Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
geido committed May 17, 2023
1 parent 59b3b94 commit 208814c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
7 changes: 4 additions & 3 deletions tests/integration_tests/charts/api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,9 +678,10 @@ def test_chart_get_list_no_username(self):
response = self.get_assert_metric("api/v1/chart/", "get_list")
res = json.loads(response.data.decode("utf-8"))["result"]

self.assertEqual(res[0]["slice_name"], new_name)
self.assertNotIn("username", res[0]["changed_by"].keys())
self.assertNotIn("username", res[0]["owners"][0].keys())
current_chart = [d for d in res if d["id"] == chart_id][0]
self.assertEqual(current_chart["slice_name"], new_name)
self.assertNotIn("username", current_chart["changed_by"].keys())
self.assertNotIn("username", current_chart["owners"][0].keys())

db.session.delete(model)
db.session.commit()
Expand Down
7 changes: 4 additions & 3 deletions tests/integration_tests/dashboards/api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1473,9 +1473,10 @@ def test_dashboard_get_list_no_username(self):
response = self.get_assert_metric("api/v1/dashboard/", "get_list")
res = json.loads(response.data.decode("utf-8"))["result"]

self.assertEqual(res[0]["dashboard_title"], "title2")
self.assertNotIn("username", res[0]["changed_by"].keys())
self.assertNotIn("username", res[0]["owners"][0].keys())
current_dash = [d for d in res if d["id"] == dashboard_id][0]
self.assertEqual(current_dash["dashboard_title"], "title2")
self.assertNotIn("username", current_dash["changed_by"].keys())
self.assertNotIn("username", current_dash["owners"][0].keys())

db.session.delete(model)
db.session.commit()
Expand Down
17 changes: 10 additions & 7 deletions tests/integration_tests/datasets/api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1333,8 +1333,9 @@ def test_dataset_get_list_no_username(self):
response = self.get_assert_metric("api/v1/dataset/", "get_list")
res = json.loads(response.data.decode("utf-8"))["result"]

self.assertEqual(res[0]["description"], "changed_description")
self.assertNotIn("username", res[0]["changed_by"].keys())
current_dataset = [d for d in res if d["id"] == dataset.id][0]
self.assertEqual(current_dataset["description"], "changed_description")
self.assertNotIn("username", current_dataset["changed_by"].keys())

db.session.delete(dataset)
db.session.commit()
Expand Down Expand Up @@ -1381,8 +1382,9 @@ def test_dataset_activity_access_enabled(self):
response = self.get_assert_metric("api/v1/dataset/", "get_list")
res = json.loads(response.data.decode("utf-8"))["result"]

self.assertEqual(res[0]["description"], "changed_description")
self.assertEqual(res[0]["changed_by_url"], "/superset/profile/admin")
current_dataset = [d for d in res if d["id"] == dataset.id][0]
self.assertEqual(current_dataset["description"], "changed_description")
self.assertEqual(current_dataset["changed_by_url"], "/superset/profile/admin")

app.config["ENABLE_BROAD_ACTIVITY_ACCESS"] = access_flag
db.session.delete(dataset)
Expand All @@ -1401,14 +1403,15 @@ def test_dataset_activity_access_disabled(self):
self.login(username="admin")
table_data = {"description": "changed_description"}
uri = f"api/v1/dataset/{dataset.id}"
rv = self.client.put(uri, json=table_data)
rv = self.put_assert_metric(uri, table_data, "put")
self.assertEqual(rv.status_code, 200)

response = self.get_assert_metric("api/v1/dataset/", "get_list")
res = json.loads(response.data.decode("utf-8"))["result"]

self.assertEqual(res[0]["description"], "changed_description")
self.assertEqual(res[0]["changed_by_url"], "")
current_dataset = [d for d in res if d["id"] == dataset.id][0]
self.assertEqual(current_dataset["description"], "changed_description")
self.assertEqual(current_dataset["changed_by_url"], "")

app.config["ENABLE_BROAD_ACTIVITY_ACCESS"] = access_flag
db.session.delete(dataset)
Expand Down

0 comments on commit 208814c

Please sign in to comment.