superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From johnbod...@apache.org
Subject [incubator-superset] branch master updated: [druid] Excluding refreshing verbose name (#4761)
Date Thu, 05 Apr 2018 00:16:55 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new df4ff05  [druid] Excluding refreshing verbose name (#4761)
df4ff05 is described below

commit df4ff05441eaac7ca99f5725956f500344bc257d
Author: John Bodley <4567245+john-bodley@users.noreply.github.com>
AuthorDate: Wed Apr 4 17:16:53 2018 -0700

    [druid] Excluding refreshing verbose name (#4761)
---
 superset/connectors/druid/models.py |  2 +-
 tests/druid_tests.py                | 49 ++++++++++++++++++++++++++++++++-----
 2 files changed, 44 insertions(+), 7 deletions(-)

diff --git a/superset/connectors/druid/models.py b/superset/connectors/druid/models.py
index 9a8d658..25c68ac 100644
--- a/superset/connectors/druid/models.py
+++ b/superset/connectors/druid/models.py
@@ -372,7 +372,7 @@ class DruidColumn(Model, BaseColumn):
         for metric in metrics.values():
             dbmetric = dbmetrics.get(metric.metric_name)
             if dbmetric:
-                for attr in ['json', 'metric_type', 'verbose_name']:
+                for attr in ['json', 'metric_type']:
                     setattr(dbmetric, attr, getattr(metric, attr))
             else:
                 with db.session.no_autoflush:
diff --git a/tests/druid_tests.py b/tests/druid_tests.py
index 7406dac..b0d9caf 100644
--- a/tests/druid_tests.py
+++ b/tests/druid_tests.py
@@ -376,13 +376,19 @@ class DruidTests(SupersetTestCase):
                     'double{}'.format(agg.capitalize()),
                 )
 
-            # Augment a metric.
-            metadata = SEGMENT_METADATA[:]
-            metadata[0]['columns']['metric1']['type'] = 'LONG'
-            instance = PyDruid.return_value
-            instance.segment_metadata.return_value = metadata
-            cluster.refresh_datasources()
+    @patch('superset.connectors.druid.models.PyDruid')
+    def test_refresh_metadata_augment_type(self, PyDruid):
+        self.login(username='admin')
+        cluster = self.get_cluster(PyDruid)
+        cluster.refresh_datasources()
 
+        metadata = SEGMENT_METADATA[:]
+        metadata[0]['columns']['metric1']['type'] = 'LONG'
+        instance = PyDruid.return_value
+        instance.segment_metadata.return_value = metadata
+        cluster.refresh_datasources()
+
+        for i, datasource in enumerate(cluster.datasources):
             metrics = (
                 db.session.query(DruidMetric)
                 .filter(DruidMetric.datasource_id == datasource.id)
@@ -397,6 +403,37 @@ class DruidTests(SupersetTestCase):
                     'long{}'.format(agg.capitalize()),
                 )
 
+    @patch('superset.connectors.druid.models.PyDruid')
+    def test_refresh_metadata_augment_verbose_name(self, PyDruid):
+        self.login(username='admin')
+        cluster = self.get_cluster(PyDruid)
+        cluster.refresh_datasources()
+
+        for i, datasource in enumerate(cluster.datasources):
+            metrics = (
+                db.session.query(DruidMetric)
+                .filter(DruidMetric.datasource_id == datasource.id)
+                .filter(DruidMetric.metric_name.like('%__metric1'))
+            )
+
+            for metric in metrics:
+                metric.verbose_name = metric.metric_name
+
+            db.session.commit()
+
+        # The verbose name should not change during a refresh.
+        cluster.refresh_datasources()
+
+        for i, datasource in enumerate(cluster.datasources):
+            metrics = (
+                db.session.query(DruidMetric)
+                .filter(DruidMetric.datasource_id == datasource.id)
+                .filter(DruidMetric.metric_name.like('%__metric1'))
+            )
+
+            for metric in metrics:
+                self.assertEqual(metric.verbose_name, metric.metric_name)
+
     def test_urls(self):
         cluster = self.get_test_cluster_obj()
         self.assertEquals(

-- 
To stop receiving notification emails like this one, please contact
johnbodley@apache.org.

Mime
View raw message