diff --git a/tests/test_cli/utils.py b/tests/test_cli/utils.py index 60d3cf66..3694f265 100644 --- a/tests/test_cli/utils.py +++ b/tests/test_cli/utils.py @@ -43,6 +43,8 @@ class CliTestCase(unittest.TestCase): STDOUT = sys.stdout STDERR = sys.stderr + def tearDown(self): + mock.patch.stopall() # # private methods # @@ -129,7 +131,7 @@ class CliTestCase(unittest.TestCase): # check callableObj callable self.__assert_callable(callableObj) - # these arguments are reseverd and used in assert_system_exit + # these arguments are reserved and used in assert_system_exit reserved = [ 'activate_session', 'stdout', 'stderr', 'assert_func', 'exit_code' diff --git a/tests/test_hub/test_add_external_repo_to_tag.py b/tests/test_hub/test_add_external_repo_to_tag.py index b208dfe2..dca2171e 100644 --- a/tests/test_hub/test_add_external_repo_to_tag.py +++ b/tests/test_hub/test_add_external_repo_to_tag.py @@ -9,6 +9,10 @@ class TestAddExternalRepoToTag(unittest.TestCase): def setUp(self): self.tag_name = 'test-tag' + self.context = mock.patch('kojihub.kojihub.context').start() + # It seems MagicMock will not automatically handle attributes that + # start with "assert" + self.context.session.assertPerm = mock.MagicMock() self.get_tag = mock.patch('kojihub.kojihub.get_tag').start() self.get_external_repo = mock.patch('kojihub.kojihub.get_external_repo').start() self.get_tag_external_repos = mock.patch('kojihub.kojihub.get_tag_external_repos').start() diff --git a/tests/test_hub/test_add_group_member.py b/tests/test_hub/test_add_group_member.py index 3dcb20bb..e891d34b 100644 --- a/tests/test_hub/test_add_group_member.py +++ b/tests/test_hub/test_add_group_member.py @@ -10,6 +10,10 @@ class TestAddGroupMember(unittest.TestCase): def setUp(self): self.exports = kojihub.RootExports() + self.context = mock.patch('kojihub.kojihub.context').start() + # It seems MagicMock will not automatically handle attributes that + # start with "assert" + self.context.session.assertPerm = mock.MagicMock() self.get_user = mock.patch('kojihub.kojihub.get_user').start() def tearDown(self): diff --git a/tests/test_hub/test_add_user_krb_principal.py b/tests/test_hub/test_add_user_krb_principal.py index 7d82b8ba..2066ff53 100644 --- a/tests/test_hub/test_add_user_krb_principal.py +++ b/tests/test_hub/test_add_user_krb_principal.py @@ -8,6 +8,10 @@ import copy class TestAddUserKrbPrincipal(unittest.TestCase): def setUp(self): + self.context = mock.patch('kojihub.kojihub.context').start() + # It seems MagicMock will not automatically handle attributes that + # start with "assert" + self.context.session.assertPerm = mock.MagicMock() self.get_user = mock.patch('kojihub.kojihub.get_user').start() self.verify_name_user = mock.patch('kojihub.kojihub.verify_name_user').start() self.get_user_by_krb_principal = mock.patch('kojihub.kojihub.get_user_by_krb_principal').start() diff --git a/tests/test_hub/test_create_image_build.py b/tests/test_hub/test_create_image_build.py index 864283ae..6bd3ecbf 100644 --- a/tests/test_hub/test_create_image_build.py +++ b/tests/test_hub/test_create_image_build.py @@ -13,6 +13,10 @@ class TestCreateImageBuild(unittest.TestCase): def setUp(self): self.get_build = mock.patch('kojihub.kojihub.get_build').start() self.exports = kojihub.RootExports() + self.context = mock.patch('kojihub.kojihub.context').start() + # It seems MagicMock will not automatically handle attributes that + # start with "assert" + self.context.session.assertPerm = mock.MagicMock() self.InsertProcessor = mock.patch('kojihub.kojihub.InsertProcessor', side_effect=self.getInsert).start() self.inserts = [] diff --git a/tests/test_hub/test_delete_build_target.py b/tests/test_hub/test_delete_build_target.py index 9b5c2277..e35348a4 100644 --- a/tests/test_hub/test_delete_build_target.py +++ b/tests/test_hub/test_delete_build_target.py @@ -20,6 +20,10 @@ class TestDeleteBuildTarget(unittest.TestCase): def setUp(self): self.lookup_build_target = mock.patch('kojihub.kojihub.lookup_build_target').start() self.exports = kojihub.RootExports() + self.context = mock.patch('kojihub.kojihub.context').start() + # It seems MagicMock will not automatically handle attributes that + # start with "assert" + self.context.session.assertPerm = mock.MagicMock() self.UpdateProcessor = mock.patch('kojihub.kojihub.UpdateProcessor', side_effect=self.getUpdate).start() self.updates = [] diff --git a/tests/test_hub/test_disable_channel.py b/tests/test_hub/test_disable_channel.py index fcb4595d..e14b7493 100644 --- a/tests/test_hub/test_disable_channel.py +++ b/tests/test_hub/test_disable_channel.py @@ -18,6 +18,10 @@ class TestDisableChannel(unittest.TestCase): def setUp(self): self.exports = kojihub.RootExports() + self.context = mock.patch('kojihub.kojihub.context').start() + # It seems MagicMock will not automatically handle attributes that + # start with "assert" + self.context.session.assertPerm = mock.MagicMock() self.get_channel = mock.patch('kojihub.kojihub.get_channel').start() self.UpdateProcessor = mock.patch('kojihub.kojihub.UpdateProcessor', side_effect=self.getUpdate).start() diff --git a/tests/test_hub/test_enable_channel.py b/tests/test_hub/test_enable_channel.py index 183cb2ef..6b7a0c3f 100644 --- a/tests/test_hub/test_enable_channel.py +++ b/tests/test_hub/test_enable_channel.py @@ -18,6 +18,11 @@ class TestEnableChannel(unittest.TestCase): def setUp(self): self.exports = kojihub.RootExports() + self.context = mock.patch('kojihub.kojihub.context').start() + # It seems MagicMock will not automatically handle attributes that + # start with "assert" + self.context.session.assertPerm = mock.MagicMock() + self.get_channel = mock.patch('kojihub.kojihub.get_channel').start() self.UpdateProcessor = mock.patch('kojihub.kojihub.UpdateProcessor', side_effect=self.getUpdate).start() diff --git a/tests/test_hub/test_get_group_members.py b/tests/test_hub/test_get_group_members.py index e152e66a..0274d00c 100644 --- a/tests/test_hub/test_get_group_members.py +++ b/tests/test_hub/test_get_group_members.py @@ -11,6 +11,10 @@ class TestGetGroupMembers(DBQueryTestCase): super(TestGetGroupMembers, self).setUp() self.get_user = mock.patch('kojihub.kojihub.get_user').start() self.exports = kojihub.RootExports() + self.context = mock.patch('kojihub.kojihub.context').start() + # It seems MagicMock will not automatically handle attributes that + # start with "assert" + self.context.session.assertPerm = mock.MagicMock() def tearDown(self): mock.patch.stopall() diff --git a/tests/test_hub/test_models/test_host.py b/tests/test_hub/test_models/test_host.py index 80daa53a..343f098c 100644 --- a/tests/test_hub/test_models/test_host.py +++ b/tests/test_hub/test_models/test_host.py @@ -132,7 +132,8 @@ class TestHost(unittest.TestCase): ) self.assertEqual(processor.call_args_list[2], update3) - def test_task_wait_check(self): + @mock.patch('kojihub.kojihub.context') + def test_task_wait_check(self, context): self.query_execute.return_value = [{'id': 1, 'state': 1}, {'id': 2, 'state': 2}, {'id': 3, 'state': 3}, diff --git a/tests/test_hub/test_write_signed_rpm.py b/tests/test_hub/test_write_signed_rpm.py index 2e0e431b..1037db16 100644 --- a/tests/test_hub/test_write_signed_rpm.py +++ b/tests/test_hub/test_write_signed_rpm.py @@ -7,6 +7,7 @@ import kojihub class TestWriteSignedRPM(unittest.TestCase): def setUp(self): + self.context = mock.patch('kojihub.kojihub.context').start() self.get_rpm = mock.patch('kojihub.kojihub.get_rpm').start() def tearDown(self):