about summary refs log tree commit diff
path: root/tests/unit/auth/test_resources.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-09-15 10:14:54 +0300
committerFrederick Muriuki Muriithi2023-09-26 03:44:31 +0300
commitc3ce0e40dc2c1982d50655b5d49ab0e1da922b1a (patch)
treec379a5306e67318f7b8b5e86df6a090f35a6be09 /tests/unit/auth/test_resources.py
parentf6566c76d97cb44d47cc491f13e1342f0c2555cf (diff)
downloadgn-auth-c3ce0e40dc2c1982d50655b5d49ab0e1da922b1a.tar.gz
Add System resource, and group resource(s) to list of user resources
* The system resource is public, and should be present for all users.
* Each user that is a member of a group, should have their group show
  up in their list of resources.
* Fix the SQL join: add an `ON ...` clause.
Diffstat (limited to 'tests/unit/auth/test_resources.py')
-rw-r--r--tests/unit/auth/test_resources.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/tests/unit/auth/test_resources.py b/tests/unit/auth/test_resources.py
index ee4f312..9b4d0e7 100644
--- a/tests/unit/auth/test_resources.py
+++ b/tests/unit/auth/test_resources.py
@@ -77,6 +77,9 @@ def sort_key_resources(resource):
     """Sort-key for resources."""
     return resource.resource_id
 
+PUBLIC_RESOURCES = sorted(
+    conftest.TEST_RESOURCES_PUBLIC, key=sort_key_resources)
+
 @pytest.mark.unit_test
 def test_public_resources(fxtr_resources):
     """
@@ -85,12 +88,8 @@ def test_public_resources(fxtr_resources):
     THEN: only list the resources that are public
     """
     conn, _res = fxtr_resources
-    assert sorted(public_resources(conn), key=sort_key_resources) == sorted(tuple(
-        res for res in conftest.TEST_RESOURCES if res.public), key=sort_key_resources)
-
-PUBLIC_RESOURCES = sorted(
-    {res.resource_id: res for res in conftest.TEST_RESOURCES_PUBLIC}.values(),
-    key=sort_key_resources)
+    assert sorted(
+        public_resources(conn), key=sort_key_resources) == PUBLIC_RESOURCES
 
 @pytest.mark.unit_test
 @pytest.mark.parametrize(
@@ -99,7 +98,8 @@ PUBLIC_RESOURCES = sorted(
         conftest.TEST_USERS,
         (sorted(
             {res.resource_id: res for res in
-             (conftest.TEST_RESOURCES_GROUP_01 +
+             ((conftest.GROUP_RESOURCES[0],) +
+              conftest.TEST_RESOURCES_GROUP_01 +
               conftest.TEST_RESOURCES_PUBLIC)}.values(),
             key=sort_key_resources),
          sorted(