Skip to content

Commit

Permalink
add owners key
Browse files Browse the repository at this point in the history
  • Loading branch information
hughhhh authored Apr 28, 2022
1 parent 158417f commit 2815838
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/integration_tests/datasource_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,14 @@ def save_datasource_from_dict(self, datasource_post):
@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
def test_change_database(self):
self.login(username="admin")
admin_user = self.get_user("admin")

tbl = self.get_table(name="birth_names")
tbl_id = tbl.id
db_id = tbl.database_id
datasource_post = get_datasource_post()
datasource_post["id"] = tbl_id
datasource_post["owners"] = [admin_user.id]

new_db = self.create_fake_db()
datasource_post["database"]["id"] = new_db.id
Expand All @@ -316,6 +319,26 @@ def test_change_database(self):

self.delete_fake_db()

@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
def test_edit_alpha_not_owner(self):
self.login(username="alpha")
alpha_user = self.get_user("alpha")

tbl = self.get_table(name="birth_names")
tbl_id = tbl.id
datasource_post = get_datasource_post()
datasource_post["id"] = tbl_id
datasource_post["owners"] = [alpha_user.id]

new_db = self.create_fake_db()
datasource_post["database"]["id"] = new_db.id

data = dict(data=json.dumps(datasource_post))
resp = self.get_json_resp("/datasource/save/", data, raise_on_error=False)
self.assertIn("Changing this dataset is forbidden", resp["error"])

self.delete_fake_db()

def test_save_duplicate_key(self):
self.login(username="admin")
tbl_id = self.get_table(name="birth_names").id
Expand Down

0 comments on commit 2815838

Please sign in to comment.