Skip to content

Commit

Permalink
fix: css template API response, less data (apache#17980)
Browse files Browse the repository at this point in the history
* fix: css template API response, less data

* add test
  • Loading branch information
dpgaspar authored Jan 10, 2022
1 parent d2d4f8e commit d35da1f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
4 changes: 3 additions & 1 deletion superset/css_templates/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
20 changes: 14 additions & 6 deletions tests/integration_tests/css_templates/api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def insert_css_template(
) -> 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()
Expand Down Expand Up @@ -75,15 +75,23 @@ def test_get_list_css_template(self):
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):
Expand Down

0 comments on commit d35da1f

Please sign in to comment.