-
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(explore): unable to update linked charts (#22896)
- Loading branch information
1 parent
deb5109
commit ad1ffbd
Showing
4 changed files
with
99 additions
and
5 deletions.
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
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 |
---|---|---|
|
@@ -692,6 +692,61 @@ def test_update_chart_not_owned(self): | |
db.session.delete(user_alpha2) | ||
db.session.commit() | ||
|
||
def test_update_chart_linked_with_not_owned_dashboard(self): | ||
""" | ||
Chart API: Test update chart which is linked to not owned dashboard | ||
""" | ||
user_alpha1 = self.create_user( | ||
"alpha1", "password", "Alpha", email="[email protected]" | ||
) | ||
user_alpha2 = self.create_user( | ||
"alpha2", "password", "Alpha", email="[email protected]" | ||
) | ||
chart = self.insert_chart("title", [user_alpha1.id], 1) | ||
|
||
original_dashboard = Dashboard() | ||
original_dashboard.dashboard_title = "Original Dashboard" | ||
original_dashboard.slug = "slug" | ||
original_dashboard.owners = [user_alpha1] | ||
original_dashboard.slices = [chart] | ||
original_dashboard.published = False | ||
db.session.add(original_dashboard) | ||
|
||
new_dashboard = Dashboard() | ||
new_dashboard.dashboard_title = "Cloned Dashboard" | ||
new_dashboard.slug = "new_slug" | ||
new_dashboard.owners = [user_alpha2] | ||
new_dashboard.slices = [chart] | ||
new_dashboard.published = False | ||
db.session.add(new_dashboard) | ||
|
||
self.login(username="alpha1", password="password") | ||
chart_data_with_invalid_dashboard = { | ||
"slice_name": "title1_changed", | ||
"dashboards": [original_dashboard.id, 0], | ||
} | ||
chart_data = { | ||
"slice_name": "title1_changed", | ||
"dashboards": [original_dashboard.id, new_dashboard.id], | ||
} | ||
uri = f"api/v1/chart/{chart.id}" | ||
|
||
rv = self.put_assert_metric(uri, chart_data_with_invalid_dashboard, "put") | ||
self.assertEqual(rv.status_code, 422) | ||
response = json.loads(rv.data.decode("utf-8")) | ||
expected_response = {"message": {"dashboards": ["Dashboards do not exist"]}} | ||
self.assertEqual(response, expected_response) | ||
|
||
rv = self.put_assert_metric(uri, chart_data, "put") | ||
self.assertEqual(rv.status_code, 200) | ||
|
||
db.session.delete(chart) | ||
db.session.delete(original_dashboard) | ||
db.session.delete(new_dashboard) | ||
db.session.delete(user_alpha1) | ||
db.session.delete(user_alpha2) | ||
db.session.commit() | ||
|
||
def test_update_chart_validate_datasource(self): | ||
""" | ||
Chart API: Test update validate datasource | ||
|
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