about summary refs log tree commit diff
path: root/tests/unit/auth/test_resources.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/auth/test_resources.py')
-rw-r--r--tests/unit/auth/test_resources.py37
1 files changed, 20 insertions, 17 deletions
diff --git a/tests/unit/auth/test_resources.py b/tests/unit/auth/test_resources.py
index 292f7dc..81f967e 100644
--- a/tests/unit/auth/test_resources.py
+++ b/tests/unit/auth/test_resources.py
@@ -50,7 +50,7 @@ def test_create_resource(# pylint: disable=[too-many-arguments, too-many-positio
 
     with db.cursor(conn) as cursor:
         resource = create_resource(
-            cursor, "test_resource", resource_category, user, _group, False)
+            conn, "test_resource", resource_category, user, _group, False)
         assert resource == expected
         # Cleanup
         cursor.execute(
@@ -82,15 +82,14 @@ def test_create_resource_raises_for_unauthorised_users(
             tuple(client for client in clients if client.user == user)[0]))
     conn, _group, _users = fxtr_users_in_group
     with pytest.raises(AuthorisationError):
-        with db.cursor(conn) as cursor:
-            assert create_resource(
-                cursor,
-                "test_resource",
-                resource_category,
-                user,
-                _group,
-                False
-            ) == expected
+        assert create_resource(
+            conn,
+            "test_resource",
+            resource_category,
+            user,
+            _group,
+            False
+        ) == expected
 
 def sort_key_resources(resource):
     """Sort-key for resources."""
@@ -115,19 +114,19 @@ def test_public_resources(fxtr_resources):
     "user,expected",
     tuple(zip(
         conftest.TEST_USERS,
-        (sorted(
+        ((sorted(
             {res.resource_id: res for res in
              ((conftest.GROUP_RESOURCES[0],) +
               conftest.TEST_RESOURCES_GROUP_01 +
               conftest.TEST_RESOURCES_PUBLIC)}.values(),
-            key=sort_key_resources),
-         sorted(
+            key=sort_key_resources), 6),
+         (sorted(
              {res.resource_id: res for res in
               ((conftest.TEST_RESOURCES_GROUP_01[1],) +
                conftest.TEST_RESOURCES_PUBLIC)}.values()
              ,
-             key=sort_key_resources),
-         PUBLIC_RESOURCES, PUBLIC_RESOURCES))))
+             key=sort_key_resources), 4),
+         (PUBLIC_RESOURCES, 3), (PUBLIC_RESOURCES, 3)))))
 def test_user_resources(fxtr_resource_user_roles, user, expected):
     """
     GIVEN: some resources in the database
@@ -135,6 +134,10 @@ def test_user_resources(fxtr_resource_user_roles, user, expected):
     THEN: list only the resources for which the user can access
     """
     conn, *_others = fxtr_resource_user_roles
+    uresources, count = user_resources(conn, user)
+    eresources, ecount = expected
+    assert count == ecount
     assert sorted(
-        {res.resource_id: res for res in user_resources(conn, user)
-         }.values(), key=sort_key_resources) == expected
+        {res.resource_id: res for res in  uresources}.values(),
+        key=sort_key_resources
+    ) == eresources