about summary refs log tree commit diff
path: root/tests/unit/auth/test_groups.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-08-23 09:12:07 +0300
committerFrederick Muriuki Muriithi2023-08-23 09:13:02 +0300
commit8d35e0413fa670ef4fc08e7262a12c43b89df6fc (patch)
treedd6bbc1f13a5a241f28f8507a659de1d3474af24 /tests/unit/auth/test_groups.py
parent277297d9a804e09137493bd9e1613df94f154dc0 (diff)
downloadgn-auth-8d35e0413fa670ef4fc08e7262a12c43b89df6fc.tar.gz
pylint: Replace `lambda ...` statements with `def ...`
Diffstat (limited to 'tests/unit/auth/test_groups.py')
-rw-r--r--tests/unit/auth/test_groups.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/tests/unit/auth/test_groups.py b/tests/unit/auth/test_groups.py
index af33f85..9c4e760 100644
--- a/tests/unit/auth/test_groups.py
+++ b/tests/unit/auth/test_groups.py
@@ -19,8 +19,6 @@ create_group_failure = {
     "message": "Unauthorised: Failed to create group."
 }
 
-uuid_fn = lambda : UUID("d32611e3-07fc-4564-b56c-786c6db6de2b")
-
 GROUP = Group(UUID("9988c21d-f02f-4d45-8966-22c968ac2fbf"), "TheTestGroup",
               {"group_description": "The test group"})
 PRIVILEGES = (
@@ -45,7 +43,7 @@ def test_create_group(# pylint: disable=[too-many-arguments]
     THEN: verify they are only able to create the group if they have the
           appropriate privileges
     """
-    mocker.patch("gn_auth.auth.authorisation.groups.models.uuid4", uuid_fn)
+    mocker.patch("gn_auth.auth.authorisation.groups.models.uuid4", conftest.uuid_fn)
     mocker.patch("gn_auth.auth.authorisation.checks.require_oauth.acquire",
                  conftest.get_tokeniser(user))
     with db.connection(auth_testdb_path) as conn:
@@ -61,7 +59,7 @@ def test_create_group_raises_exception_with_non_privileged_user(# pylint: disabl
     WHEN: the user attempts to create a group
     THEN: verify the system raises an exception
     """
-    mocker.patch("gn_auth.auth.authorisation.groups.models.uuid4", uuid_fn)
+    mocker.patch("gn_auth.auth.authorisation.groups.models.uuid4", conftest.uuid_fn)
     mocker.patch("gn_auth.auth.authorisation.checks.require_oauth.acquire",
                  conftest.get_tokeniser(user))
     with db.connection(auth_testdb_path) as conn:
@@ -88,8 +86,8 @@ def test_create_group_role(mocker, fxtr_users_in_group, user, expected):
     THEN: verify they are only able to create the role if they have the
         appropriate privileges and that the role is attached to the given group
     """
-    mocker.patch("gn_auth.auth.authorisation.groups.models.uuid4", uuid_fn)
-    mocker.patch("gn_auth.auth.authorisation.roles.models.uuid4", uuid_fn)
+    mocker.patch("gn_auth.auth.authorisation.groups.models.uuid4", conftest.uuid_fn)
+    mocker.patch("gn_auth.auth.authorisation.roles.models.uuid4", conftest.uuid_fn)
     mocker.patch("gn_auth.auth.authorisation.checks.require_oauth.acquire",
                  conftest.get_tokeniser(user))
     conn, _group, _users = fxtr_users_in_group
@@ -100,7 +98,7 @@ def test_create_group_role(mocker, fxtr_users_in_group, user, expected):
         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())))
+            (str(conftest.uuid_fn()), str(GROUP.group_id), str(conftest.uuid_fn())))
 
 @pytest.mark.unit_test
 @pytest.mark.parametrize(
@@ -114,8 +112,8 @@ def test_create_group_role_raises_exception_with_unauthorised_users(
     THEN: verify they are only able to create the role if they have the
         appropriate privileges and that the role is attached to the given group
     """
-    mocker.patch("gn_auth.auth.authorisation.groups.models.uuid4", uuid_fn)
-    mocker.patch("gn_auth.auth.authorisation.roles.models.uuid4", uuid_fn)
+    mocker.patch("gn_auth.auth.authorisation.groups.models.uuid4", conftest.uuid_fn)
+    mocker.patch("gn_auth.auth.authorisation.roles.models.uuid4", conftest.uuid_fn)
     mocker.patch("gn_auth.auth.authorisation.checks.require_oauth.acquire",
                  conftest.get_tokeniser(user))
     conn, _group, _users = fxtr_users_in_group
@@ -132,7 +130,7 @@ def test_create_multiple_groups(mocker, fxtr_users):
     THEN: The system should prevent that, and respond with an appropriate error
       message
     """
-    mocker.patch("gn_auth.auth.authorisation.groups.models.uuid4", uuid_fn)
+    mocker.patch("gn_auth.auth.authorisation.groups.models.uuid4", conftest.uuid_fn)
     user = User(
         UUID("ecb52977-3004-469e-9428-2a1856725c7f"), "group@lead.er",
         "Group Leader")