diff --git a/tests/test_hub/test_add_group_member.py b/tests/test_hub/test_add_group_member.py index 29253335..3dcb20bb 100644 --- a/tests/test_hub/test_add_group_member.py +++ b/tests/test_hub/test_add_group_member.py @@ -12,6 +12,9 @@ class TestAddGroupMember(unittest.TestCase): self.exports = kojihub.RootExports() self.get_user = mock.patch('kojihub.kojihub.get_user').start() + def tearDown(self): + mock.patch.stopall() + def test_non_exist_user(self): data = [{'id': 3, 'name': 'test-group', diff --git a/tests/test_hub/test_add_volume.py b/tests/test_hub/test_add_volume.py index de9023a6..d92b08a9 100644 --- a/tests/test_hub/test_add_volume.py +++ b/tests/test_hub/test_add_volume.py @@ -19,6 +19,9 @@ class TestAddVolume(unittest.TestCase): self.context.session.assertPerm = mock.MagicMock() self.context.session.assertLogin = mock.MagicMock() + def tearDown(self): + mock.patch.stopall() + def test_add_volume_wrong_format(self): volume_name = 'volume-name+' diff --git a/tests/test_hub/test_create_image_build.py b/tests/test_hub/test_create_image_build.py index 2b881e13..864283ae 100644 --- a/tests/test_hub/test_create_image_build.py +++ b/tests/test_hub/test_create_image_build.py @@ -18,6 +18,9 @@ class TestCreateImageBuild(unittest.TestCase): self.inserts = [] self.insert_execute = mock.MagicMock() + def tearDown(self): + mock.patch.stopall() + def getInsert(self, *args, **kwargs): insert = IP(*args, **kwargs) insert.execute = self.insert_execute diff --git a/tests/test_hub/test_create_maven_build.py b/tests/test_hub/test_create_maven_build.py index 8f13d433..53aa9fad 100644 --- a/tests/test_hub/test_create_maven_build.py +++ b/tests/test_hub/test_create_maven_build.py @@ -32,6 +32,9 @@ class TestCreateMavenBuild(unittest.TestCase): } self.build_info = 'test-build-11-12' + def tearDown(self): + mock.patch.stopall() + def getInsert(self, *args, **kwargs): insert = IP(*args, **kwargs) insert.execute = self.insert_execute diff --git a/tests/test_hub/test_create_user.py b/tests/test_hub/test_create_user.py index 3f0dc059..00cf2212 100644 --- a/tests/test_hub/test_create_user.py +++ b/tests/test_hub/test_create_user.py @@ -24,6 +24,9 @@ class TestCreateUser(unittest.TestCase): self.user_info_krb = {'id': 1, 'krb_principals': ['test_user@fedora.org'], 'name': self.user_name, 'status': 0, 'usertype': 0} + def tearDown(self): + mock.patch.stopall() + def test_create_user_wrong_format(self): user_name = 'test-user+' diff --git a/tests/test_hub/test_create_win_build.py b/tests/test_hub/test_create_win_build.py index d714da6d..3d2bbefc 100644 --- a/tests/test_hub/test_create_win_build.py +++ b/tests/test_hub/test_create_win_build.py @@ -32,6 +32,9 @@ class TestCreateWinBuild(unittest.TestCase): } self.build_info = 'test-build-11-12' + def tearDown(self): + mock.patch.stopall() + def getInsert(self, *args, **kwargs): insert = IP(*args, **kwargs) insert.execute = self.insert_execute diff --git a/tests/test_hub/test_delete_build_target.py b/tests/test_hub/test_delete_build_target.py index c90a68bc..9b5c2277 100644 --- a/tests/test_hub/test_delete_build_target.py +++ b/tests/test_hub/test_delete_build_target.py @@ -28,6 +28,9 @@ class TestDeleteBuildTarget(unittest.TestCase): # start with "assert" self.context_db.session.assertLogin = mock.MagicMock() + def tearDown(self): + mock.patch.stopall() + def test_non_exist_target(self): build_target = 'build-target' self.lookup_build_target.return_value = None diff --git a/tests/test_hub/test_disable_channel.py b/tests/test_hub/test_disable_channel.py index 8aa35ce9..fcb4595d 100644 --- a/tests/test_hub/test_disable_channel.py +++ b/tests/test_hub/test_disable_channel.py @@ -24,6 +24,9 @@ class TestDisableChannel(unittest.TestCase): self.updates = [] self.channelname = 'test-channel' + def tearDown(self): + mock.patch.stopall() + def test_non_exist_channel(self): self.get_channel.return_value = None with self.assertRaises(koji.GenericError) as cm: diff --git a/tests/test_hub/test_disable_user.py b/tests/test_hub/test_disable_user.py index 4ee6574d..94cb3a14 100644 --- a/tests/test_hub/test_disable_user.py +++ b/tests/test_hub/test_disable_user.py @@ -12,6 +12,9 @@ class TestDisableUser(unittest.TestCase): self.exports = kojihub.RootExports() self.get_user = mock.patch('kojihub.kojihub.get_user').start() + def tearDown(self): + mock.patch.stopall() + def test_non_exist_user(self): username = 'test-user' self.get_user.return_value = None diff --git a/tests/test_hub/test_edit_permission.py b/tests/test_hub/test_edit_permission.py index 59c45c37..7a349a8d 100644 --- a/tests/test_hub/test_edit_permission.py +++ b/tests/test_hub/test_edit_permission.py @@ -24,6 +24,9 @@ class TestEditPermission(unittest.TestCase): self.perm_info = {'id': 1, 'name': self.perm_name} self.description = 'test-description' + def tearDown(self): + mock.patch.stopall() + def test_edit_permission_non_exist_permission(self): self.lookup_perm.side_effect = koji.GenericError with self.assertRaises(koji.GenericError): diff --git a/tests/test_hub/test_enable_channel.py b/tests/test_hub/test_enable_channel.py index 0fd12dd4..183cb2ef 100644 --- a/tests/test_hub/test_enable_channel.py +++ b/tests/test_hub/test_enable_channel.py @@ -24,6 +24,9 @@ class TestEnableChannel(unittest.TestCase): self.updates = [] self.channelname = 'test-channel' + def tearDown(self): + mock.patch.stopall() + def test_non_exist_channel(self): self.get_channel.return_value = None diff --git a/tests/test_hub/test_enable_user.py b/tests/test_hub/test_enable_user.py index 42bbd51e..739a9d8c 100644 --- a/tests/test_hub/test_enable_user.py +++ b/tests/test_hub/test_enable_user.py @@ -12,6 +12,9 @@ class TestEnableUser(unittest.TestCase): self.exports = kojihub.RootExports() self.get_user = mock.patch('kojihub.kojihub.get_user').start() + def tearDown(self): + mock.patch.stopall() + def test_non_exist_user(self): username = 'test-user' self.get_user.return_value = None diff --git a/tests/test_hub/test_find_build_id.py b/tests/test_hub/test_find_build_id.py index 0c2f6592..857985db 100644 --- a/tests/test_hub/test_find_build_id.py +++ b/tests/test_hub/test_find_build_id.py @@ -24,6 +24,9 @@ class TestFindBuildId(unittest.TestCase): self.queries = [] self.query_singleValue = mock.MagicMock() + def tearDown(self): + mock.patch.stopall() + def test_non_exist_build_dict(self): build = { 'name': 'test_name', diff --git a/tests/test_hub/test_getRPMDeps.py b/tests/test_hub/test_getRPMDeps.py index ca1f3179..53c50d5b 100644 --- a/tests/test_hub/test_getRPMDeps.py +++ b/tests/test_hub/test_getRPMDeps.py @@ -11,6 +11,9 @@ class TestGetRPMDeps(unittest.TestCase): self.get_rpm = mock.patch('kojihub.kojihub.get_rpm').start() self.get_build = mock.patch('kojihub.kojihub.get_build').start() + def tearDown(self): + mock.patch.stopall() + def test_getRPMDeps_no_rpminfo(self): def mock_get_rpm(rpmID, strict=False): if strict: diff --git a/tests/test_hub/test_get_build_notifications.py b/tests/test_hub/test_get_build_notifications.py index f8d023d5..ce201269 100644 --- a/tests/test_hub/test_get_build_notifications.py +++ b/tests/test_hub/test_get_build_notifications.py @@ -10,6 +10,9 @@ class TestGetBuildNotifications(unittest.TestCase): self.get_user = mock.patch('kojihub.kojihub.get_user').start() self.get_build_notifications = mock.patch('kojihub.kojihub.get_build_notifications').start() + def tearDown(self): + mock.patch.stopall() + def test_loggedin_user(self): self.get_user.return_value = {'id': 1} kojihub.RootExports().getBuildNotifications(None) diff --git a/tests/test_hub/test_get_buildroot.py b/tests/test_hub/test_get_buildroot.py index 7fd22f0d..5fd85191 100644 --- a/tests/test_hub/test_get_buildroot.py +++ b/tests/test_hub/test_get_buildroot.py @@ -10,6 +10,9 @@ class TestGetBuildroot(unittest.TestCase): self.query_buildroots = mock.patch('kojihub.kojihub.query_buildroots').start() self.buildroot_id = 1 + def tearDown(self): + mock.patch.stopall() + def test_empty_buildroots_without_strict(self): self.query_buildroots.return_value = [] rv = kojihub.get_buildroot(self.buildroot_id, strict=False) diff --git a/tests/test_hub/test_get_changelog_entries.py b/tests/test_hub/test_get_changelog_entries.py index d00aa178..0619e0a6 100644 --- a/tests/test_hub/test_get_changelog_entries.py +++ b/tests/test_hub/test_get_changelog_entries.py @@ -17,6 +17,9 @@ class TestGetChangelogEntries(unittest.TestCase): self.cursor = mock.MagicMock() self.os_path_exists = mock.patch('os.path.exists').start() + def tearDown(self): + mock.patch.stopall() + def test_non_exist_build(self): build_id = 1 self.cursor.fetchone.return_value = None diff --git a/tests/test_hub/test_get_external_repo.py b/tests/test_hub/test_get_external_repo.py index b71070cd..5b63edc3 100644 --- a/tests/test_hub/test_get_external_repo.py +++ b/tests/test_hub/test_get_external_repo.py @@ -12,6 +12,9 @@ class TestGetExternalRepo(unittest.TestCase): self.get_external_repos = mock.patch('kojihub.kojihub.get_external_repos').start() self.exports = kojihub.RootExports() + def tearDown(self): + mock.patch.stopall() + def test_non_exist_repo_with_strict(self): repo = 'test-repo' self.get_external_repos.return_value = [] diff --git a/tests/test_hub/test_get_next_release.py b/tests/test_hub/test_get_next_release.py index 457e1796..f199723c 100644 --- a/tests/test_hub/test_get_next_release.py +++ b/tests/test_hub/test_get_next_release.py @@ -12,6 +12,9 @@ class TestGetNextRelease(DBQueryTestCase): self.get_build = mock.patch('kojihub.kojihub.get_build').start() self.binfo = {'name': 'name', 'version': 'version'} + def tearDown(self): + mock.patch.stopall() + def test_get_next_release_new(self): # no previous build self.qp_execute_one_return_value = None diff --git a/tests/test_hub/test_get_user.py b/tests/test_hub/test_get_user.py index 51bcf2e0..ba040356 100644 --- a/tests/test_hub/test_get_user.py +++ b/tests/test_hub/test_get_user.py @@ -15,6 +15,9 @@ class TestGetUser(DBQueryTestCase): self.list_user_krb_principals = mock.patch( 'kojihub.kojihub.list_user_krb_principals').start() + def tearDown(self): + mock.patch.stopall() + def test_wrong_format_user_info(self): userinfo = ['test-user'] with self.assertRaises(koji.GenericError) as cm: diff --git a/tests/test_hub/test_get_volume.py b/tests/test_hub/test_get_volume.py index 3c17b1e7..24a03b63 100644 --- a/tests/test_hub/test_get_volume.py +++ b/tests/test_hub/test_get_volume.py @@ -11,6 +11,9 @@ class TestGetVolume(unittest.TestCase): self.exports = kojihub.RootExports() self.lookup_name = mock.patch('kojihub.kojihub.lookup_name').start() + def tearDown(self): + mock.patch.stopall() + def test_non_exist_volume_with_strict(self): volume = ['test-volume'] self.lookup_name.return_value = None diff --git a/tests/test_hub/test_grant_permissions.py b/tests/test_hub/test_grant_permissions.py index 07afb977..c79f882c 100644 --- a/tests/test_hub/test_grant_permissions.py +++ b/tests/test_hub/test_grant_permissions.py @@ -32,6 +32,9 @@ class TestGrantPermission(unittest.TestCase): 'status': 0, 'usertype': 0} self.perm_info = {'id': 1, 'name': self.perms_name} + def tearDown(self): + mock.patch.stopall() + def test_grant_permission_wrong_format(self): perms_name = 'test-perms+' diff --git a/tests/test_hub/test_group_pkg_operations.py b/tests/test_hub/test_group_pkg_operations.py index 42a56d49..23045207 100644 --- a/tests/test_hub/test_group_pkg_operations.py +++ b/tests/test_hub/test_group_pkg_operations.py @@ -61,6 +61,9 @@ class TestGroupPkglist(unittest.TestCase): self.context_db.event_id = 42 self.context_db.session.user_id = 24 + def tearDown(self): + mock.patch.stopall() + def test_grp_pkg_add_previous_changed(self): self.lookup_tag.return_value = self.taginfo self.lookup_group.return_value = self.groupinfo diff --git a/tests/test_hub/test_group_req_operations.py b/tests/test_hub/test_group_req_operations.py index 52251c5f..dadf6e5e 100644 --- a/tests/test_hub/test_group_req_operations.py +++ b/tests/test_hub/test_group_req_operations.py @@ -61,6 +61,9 @@ class TestGroupReqlist(unittest.TestCase): self.context_db.event_id = 42 self.context_db.session.user_id = 24 + def tearDown(self): + mock.patch.stopall() + def test_grp_req_add_not_previous(self): self.lookup_tag.return_value = self.taginfo self.lookup_group.side_effect = [self.groupinfo, self.reqinfo] diff --git a/tests/test_hub/test_import_image_internal.py b/tests/test_hub/test_import_image_internal.py index a12d31e9..435cb814 100644 --- a/tests/test_hub/test_import_image_internal.py +++ b/tests/test_hub/test_import_image_internal.py @@ -22,6 +22,7 @@ class TestImportImageInternal(unittest.TestCase): def tearDown(self): shutil.rmtree(self.tempdir) + mock.patch.stopall() def test_basic(self): task = mock.MagicMock() diff --git a/tests/test_hub/test_list_builds.py b/tests/test_hub/test_list_builds.py index 239a1dc7..9456147f 100644 --- a/tests/test_hub/test_list_builds.py +++ b/tests/test_hub/test_list_builds.py @@ -86,6 +86,9 @@ class TestListBuilds(unittest.TestCase): 'volume_name': 'DEFAULT', 'draft': False},] + def tearDown(self): + mock.patch.stopall() + def test_wrong_package(self): package = 'test-package' self.get_package_id.return_value = None diff --git a/tests/test_hub/test_list_tagged.py b/tests/test_hub/test_list_tagged.py index 6cde73a9..3990d69c 100644 --- a/tests/test_hub/test_list_tagged.py +++ b/tests/test_hub/test_list_tagged.py @@ -27,6 +27,9 @@ class TestListTagged(unittest.TestCase): 'release': '1.fc35', 'state': 1, 'tag_id': 1, 'tag_name': 'test-tag', 'task_id': None, 'version': '2.52', 'volume_id': 0, 'volume_name': 'DEFAULT'}] + def tearDown(self): + mock.patch.stopall() + def getQuery(self, *args, **kwargs): query = QP(*args, **kwargs) query.execute = mock.MagicMock() diff --git a/tests/test_hub/test_list_tagged_archives.py b/tests/test_hub/test_list_tagged_archives.py index 67c092c8..2ccd469e 100644 --- a/tests/test_hub/test_list_tagged_archives.py +++ b/tests/test_hub/test_list_tagged_archives.py @@ -48,6 +48,9 @@ class TestListTaggedArchives(unittest.TestCase): 'volume_name': 'DEFAULT'}] ] + def tearDown(self): + mock.patch.stopall() + def getQuery(self, *args, **kwargs): query = QP(*args, **kwargs) query.execute = mock.MagicMock() diff --git a/tests/test_hub/test_list_tagged_rpms.py b/tests/test_hub/test_list_tagged_rpms.py index 4a0e2e46..c93cc6aa 100644 --- a/tests/test_hub/test_list_tagged_rpms.py +++ b/tests/test_hub/test_list_tagged_rpms.py @@ -47,6 +47,9 @@ class TestListTaggedRPMS(unittest.TestCase): 'volume_name': 'DEFAULT'}] ] + def tearDown(self): + mock.patch.stopall() + def getQuery(self, *args, **kwargs): query = QP(*args, **kwargs) query.execute = mock.MagicMock() diff --git a/tests/test_hub/test_multicall.py b/tests/test_hub/test_multicall.py index 5a9881a5..3280b19f 100644 --- a/tests/test_hub/test_multicall.py +++ b/tests/test_hub/test_multicall.py @@ -15,6 +15,9 @@ class DummyExports(object): class TestMulticall(unittest.TestCase): + def tearDown(self): + mock.patch.stopall() + def test_multicall(self): self.context_db = mock.patch('kojihub.db.context').start() kojixmlrpc.kojihub = mock.MagicMock() diff --git a/tests/test_hub/test_new_maven_build.py b/tests/test_hub/test_new_maven_build.py index d84e4fe4..f1636e86 100644 --- a/tests/test_hub/test_new_maven_build.py +++ b/tests/test_hub/test_new_maven_build.py @@ -26,6 +26,9 @@ class TestNewMavenBuild(unittest.TestCase): 'build_id': 2, } + def tearDown(self): + mock.patch.stopall() + def getInsert(self, *args, **kwargs): insert = IP(*args, **kwargs) insert.execute = self.insert_execute diff --git a/tests/test_hub/test_new_win_build.py b/tests/test_hub/test_new_win_build.py index f62f9a6c..6813e54e 100644 --- a/tests/test_hub/test_new_win_build.py +++ b/tests/test_hub/test_new_win_build.py @@ -31,6 +31,9 @@ class TestNewWinBuild(unittest.TestCase): 'extra': {'extra_key': 'extra_value'}, } + def tearDown(self): + mock.patch.stopall() + def getInsert(self, *args, **kwargs): insert = IP(*args, **kwargs) insert.execute = self.insert_execute diff --git a/tests/test_hub/test_query_buildroots.py b/tests/test_hub/test_query_buildroots.py index 2257a55a..019970eb 100644 --- a/tests/test_hub/test_query_buildroots.py +++ b/tests/test_hub/test_query_buildroots.py @@ -20,6 +20,9 @@ class TestQueryBuildroots(unittest.TestCase): self.queries = [] self.query_execute = mock.MagicMock() + def tearDown(self): + mock.patch.stopall() + def test_query_buildroots(self): self.query_execute.side_effect = [[7], [7], [7], []] self.repo_references.return_value = [{'id': 7, 'host_id': 1, 'create_event': 333, diff --git a/tests/test_hub/test_query_rpm_sigs.py b/tests/test_hub/test_query_rpm_sigs.py index b993f55f..2e19d741 100644 --- a/tests/test_hub/test_query_rpm_sigs.py +++ b/tests/test_hub/test_query_rpm_sigs.py @@ -35,6 +35,9 @@ class TestQueryRPMSigs(unittest.TestCase): 'size': 25644, 'version': '3.3'} + def tearDown(self): + mock.patch.stopall() + def test_rpm_dict(self): rinfo_dict = { 'arch': 'x86_64', diff --git a/tests/test_hub/test_restart_hosts.py b/tests/test_hub/test_restart_hosts.py index 005309ae..4d0d8b19 100644 --- a/tests/test_hub/test_restart_hosts.py +++ b/tests/test_hub/test_restart_hosts.py @@ -14,6 +14,9 @@ class TestRestartHosts(unittest.TestCase): self.context.session.assertPerm = mock.MagicMock() self.make_task = mock.patch('kojihub.kojihub.make_task').start() + def tearDown(self): + mock.patch.stopall() + def test_options_is_none(self): self.make_task.return_value = 13 rv = self.exports.restartHosts() diff --git a/tests/test_hub/test_set_user_status.py b/tests/test_hub/test_set_user_status.py index 3455d551..e4988340 100644 --- a/tests/test_hub/test_set_user_status.py +++ b/tests/test_hub/test_set_user_status.py @@ -23,6 +23,9 @@ class TestSetUserStatus(unittest.TestCase): self.context.session.assertPerm = mock.MagicMock() self.update_execute = mock.MagicMock() + def tearDown(self): + mock.patch.stopall() + def test_wrong_status(self): status = 111 with self.assertRaises(koji.GenericError) as cm: diff --git a/tests/test_hub/test_verify_names.py b/tests/test_hub/test_verify_names.py index 91901ad8..c36e4c58 100644 --- a/tests/test_hub/test_verify_names.py +++ b/tests/test_hub/test_verify_names.py @@ -15,6 +15,9 @@ class TestVerifyNameInternal(unittest.TestCase): self.context.opts = {'MaxNameLengthInternal': 15, 'RegexNameInternal.compiled': re.compile('^[A-Za-z0-9/_.+-]+$')} + def tearDown(self): + mock.patch.stopall() + def test_verify_name_internal_integer_type(self): expected_error = "Name should be string" with self.assertRaises(koji.GenericError) as cm: diff --git a/tests/test_hub/utils.py b/tests/test_hub/utils.py index f2e05c32..561e70a7 100644 --- a/tests/test_hub/utils.py +++ b/tests/test_hub/utils.py @@ -28,7 +28,6 @@ def get_qp_init(testcase): class DBQueryTestCase(unittest.TestCase): def setUp(self): - mock.patch.stopall() self.qp_execute_return_value = [] self.qp_execute_side_effect = None self.qp_execute_one_return_value = [] @@ -44,7 +43,6 @@ class DBQueryTestCase(unittest.TestCase): def tearDown(self): mock.patch.stopall() - self.reset_query() def reset_query(self): del self.queries[:]