Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoyongjie committed Jul 27, 2022
1 parent f1cd5bd commit 5572f3f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion superset/dashboards/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,9 @@ def get_datasets(self, id_or_slug: str) -> Response:
return self.response(200, result=result)
except (TypeError, ValueError) as err:
return self.response_400(
message=gettext(f"Dataset schema is invalid, caused by: {str(err)}")
message=gettext(
"Dataset schema is invalid, caused by: %(error)s", error=str(err)
)
)
except DashboardAccessDeniedError:
return self.response_403()
Expand Down
12 changes: 12 additions & 0 deletions tests/unit_tests/core_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@ def test_get_metric_name_invalid_metric():
with pytest.raises(ValueError):
get_metric_name(metric)

metric = deepcopy(SQL_ADHOC_METRIC)
del metric["expressionType"]
with pytest.raises(ValueError):
get_metric_name(metric)

with pytest.raises(ValueError):
get_metric_name(None)
with pytest.raises(ValueError):
get_metric_name(0)
with pytest.raises(ValueError):
get_metric_name({})


def test_get_metric_names():
assert get_metric_names(
Expand Down

0 comments on commit 5572f3f

Please sign in to comment.