diff options
author | Arun Isaac | 2023-12-30 05:17:17 +0000 |
---|---|---|
committer | Arun Isaac | 2023-12-30 05:17:17 +0000 |
commit | 8536431f9c367c55d2ea138ab24b2d12e98f7c81 (patch) | |
tree | 1d7d272066ee675065e4d1e89fa37fdb5293e101 /gn2/tests/unit/utility | |
parent | 21d6de22641cb1b540e03cb963d12593dab16046 (diff) | |
download | genenetwork2-8536431f9c367c55d2ea138ab24b2d12e98f7c81.tar.gz |
Namespace mock paths under gn2.
Diffstat (limited to 'gn2/tests/unit/utility')
-rw-r--r-- | gn2/tests/unit/utility/test_authentication_tools.py | 52 | ||||
-rw-r--r-- | gn2/tests/unit/utility/test_hmac.py | 14 |
2 files changed, 33 insertions, 33 deletions
diff --git a/gn2/tests/unit/utility/test_authentication_tools.py b/gn2/tests/unit/utility/test_authentication_tools.py index 3b16ca94..90945b0f 100644 --- a/gn2/tests/unit/utility/test_authentication_tools.py +++ b/gn2/tests/unit/utility/test_authentication_tools.py @@ -38,10 +38,10 @@ def mock_add_resource(resource_ob, update=False): class TestCheckResourceAvailability(unittest.TestCase): """Test methods related to checking the resource availability""" - @mock.patch('utility.authentication_tools.add_new_resource') - @mock.patch('utility.authentication_tools.Redis') - @mock.patch('utility.authentication_tools.g', TestUserSession()) - @mock.patch('utility.authentication_tools.get_resource_id') + @mock.patch('gn2.utility.authentication_tools.add_new_resource') + @mock.patch('gn2.utility.authentication_tools.Redis') + @mock.patch('gn2.utility.authentication_tools.g', TestUserSession()) + @mock.patch('gn2.utility.authentication_tools.get_resource_id') def test_check_resource_availability_default_mask( self, resource_id_mock, @@ -56,11 +56,11 @@ class TestCheckResourceAvailability(unittest.TestCase): add_new_resource_mock.return_value = {"default_mask": 2} self.assertEqual(check_resource_availability(test_dataset, user_id), 2) - @mock.patch('utility.authentication_tools.requests.get') - @mock.patch('utility.authentication_tools.add_new_resource') - @mock.patch('utility.authentication_tools.Redis') - @mock.patch('utility.authentication_tools.g', TestUserSession()) - @mock.patch('utility.authentication_tools.get_resource_id') + @mock.patch('gn2.utility.authentication_tools.requests.get') + @mock.patch('gn2.utility.authentication_tools.add_new_resource') + @mock.patch('gn2.utility.authentication_tools.Redis') + @mock.patch('gn2.utility.authentication_tools.g', TestUserSession()) + @mock.patch('gn2.utility.authentication_tools.get_resource_id') def test_check_resource_availability_non_default_mask( self, resource_id_mock, @@ -77,13 +77,13 @@ class TestCheckResourceAvailability(unittest.TestCase): self.assertEqual(check_resource_availability(test_dataset, user_id), ['foo']) - @mock.patch('utility.authentication_tools.webqtlConfig.SUPER_PRIVILEGES', + @mock.patch('gn2.utility.authentication_tools.webqtlConfig.SUPER_PRIVILEGES', "SUPERUSER") - @mock.patch('utility.authentication_tools.requests.get') - @mock.patch('utility.authentication_tools.add_new_resource') - @mock.patch('utility.authentication_tools.Redis') - @mock.patch('utility.authentication_tools.g', TestUserSession()) - @mock.patch('utility.authentication_tools.get_resource_id') + @mock.patch('gn2.utility.authentication_tools.requests.get') + @mock.patch('gn2.utility.authentication_tools.add_new_resource') + @mock.patch('gn2.utility.authentication_tools.Redis') + @mock.patch('gn2.utility.authentication_tools.g', TestUserSession()) + @mock.patch('gn2.utility.authentication_tools.get_resource_id') def test_check_resource_availability_of_super_user( self, resource_id_mock, @@ -100,14 +100,14 @@ class TestCheckResourceAvailability(unittest.TestCase): self.assertEqual(check_resource_availability(test_dataset, user_id), "SUPERUSER") - @mock.patch('utility.authentication_tools.webqtlConfig.DEFAULT_PRIVILEGES', + @mock.patch('gn2.utility.authentication_tools.webqtlConfig.DEFAULT_PRIVILEGES', "John Doe") def test_check_resource_availability_string_dataset(self): """Test the resource availability if the dataset is a string""" self.assertEqual(check_resource_availability("Test", user_id), "John Doe") - @mock.patch('utility.authentication_tools.webqtlConfig.DEFAULT_PRIVILEGES', + @mock.patch('gn2.utility.authentication_tools.webqtlConfig.DEFAULT_PRIVILEGES', "John Doe") def test_check_resource_availability_temp(self): """Test the resource availability if the dataset is a string""" @@ -119,10 +119,10 @@ class TestCheckResourceAvailability(unittest.TestCase): class TestAddNewResource(unittest.TestCase): """Test cases for add_new_resource method""" - @mock.patch('utility.authentication_tools.webqtlConfig.DEFAULT_PRIVILEGES', + @mock.patch('gn2.utility.authentication_tools.webqtlConfig.DEFAULT_PRIVILEGES', "John Doe") - @mock.patch('utility.authentication_tools.add_resource', mock_add_resource) - @mock.patch('utility.authentication_tools.get_group_code') + @mock.patch('gn2.utility.authentication_tools.add_resource', mock_add_resource) + @mock.patch('gn2.utility.authentication_tools.get_group_code') def test_add_new_resource_if_publish_datatype(self, group_code_mock): """Test add_new_resource if dataset type is 'publish'""" group_code_mock.return_value = "Test" @@ -143,10 +143,10 @@ class TestAddNewResource(unittest.TestCase): self.assertEqual(add_new_resource(test_dataset), expected_value) - @mock.patch('utility.authentication_tools.webqtlConfig.DEFAULT_PRIVILEGES', + @mock.patch('gn2.utility.authentication_tools.webqtlConfig.DEFAULT_PRIVILEGES', "John Doe") - @mock.patch('utility.authentication_tools.add_resource', mock_add_resource) - @mock.patch('utility.authentication_tools.get_group_code') + @mock.patch('gn2.utility.authentication_tools.add_resource', mock_add_resource) + @mock.patch('gn2.utility.authentication_tools.get_group_code') def test_add_new_resource_if_geno_datatype(self, group_code_mock): """Test add_new_resource if dataset type is 'geno'""" group_code_mock.return_value = "Test" @@ -167,10 +167,10 @@ class TestAddNewResource(unittest.TestCase): self.assertEqual(add_new_resource(test_dataset), expected_value) - @mock.patch('utility.authentication_tools.webqtlConfig.DEFAULT_PRIVILEGES', + @mock.patch('gn2.utility.authentication_tools.webqtlConfig.DEFAULT_PRIVILEGES', "John Doe") - @mock.patch('utility.authentication_tools.add_resource', mock_add_resource) - @mock.patch('utility.authentication_tools.get_group_code') + @mock.patch('gn2.utility.authentication_tools.add_resource', mock_add_resource) + @mock.patch('gn2.utility.authentication_tools.get_group_code') def test_add_new_resource_if_other_datatype(self, group_code_mock): """Test add_new_resource if dataset type is not 'geno' or 'publish'""" group_code_mock.return_value = "Test" diff --git a/gn2/tests/unit/utility/test_hmac.py b/gn2/tests/unit/utility/test_hmac.py index 2b428588..f148ea5b 100644 --- a/gn2/tests/unit/utility/test_hmac.py +++ b/gn2/tests/unit/utility/test_hmac.py @@ -11,12 +11,12 @@ from gn2.utility.hmac import hmac_creation class TestHmacUtil(unittest.TestCase): """Test Utility method for hmac creation""" - @mock.patch("utility.hmac.app.config", {'SECRET_HMAC_CODE': "secret"}) + @mock.patch("gn2.utility.hmac.app.config", {'SECRET_HMAC_CODE': "secret"}) def test_hmac_creation(self): """Test hmac creation with a utf-8 string""" self.assertEqual(hmac_creation("ファイ"), "7410466338cfe109e946") - @mock.patch("utility.hmac.app.config", + @mock.patch("gn2.utility.hmac.app.config", {'SECRET_HMAC_CODE': ('\x08\xdf\xfa\x93N\x80' '\xd9\\H@\\\x9f`\x98d^' '\xb4a;\xc6OM\x946a\xbc' @@ -29,21 +29,21 @@ class TestHmacUtil(unittest.TestCase): hmac_creation(uuid_), "af4fcf5eace9e7c864ce") - @mock.patch("utility.hmac.app.config", {'SECRET_HMAC_CODE': "secret"}) + @mock.patch("gn2.utility.hmac.app.config", {'SECRET_HMAC_CODE': "secret"}) def test_data_hmac(self): """Test data_hmac fn with a utf-8 string""" self.assertEqual(data_hmac("ファイ"), "ファイ:7410466338cfe109e946") - @mock.patch("utility.hmac.app.config", {'SECRET_HMAC_CODE': "secret"}) - @mock.patch("utility.hmac.url_for") + @mock.patch("gn2.utility.hmac.app.config", {'SECRET_HMAC_CODE': "secret"}) + @mock.patch("gn2.utility.hmac.url_for") def test_url_for_hmac_with_plain_url(self, mock_url): """Test url_for_hmac without params""" mock_url.return_value = "https://mock_url.com/ファイ/" self.assertEqual(url_for_hmac("ファイ"), "https://mock_url.com/ファイ/?hm=05bc39e659b1948f41e7") - @mock.patch("utility.hmac.app.config", {'SECRET_HMAC_CODE': "secret"}) - @mock.patch("utility.hmac.url_for") + @mock.patch("gn2.utility.hmac.app.config", {'SECRET_HMAC_CODE': "secret"}) + @mock.patch("gn2.utility.hmac.url_for") def test_url_for_hmac_with_param_in_url(self, mock_url): """Test url_for_hmac with params""" mock_url.return_value = "https://mock_url.com/?ファイ=1" |