From f1f74e256cde220f04c41d6c86460d64cd3026b2 Mon Sep 17 00:00:00 2001 From: Dominik Rumian Date: Sep 15 2021 10:10:03 +0000 Subject: Fixes import fail with sources already imported Fixes: #573 JIRA: RHELCMP-6481 Signed-off-by: Dominik Rumian --- diff --git a/pyrpkg/cli.py b/pyrpkg/cli.py index 6aa8f27..fafada6 100644 --- a/pyrpkg/cli.py +++ b/pyrpkg/cli.py @@ -2144,7 +2144,10 @@ class cliClient(object): def import_srpm(self): uploadfiles = self.cmd.import_srpm(self.args.srpm) if uploadfiles: - self.cmd.upload(uploadfiles, replace=True, offline=self.args.offline) + try: + self.cmd.upload(uploadfiles, replace=True, offline=self.args.offline) + except AlreadyUploadedError: + self.log.info("All sources were already uploaded.") if not self.args.skip_diffs: self.cmd.diff(cached=True) self.log.info('--------------------------------------------') diff --git a/tests/test_cli.py b/tests/test_cli.py index 887917c..90c2067 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1531,11 +1531,7 @@ class TestImportSrpm(LookasideCacheMock, CliTestCase): def test_import(self): self.assert_import_srpm(self.chaos_repo) - # Exception is not a functionality issue. There is no problem with - # uploading same file twice in a test however, the upload method checks - # if file has been already uploaded. - six.assertRaisesRegex(self, AlreadyUploadedError, r'File already uploaded', - self.assert_import_srpm, self.cloned_repo_path) + self.assert_import_srpm(self.cloned_repo_path) def test_import_gating_and_rpmlintrc_exception(self): # Add three additional files to the repo. Former gating.yaml and package.rpmlintrc are