superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ccwilli...@apache.org
Subject [incubator-superset] branch dashboard-builder updated: [dashboard v2] fix python tests
Date Fri, 22 Jun 2018 21:52:52 GMT
This is an automated email from the ASF dual-hosted git repository.

ccwilliams pushed a commit to branch dashboard-builder
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/dashboard-builder by this push:
     new 047cb80  [dashboard v2] fix python tests
047cb80 is described below

commit 047cb804906252c7aedb6b0425505200f965f8b2
Author: Chris Williams <chris.williams@airbnb.com>
AuthorDate: Fri Jun 22 14:52:38 2018 -0700

    [dashboard v2] fix python tests
---
 tests/dashboard_tests.py | 93 ++++--------------------------------------------
 1 file changed, 6 insertions(+), 87 deletions(-)

diff --git a/tests/dashboard_tests.py b/tests/dashboard_tests.py
index f1b035a..671c07d 100644
--- a/tests/dashboard_tests.py
+++ b/tests/dashboard_tests.py
@@ -61,26 +61,10 @@ class DashboardTests(SupersetTestCase):
         self.login(username=username)
         dash = db.session.query(models.Dashboard).filter_by(
             slug='births').first()
-        positions = {
-            'DASHBOARD_VERSION_KEY': 'v2',
-        }
-        for i, slc in enumerate(dash.slices):
-            id = 'DASHBOARD_CHART_TYPE-{}'.format(i)
-            d = {
-                'type': 'DASHBOARD_CHART_TYPE',
-                'id': id,
-                'children': [],
-                'meta': {
-                    'width': 4,
-                    'height': 50,
-                    'chartId': slc.id,
-                },
-            }
-            positions[id] = d
         data = {
             'css': '',
             'expanded_slices': {},
-            'positions': positions,
+            'positions': dash.position_array,
             'dashboard_title': dash.dashboard_title,
         }
         url = '/superset/save_dash/{}/'.format(dash.id)
@@ -91,29 +75,13 @@ class DashboardTests(SupersetTestCase):
         self.login(username=username)
         dash = db.session.query(models.Dashboard).filter_by(
             slug='world_health').first()
-        positions = {
-            'DASHBOARD_VERSION_KEY': 'v2',
-        }
-        for i, slc in enumerate(dash.slices):
-            id = 'DASHBOARD_CHART_TYPE-{}'.format(i)
-            d = {
-                'type': 'DASHBOARD_CHART_TYPE',
-                'id': id,
-                'children': [],
-                'meta': {
-                    'width': 4,
-                    'height': 50,
-                    'chartId': slc.id,
-                },
-            }
-            positions[id] = d
 
         filters = {str(dash.slices[0].id): {'region': ['North America']}}
         default_filters = json.dumps(filters)
         data = {
             'css': '',
             'expanded_slices': {},
-            'positions': positions,
+            'positions': dash.position_array,
             'dashboard_title': dash.dashboard_title,
             'default_filters': default_filters,
         }
@@ -138,26 +106,10 @@ class DashboardTests(SupersetTestCase):
             .first()
         )
         origin_title = dash.dashboard_title
-        positions = {
-            'DASHBOARD_VERSION_KEY': 'v2',
-        }
-        for i, slc in enumerate(dash.slices):
-            id = 'DASHBOARD_CHART_TYPE-{}'.format(i)
-            d = {
-                'type': 'DASHBOARD_CHART_TYPE',
-                'id': id,
-                'children': [],
-                'meta': {
-                    'width': 4,
-                    'height': 50,
-                    'chartId': slc.id,
-                },
-            }
-            positions[id] = d
         data = {
             'css': '',
             'expanded_slices': {},
-            'positions': positions,
+            'positions': dash.position_array,
             'dashboard_title': 'new title',
         }
         url = '/superset/save_dash/{}/'.format(dash.id)
@@ -168,7 +120,7 @@ class DashboardTests(SupersetTestCase):
             .first()
         )
         self.assertEqual(updatedDash.dashboard_title, 'new title')
-        # # bring back dashboard original title
+        # bring back dashboard original title
         data['dashboard_title'] = origin_title
         self.get_resp(url, data=dict(data=json.dumps(data)))
 
@@ -176,27 +128,11 @@ class DashboardTests(SupersetTestCase):
         self.login(username=username)
         dash = db.session.query(models.Dashboard).filter_by(
             slug='births').first()
-        positions = {
-            'DASHBOARD_VERSION_KEY': 'v2',
-        }
-        for i, slc in enumerate(dash.slices):
-            id = 'DASHBOARD_CHART_TYPE-{}'.format(i)
-            d = {
-                'type': 'DASHBOARD_CHART_TYPE',
-                'id': id,
-                'children': [],
-                'meta': {
-                    'width': 4,
-                    'height': 50,
-                    'chartId': slc.id,
-                },
-            }
-            positions[id] = d
         data = {
             'css': '',
             'duplicate_slices': False,
             'expanded_slices': {},
-            'positions': positions,
+            'positions': dash.position_array,
             'dashboard_title': 'Copy Of Births',
         }
 
@@ -250,25 +186,8 @@ class DashboardTests(SupersetTestCase):
         self.login(username=username)
         dash = db.session.query(models.Dashboard).filter_by(
             slug='births').first()
-        positions = {
-            'DASHBOARD_VERSION_KEY': 'v2',
-        }
+        positions = dash.position_array[:-1]
         origin_slices_length = len(dash.slices)
-        for i, slc in enumerate(dash.slices):
-            id = 'DASHBOARD_CHART_TYPE-{}'.format(i)
-            d = {
-                'type': 'DASHBOARD_CHART_TYPE',
-                'id': id,
-                'children': [],
-                'meta': {
-                    'width': 4,
-                    'height': 50,
-                    'chartId': slc.id,
-                },
-            }
-            # remove last slice
-            if i < len(dash.slices) - 1:
-                positions[id] = d
 
         data = {
             'css': '',


Mime
View raw message