aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/auth/test_resources.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-12-08 08:32:26 +0300
committerFrederick Muriuki Muriithi2022-12-08 08:35:42 +0300
commitb408d90f52766861071b6fefe01f8bf9d213432e (patch)
tree0a410830acdec6e3e25b33bb16a4255d15074fc5 /tests/unit/auth/test_resources.py
parent836924e7dccddaceb036fe3a312ca6811ccf2228 (diff)
downloadgenenetwork3-b408d90f52766861071b6fefe01f8bf9d213432e.tar.gz
auth: test for `user_resources` function (incomplete)
* gn3/auth/authorisation/resources.py: dummy `user_resources` function * tests/unit/auth/conftest.py: (incomplete): Add some fixtures for testing the `user_resources` function * tests/unit/auth/test_resources.py: test the `user_resources` function
Diffstat (limited to 'tests/unit/auth/test_resources.py')
-rw-r--r--tests/unit/auth/test_resources.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/unit/auth/test_resources.py b/tests/unit/auth/test_resources.py
index 6dc0e98..88edc77 100644
--- a/tests/unit/auth/test_resources.py
+++ b/tests/unit/auth/test_resources.py
@@ -51,3 +51,25 @@ def test_public_resources(test_resources):
conn, _res = test_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)
+
+@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")),
+ PUBLIC_RESOURCES, PUBLIC_RESOURCES))))
+def test_user_resources(fixture_user_resources, 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