-
Notifications
You must be signed in to change notification settings - Fork 13.8k
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
[test] Fix test data remove slice_name #7898
[test] Fix test data remove slice_name #7898
Conversation
Codecov Report
@@ Coverage Diff @@
## master #7898 +/- ##
==========================================
+ Coverage 65.76% 65.76% +<.01%
==========================================
Files 461 461
Lines 22188 22190 +2
Branches 2425 2425
==========================================
+ Hits 14592 14594 +2
Misses 7475 7475
Partials 121 121
Continue to review full report at Codecov.
|
superset/views/core.py
Outdated
@@ -1974,7 +1974,8 @@ def _set_dash_metadata(dashboard, data): | |||
): | |||
slice_id = value.get("meta").get("chartId") | |||
slice_ids.append(slice_id) | |||
slice_id_to_name[slice_id] = value.get("meta").get("sliceName") | |||
if "sliceName" in value.get("meta"): | |||
slice_id_to_name[slice_id] = value.get("meta").get("sliceName") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
superset/views/core.py
Outdated
@@ -1974,7 +1974,8 @@ def _set_dash_metadata(dashboard, data): | |||
): | |||
slice_id = value.get("meta").get("chartId") | |||
slice_ids.append(slice_id) | |||
slice_id_to_name[slice_id] = value.get("meta").get("sliceName") | |||
if "sliceName" in value.get("meta"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somewhat unrelated to your change but I sense we can cleanup some of this logic (which could be error prone as get()
returns None
if the key doesn't exist),
if (
isinstance(value, dict)
and "meta" in value
and "chartId" in value["meta"]
):
slice_id = value["meta"]["chartId"]
slice_ids.append(slice_id)
if "sliceName" in value["meta"]:
slice_id_to_name[slice_id] = value["meta"]["sliceName"]
or
try:
slice_id = value["meta"]["chartId"]
...
except KeyError:
pass
Note I'm uncertain whether sliceId
or sliceName
could be None
and whether additional checks are required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
meta, sliceId, sliceName could be None.
user doesn't have to show a slice with name in dashboard, but the associated Slice entry in the database still have name column
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
@graceguo-supercat thanks for tracing down the root cause of the issue. I had a couple of small comments but otherwise this LGTM. |
c5536f3
to
fea173b
Compare
fea173b
to
2610c00
Compare
* [text] Fix test data remove slice_name * fix review comment
CATEGORY
Choose one
SUMMARY
When user save dashboard, we allow user do not user original slice_name saved in Slice table, and have a copy of slice name which is only used by a dashboard. We also allow user to set this dashboard's slice name be empty.
in front-end code i think we copy slice_name into layout data and send with save_dash API. But in unit tests we didn't set slicename attribute in the mock layout data, and cause after /save_dash/ api call in unit test, sample slices created for unit tests lost their slice_name. So that some unit tests that rely on slice_name uniqueness became flacky.
Solution
I fixed the logic in save_dash. It will only reset slice_name when has explicit attribute in layout.
TEST PLAN
CI
REVIEWERS
@john-bodley @mistercrunch