aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/auth/test_resources.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-12-12 13:33:13 +0300
committerFrederick Muriuki Muriithi2022-12-12 13:33:13 +0300
commit5269d0e9927a18f7266d53ecb67a81c7eadf70b9 (patch)
tree8076d960d860b1bed533c12d33616c580221d94d /tests/unit/auth/test_resources.py
parent2344e4cd55cc37dac93ab2127a456a39dc4fedbe (diff)
downloadgenenetwork3-5269d0e9927a18f7266d53ecb67a81c7eadf70b9.tar.gz
tests: Update fixtures to use for testing resources functions
Diffstat (limited to 'tests/unit/auth/test_resources.py')
-rw-r--r--tests/unit/auth/test_resources.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/tests/unit/auth/test_resources.py b/tests/unit/auth/test_resources.py
index 88edc77..824062d 100644
--- a/tests/unit/auth/test_resources.py
+++ b/tests/unit/auth/test_resources.py
@@ -42,34 +42,37 @@ def test_create_resource(mocker, test_app, test_users_in_group, user, expected):
SORTKEY = lambda resource: resource.resource_id
@pytest.mark.unit_test
-def test_public_resources(test_resources):
+def test_public_resources(fixture_resources):
"""
GIVEN: some resources in the database
WHEN: public resources are requested
THEN: only list the resources that are public
"""
- conn, _res = test_resources
+ conn, _res = fixture_resources
assert sorted(public_resources(conn), key=SORTKEY) == sorted(tuple(
res for res in conftest.TEST_RESOURCES if res.public), key=SORTKEY)
-PUBLIC_RESOURCES = sorted(conftest.TEST_RESOURCES, key=SORTKEY)
+PUBLIC_RESOURCES = sorted(conftest.TEST_RESOURCES_PUBLIC, key=SORTKEY)
-@pytest.mark.skip # REMOVE THIS LINE!!!
@pytest.mark.unit_test
@pytest.mark.parametrize(
"user,expected",
tuple(zip(
conftest.TEST_USERS,
- (sorted(conftest.TEST_RESOURCES, key=SORTKEY),
- sorted(res for res in conftest.TEST_RESOURCES
- if str(res.resource_id) not in
- ("2130aec0-fefd-434d-92fd-9ca342348b2d",
- "14496a1c-c234-49a2-978c-8859ea274054")),
+ (sorted(
+ set(conftest.TEST_RESOURCES_GROUP_01).union(
+ conftest.TEST_RESOURCES_PUBLIC),
+ key=SORTKEY),
+ sorted(
+ set([conftest.TEST_RESOURCES_GROUP_01[1]]).union(
+ conftest.TEST_RESOURCES_PUBLIC),
+ key=SORTKEY),
PUBLIC_RESOURCES, PUBLIC_RESOURCES))))
-def test_user_resources(fixture_user_resources, user, expected):
+def test_user_resources(fixture_group_user_roles, user, expected):
"""
GIVEN: some resources in the database
WHEN: a particular user's resources are requested
THEN: list only the resources for which the user can access
"""
- assert user_resources(fixture_user_resources, user) == expected
+ conn = fixture_group_user_roles
+ assert sorted(user_resources(conn, user), key=SORTKEY) == expected