PR#1633: Fix lookup_name usage + tests

Merges #1633
https://pagure.io/koji/pull-request/1633

Fixes: #1632
https://pagure.io/koji/issue/1632
Wrong dict usage
This commit is contained in:
Tomas Kopecek 2019-08-29 10:24:05 +02:00
commit 0b7c1198dd
3 changed files with 6 additions and 4 deletions

View file

@ -6637,8 +6637,8 @@ def import_archive_internal(filepath, buildinfo, type, typeInfo, buildroot_id=No
btype = lookup_name('btype', type, strict=False)
if btype is None:
raise koji.BuildError('unsupported build type: %s' % type)
if btype not in get_build_type(buildinfo, strict=True):
raise koji.ImportError('Build does not have type %s', btype)
if btype['name'] not in get_build_type(buildinfo, strict=True):
raise koji.ImportError('Build does not have type %s' % btype['name'])
archiveinfo['btype_id'] = btype['id']
# cg extra data

View file

@ -131,7 +131,7 @@ class TestCompleteImageBuild(unittest.TestCase):
if table == 'btype':
return {
'id': 'BTYPEID:%s' % info,
'name': 'BTYPE:%s' % info,
'name': info,
}
else:
raise Exception("Cannot fake call")
@ -189,6 +189,7 @@ class TestCompleteImageBuild(unittest.TestCase):
'source': None,
'state': koji.BUILD_STATES['BUILDING'],
'volume_id': 0,
'extra': {},
}
image_info = {'build_id': buildinfo['id']}
self.get_build.return_value = buildinfo

View file

@ -73,7 +73,7 @@ class TestCompleteMavenBuild(unittest.TestCase):
def my_lookup_name(self, table, info, **kw):
if table == 'btype':
return mock.MagicMock()
return {'name': 'maven', 'id': 1234}
else:
raise Exception("Cannot fake call")
@ -121,6 +121,7 @@ class TestCompleteMavenBuild(unittest.TestCase):
buildinfo['state'] = koji.BUILD_STATES['BUILDING']
buildinfo['volume_id'] = 0
buildinfo['volume_name'] = 'DEFAULT'
buildinfo['extra'] = {}
maven_info = self.maven_data['maven_info'].copy()
maven_info['build_id'] = buildinfo['id']
self.get_build.return_value = buildinfo