diff options
author | Frederick Muriuki Muriithi | 2023-01-18 14:59:35 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2023-01-18 14:59:35 +0300 |
commit | 4cc328ef78c7b8108d7623fdd4fcae5294317f2e (patch) | |
tree | 5fff59d3a57bb6e0ec044373f205ed4503d8b47a /tests/unit/auth/test_groups.py | |
parent | e97703817628e6b781c5b883ed3aa7fbf9967628 (diff) | |
download | genenetwork3-4cc328ef78c7b8108d7623fdd4fcae5294317f2e.tar.gz |
auth: Fix tests after enforcing FOREIGN KEY constraint
Fix a number of tests and fixtures that were not conforming to the FOREIGN KEY
constraints:
* Each test that creates a new "object" needs to clean up after itself
* Each fixture that sets up test data needs to clean up after itself
Diffstat (limited to 'tests/unit/auth/test_groups.py')
-rw-r--r-- | tests/unit/auth/test_groups.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/unit/auth/test_groups.py b/tests/unit/auth/test_groups.py index 53e0543..158360e 100644 --- a/tests/unit/auth/test_groups.py +++ b/tests/unit/auth/test_groups.py @@ -73,10 +73,15 @@ def test_create_group_role(mocker, fxtr_users_in_group, fxtr_app, user, expected mocker.patch("gn3.auth.authorisation.groups.uuid4", uuid_fn) mocker.patch("gn3.auth.authorisation.roles.uuid4", uuid_fn) conn, _group, _users = fxtr_users_in_group - with fxtr_app.app_context() as flask_context: + with fxtr_app.app_context() as flask_context, db.cursor(conn) as cursor: flask_context.g.user = user assert create_group_role( conn, GROUP, "ResourceEditor", PRIVILEGES) == expected + # cleanup + cursor.execute( + ("DELETE FROM group_roles " + "WHERE group_role_id=? AND group_id=? AND role_id=?"), + (str(uuid_fn()), str(GROUP.group_id), str(uuid_fn()))) @pytest.mark.unit_test def test_create_multiple_groups(mocker, fxtr_app, fxtr_users): |