use double quotes instead of escaping
This commit is contained in:
parent
22eea4546b
commit
5bfbe4ae4a
2 changed files with 37 additions and 20 deletions
|
|
@ -4331,7 +4331,7 @@ def list_archive_files(archive_id, queryOpts=None, strict=False):
|
|||
result = _applyQueryOpts(result, queryOpts)
|
||||
|
||||
if strict and not result:
|
||||
raise koji.GenericError('Archive#%s doesn\'t contain any files' % archive_id)
|
||||
raise koji.GenericError("Archive#%s doesn't contain any files" % archive_id)
|
||||
return result
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,23 +1,32 @@
|
|||
import unittest
|
||||
|
||||
import mock
|
||||
|
||||
import koji
|
||||
import kojihub
|
||||
|
||||
GET_ARCHIVE_RV = {'id': 1, 'build_id': 2, 'type_id': 3, 'filename': 'somearchive.zip'}
|
||||
GET_ARCHIVE_RV = {'id': 1, 'build_id': 2, 'type_id': 3,
|
||||
'filename': 'somearchive.zip'}
|
||||
GET_ARCHIVE_TYPE_RV = {'id': 3, 'name': 'zip'}
|
||||
GET_BUILD_RV = {'id': 2, 'name': 'somebuild', 'version': '1.2.3', 'release': '1.el6', 'volume_name': 'archive_vol'}
|
||||
GET_BUILD_RV = {'id': 2, 'name': 'somebuild', 'version': '1.2.3',
|
||||
'release': '1.el6', 'volume_name': 'archive_vol'}
|
||||
|
||||
|
||||
class TestListArchiveFiles(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.mm = mock.MagicMock()
|
||||
self.mm.get_image_build = mock.patch('kojihub.get_image_build', return_value=None).start()
|
||||
self.mm.get_win_build = mock.patch('kojihub.get_win_build', return_value=None).start()
|
||||
self.mm.get_maven_build = mock.patch('kojihub.get_maven_build', return_value=None).start()
|
||||
self.mm.get_build = mock.patch('kojihub.get_build', return_value=GET_BUILD_RV).start()
|
||||
self.mm.get_archive_type = mock.patch('kojihub.get_archive_type', return_value=GET_ARCHIVE_TYPE_RV).start()
|
||||
self.mm.get_archive = mock.patch('kojihub.get_archive', return_value=GET_ARCHIVE_RV).start()
|
||||
self.mm.get_image_build = mock.patch('kojihub.get_image_build',
|
||||
return_value=None).start()
|
||||
self.mm.get_win_build = mock.patch('kojihub.get_win_build',
|
||||
return_value=None).start()
|
||||
self.mm.get_maven_build = mock.patch('kojihub.get_maven_build',
|
||||
return_value=None).start()
|
||||
self.mm.get_build = mock.patch('kojihub.get_build',
|
||||
return_value=GET_BUILD_RV).start()
|
||||
self.mm.get_archive_type = mock.patch('kojihub.get_archive_type',
|
||||
return_value=GET_ARCHIVE_TYPE_RV).start()
|
||||
self.mm.get_archive = mock.patch('kojihub.get_archive',
|
||||
return_value=GET_ARCHIVE_RV).start()
|
||||
|
||||
def tearDown(self):
|
||||
mock.patch.stopall()
|
||||
|
|
@ -25,7 +34,8 @@ class TestListArchiveFiles(unittest.TestCase):
|
|||
def test_simple(self):
|
||||
rv = kojihub.list_archive_files(1)
|
||||
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_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)
|
||||
|
|
@ -36,17 +46,20 @@ class TestListArchiveFiles(unittest.TestCase):
|
|||
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_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],
|
||||
"Archive#1 doesn't contain any files")
|
||||
|
||||
@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_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=[{'archive_id': 1,
|
||||
'name': 'file1',
|
||||
'size': 4096,
|
||||
|
|
@ -66,8 +79,10 @@ class TestListArchiveFiles(unittest.TestCase):
|
|||
get_zipfile_list.assert_called_once_with(1,
|
||||
'/mnt/koji/vol/archive_vol/packages'
|
||||
'/somebuild/1.2.3/1.el6/maven/gid/aid/1.0.0/somearchive.zip')
|
||||
self.assertListEqual(rv, [{'archive_id': 1, 'mtime': 1000, 'name': 'file1', 'size': 4096},
|
||||
{'archive_id': 1, 'mtime': 103420, 'name': 'file2', 'size': 512000}])
|
||||
self.assertListEqual(rv, [
|
||||
{'archive_id': 1, 'mtime': 1000, 'name': 'file1', 'size': 4096},
|
||||
{'archive_id': 1, 'mtime': 103420, 'name': 'file2',
|
||||
'size': 512000}])
|
||||
|
||||
@mock.patch('kojihub.get_win_archive', return_value={'archive_id': 1,
|
||||
'relpath': 'rpath',
|
||||
|
|
@ -90,8 +105,10 @@ class TestListArchiveFiles(unittest.TestCase):
|
|||
get_zipfile_list.assert_called_once_with(1,
|
||||
'/mnt/koji/vol/archive_vol/packages'
|
||||
'/somebuild/1.2.3/1.el6/win/rpath/somearchive.zip')
|
||||
self.assertListEqual(rv, [{'archive_id': 1, 'mtime': 1000, 'name': 'file1', 'size': 4096},
|
||||
{'archive_id': 1, 'mtime': 103420, 'name': 'file2', 'size': 512000}])
|
||||
self.assertListEqual(rv, [
|
||||
{'archive_id': 1, 'mtime': 1000, 'name': 'file1', 'size': 4096},
|
||||
{'archive_id': 1, 'mtime': 103420, 'name': 'file2',
|
||||
'size': 512000}])
|
||||
|
||||
@mock.patch('kojihub.get_image_archive', return_value={'archive_id': 1,
|
||||
'arch': 'noarch'})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue