Not fail when 'ref' is missing

This commit is contained in:
Jakub Kadlčík
2017-03-17 11:29:25 +01:00
parent 9b02605370
commit 95dee6c463
2 changed files with 16 additions and 2 deletions

View File

@@ -767,8 +767,9 @@ def get_reusable_component(session, module, component_name):
# Assumes that the streams have been replaced with commit hashes, so we
# can compare to see if they have changed. Since a build is unique to
# a commit hash, this is a safe test.
if br_module['ref'] != \
old_mmd.xmd['mbs']['buildrequires'][br_module_name]['ref']:
ref1 = br_module.get('ref')
ref2 = old_mmd.xmd['mbs']['buildrequires'][br_module_name].get('ref')
if not (ref1 and ref2) or ref1 != ref2:
return None
# At this point we've determined that both module builds depend(ed) on the

View File

@@ -151,6 +151,19 @@ class TestUtils(unittest.TestCase):
db.session, new_module, 'tangerine')
self.assertEqual(rv.package, 'tangerine')
def test_get_reusable_component_empty_scmurl(self):
test_reuse_component_init_data()
new_module = models.ModuleBuild.query.filter_by(id=2).one()
mmd = new_module.mmd()
mmd.xmd['mbs']['buildrequires'] = {'base-runtime': {}}
new_module.modulemd = mmd.dumps()
db.session.commit()
rv = module_build_service.utils.get_reusable_component(
db.session, new_module, 'tangerine')
self.assertEqual(rv, None)
def test_get_reusable_component_different_perl_tangerine(self):
test_reuse_component_init_data()
second_module_build = models.ModuleBuild.query.filter_by(id=2).one()