-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(dashboard): Stop updating chart owners for charts removed from da…
…shboard (#21720) Co-authored-by: Michael S. Molina <[email protected]>
- Loading branch information
1 parent
5e64211
commit 684b888
Showing
2 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1347,6 +1347,65 @@ def test_update_dashboard_chart_owners(self): | |
db.session.delete(user_alpha2) | ||
db.session.commit() | ||
|
||
@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices") | ||
def test_update_dashboard_chart_owners_propagation(self): | ||
""" | ||
Dashboard API: Test update chart owners propagation | ||
""" | ||
user_alpha1 = self.create_user( | ||
"alpha1", | ||
"password", | ||
"Alpha", | ||
email="[email protected]", | ||
first_name="alpha1", | ||
) | ||
admin = self.get_user("admin") | ||
slices = [] | ||
slices.append(db.session.query(Slice).filter_by(slice_name="Trends").one()) | ||
slices.append(db.session.query(Slice).filter_by(slice_name="Boys").one()) | ||
|
||
# Insert dashboard with admin as owner | ||
dashboard = self.insert_dashboard( | ||
"title1", | ||
"slug1", | ||
[admin.id], | ||
slices=slices, | ||
) | ||
|
||
# Updates dashboard without Boys in json_metadata positions | ||
# and user_alpha1 as owner | ||
dashboard_data = { | ||
"owners": [user_alpha1.id], | ||
"json_metadata": json.dumps( | ||
{ | ||
"positions": { | ||
f"{slices[0].id}": { | ||
"type": "CHART", | ||
"meta": {"chartId": slices[0].id}, | ||
}, | ||
} | ||
} | ||
), | ||
} | ||
self.login(username="admin") | ||
uri = f"api/v1/dashboard/{dashboard.id}" | ||
rv = self.client.put(uri, json=dashboard_data) | ||
self.assertEqual(rv.status_code, 200) | ||
|
||
# Check that chart named Boys does not contain alpha 1 in its owners | ||
boys = db.session.query(Slice).filter_by(slice_name="Boys").one() | ||
self.assertNotIn(user_alpha1, boys.owners) | ||
|
||
# Revert owners on slice | ||
for slice in slices: | ||
slice.owners = [] | ||
db.session.commit() | ||
|
||
# Rollback changes | ||
db.session.delete(dashboard) | ||
db.session.delete(user_alpha1) | ||
db.session.commit() | ||
|
||
def test_update_partial_dashboard(self): | ||
""" | ||
Dashboard API: Test update partial | ||
|