diff options
author | Frederick Muriuki Muriithi | 2022-02-14 06:56:32 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-02-17 06:37:30 +0300 |
commit | 74044f3c7985308b4996da3a52f91c5c20a19194 (patch) | |
tree | d86714b859b31cbbd1755522f8abd8eed16e321b /tests/unit/test_authentication.py | |
parent | 67f517aa0f44f55dc691ffd791bf22ef7af0b02c (diff) | |
download | genenetwork3-74044f3c7985308b4996da3a52f91c5c20a19194.tar.gz |
Use pytest's "mark" feature to categorise tests
Use pytest's `mark` feature to explicitly categorise the tests and run them
per category
Diffstat (limited to 'tests/unit/test_authentication.py')
-rw-r--r-- | tests/unit/test_authentication.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/tests/unit/test_authentication.py b/tests/unit/test_authentication.py index 061b684..59c88ef 100644 --- a/tests/unit/test_authentication.py +++ b/tests/unit/test_authentication.py @@ -1,8 +1,10 @@ """Test cases for authentication.py""" import json import unittest - from unittest import mock + +import pytest + from gn3.authentication import AdminRole from gn3.authentication import DataRole from gn3.authentication import get_highest_user_access_role @@ -24,6 +26,7 @@ class TestGetUserMembership(unittest.TestCase): '"created_timestamp": "Oct 06 2021 06:39PM"}')} self.conn = conn + @pytest.mark.unit_test def test_user_is_group_member_only(self): """Test that a user is only a group member""" self.assertEqual( @@ -34,6 +37,7 @@ class TestGetUserMembership(unittest.TestCase): {"member": True, "admin": False}) + @pytest.mark.unit_test def test_user_is_group_admin_only(self): """Test that a user is a group admin only""" self.assertEqual( @@ -44,6 +48,7 @@ class TestGetUserMembership(unittest.TestCase): {"member": False, "admin": True}) + @pytest.mark.unit_test def test_user_is_both_group_member_and_admin(self): """Test that a user is both an admin and member of a group""" self.assertEqual( @@ -58,6 +63,7 @@ class TestGetUserMembership(unittest.TestCase): class TestCheckUserAccessRole(unittest.TestCase): """Test cases for `get_highest_user_access_role`""" + @pytest.mark.unit_test @mock.patch("gn3.authentication.requests.get") def test_edit_access(self, requests_mock): """Test that the right access roles are set if the user has edit access""" @@ -79,6 +85,7 @@ class TestCheckUserAccessRole(unittest.TestCase): "admin": AdminRole.EDIT_ACCESS, }) + @pytest.mark.unit_test @mock.patch("gn3.authentication.requests.get") def test_no_access(self, requests_mock): """Test that the right access roles are set if the user has no access""" |