do not raise error when archive is empty
This commit is contained in:
parent
41ccaa8569
commit
02d22df425
2 changed files with 35 additions and 16 deletions
|
|
@ -4293,8 +4293,8 @@ def list_archive_files(archive_id, queryOpts=None, strict=False):
|
|||
size: uncompressed size of the file (integer)
|
||||
|
||||
If strict is True, raise GenericError if:
|
||||
- there are no files found for the archive
|
||||
- the archive is not a type we are able to expand
|
||||
- build btype of this archive belong to is not maven, win or image
|
||||
- archive_type is not that we are able to expand
|
||||
|
||||
Regardless of strict, an error will be raised if the archive_id is invalid
|
||||
"""
|
||||
|
|
@ -4337,9 +4337,6 @@ def list_archive_files(archive_id, queryOpts=None, strict=False):
|
|||
raise koji.GenericError(
|
||||
"Unsupported archive type: %s" % archive_type['name'])
|
||||
filelist = []
|
||||
|
||||
if strict and not filelist:
|
||||
raise koji.GenericError("Archive#%s doesn't contain any files" % archive_id)
|
||||
return _applyQueryOpts(filelist, queryOpts)
|
||||
|
||||
|
||||
|
|
@ -4355,7 +4352,8 @@ def get_archive_file(archive_id, filename, strict=False):
|
|||
|
||||
If strict is True, raise GenericError if:
|
||||
- this file is not found in the archive
|
||||
- the archive is not a type we are able to expand
|
||||
- build btype of this archive belong to is not maven, win or image
|
||||
- archive_type is not that we are able to expand
|
||||
|
||||
Regardless of strict, an error will be raised if the archive_id is invalid
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -42,18 +42,39 @@ class TestListArchiveFiles(unittest.TestCase):
|
|||
self.mm.get_image_build.assert_called_once_with(2)
|
||||
self.assertListEqual(rv, [])
|
||||
|
||||
def test_simple_strict(self):
|
||||
@mock.patch('kojihub.get_maven_archive',
|
||||
return_value={'archive_id': 1,
|
||||
'group_id': 'gid',
|
||||
'artifact_id': 'aid',
|
||||
'version': '1.0.0'})
|
||||
@mock.patch('kojihub._get_zipfile_list', return_value=[])
|
||||
def test_simple_strict_empty(self, get_zipfile_list, get_maven_archive):
|
||||
self.mm.get_maven_build.return_value = {'build_id': 2,
|
||||
'group_id': 'gid',
|
||||
'artifact_id': 'aid',
|
||||
'version': '1.0.0'}
|
||||
rv = kojihub.list_archive_files(1, strict=True)
|
||||
self.assertListEqual(rv, [])
|
||||
|
||||
def test_simple_strict_bad_btype(self):
|
||||
with self.assertRaises(koji.GenericError) as cm:
|
||||
kojihub.list_archive_files(1, strict=True)
|
||||
self.mm.get_archive.assert_called_once_with(1, strict=True)
|
||||
self.mm.get_archive_type.assert_called_once_with(type_id=3,
|
||||
strict=True)
|
||||
self.mm.get_build.assert_called_once_with(2, strict=True)
|
||||
self.mm.get_maven_build.assert_called_once_with(2)
|
||||
self.mm.get_win_build.assert_called_once_with(2)
|
||||
self.mm.get_image_build.assert_called_once_with(2)
|
||||
self.assertEqual(cm.exception.args[0],
|
||||
"Archive#1 doesn't contain any files")
|
||||
self.assertEqual(cm.exception.args[0], "Unsupported build type")
|
||||
|
||||
@mock.patch('kojihub.get_maven_archive',
|
||||
return_value={'archive_id': 1,
|
||||
'group_id': 'gid',
|
||||
'artifact_id': 'aid',
|
||||
'version': '1.0.0'})
|
||||
def test_simple_strict_bad_archive_type(self, get_maven_archive):
|
||||
self.mm.get_archive_type.return_value = {'id': 9, 'name': 'txt'}
|
||||
self.mm.get_maven_build.return_value = {'build_id': 2,
|
||||
'group_id': 'gid',
|
||||
'artifact_id': 'aid',
|
||||
'version': '1.0.0'}
|
||||
with self.assertRaises(koji.GenericError) as cm:
|
||||
kojihub.list_archive_files(1, strict=True)
|
||||
self.assertEqual(cm.exception.args[0], "Unsupported archive type: txt")
|
||||
|
||||
@mock.patch('kojihub.get_maven_archive',
|
||||
return_value={'archive_id': 1,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue