You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by el...@apache.org on 2022/01/27 01:05:20 UTC

[superset] 10/12: fix: css template API response, less data (#17980)

This is an automated email from the ASF dual-hosted git repository.

elizabeth pushed a commit to branch 1.4
in repository https://gitbox.apache.org/repos/asf/superset.git

commit dbe0a35a205bbd2e11817db19c492c1d443babc6
Author: Daniel Vaz Gaspar <da...@gmail.com>
AuthorDate: Mon Jan 10 13:00:39 2022 +0000

    fix: css template API response, less data (#17980)
    
    * fix: css template API response, less data
    
    * add test
---
 superset/css_templates/api.py                      |  4 +++-
 tests/integration_tests/css_templates/api_tests.py | 20 ++++++++++++++------
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/superset/css_templates/api.py b/superset/css_templates/api.py
index 8f1134b..5cc36f4 100644
--- a/superset/css_templates/api.py
+++ b/superset/css_templates/api.py
@@ -63,7 +63,9 @@ class CssTemplateRestApi(BaseSupersetModelRestApi):
     ]
     list_columns = [
         "changed_on_delta_humanized",
-        "changed_by",
+        "changed_by.first_name",
+        "changed_by.id",
+        "changed_by.last_name",
         "created_on",
         "created_by.first_name",
         "created_by.id",
diff --git a/tests/integration_tests/css_templates/api_tests.py b/tests/integration_tests/css_templates/api_tests.py
index 8401494..4e71431 100644
--- a/tests/integration_tests/css_templates/api_tests.py
+++ b/tests/integration_tests/css_templates/api_tests.py
@@ -38,7 +38,7 @@ class TestCssTemplateApi(SupersetTestCase):
     ) -> CssTemplate:
         admin = self.get_user(created_by_username)
         css_template = CssTemplate(
-            template_name=template_name, css=css, created_by=admin
+            template_name=template_name, css=css, created_by=admin, changed_by=admin
         )
         db.session.add(css_template)
         db.session.commit()
@@ -75,15 +75,23 @@ class TestCssTemplateApi(SupersetTestCase):
         data = json.loads(rv.data.decode("utf-8"))
         assert data["count"] == len(css_templates)
         expected_columns = [
-            "changed_on_delta_humanized",
             "changed_by",
-            "created_on",
+            "changed_on_delta_humanized",
             "created_by",
-            "template_name",
+            "created_on",
             "css",
+            "id",
+            "template_name",
         ]
-        for expected_column in expected_columns:
-            assert expected_column in data["result"][0]
+        result_columns = list(data["result"][0].keys())
+        result_columns.sort()
+        assert expected_columns == result_columns
+        created_by_columns = list(data["result"][0]["created_by"].keys())
+        created_by_columns.sort()
+        assert ["first_name", "id", "last_name"] == created_by_columns
+        changed_by_columns = list(data["result"][0]["changed_by"].keys())
+        changed_by_columns.sort()
+        assert ["first_name", "id", "last_name"] == changed_by_columns
 
     @pytest.mark.usefixtures("create_css_templates")
     def test_get_list_sort_css_template(self):