Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: css template API response, less data #17980

Merged
merged 2 commits into from
Jan 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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