Merge branch 'master' into ridad

Also, fix tests.
This commit is contained in:
Ralph Bean
2016-07-27 13:34:32 -04:00
4 changed files with 15 additions and 11 deletions

View File

@@ -5,5 +5,4 @@ fedmsg
modulemd
pyOpenSSL
kobo
koji
munch

View File

@@ -61,7 +61,7 @@ def wait(config, session, msg):
pdc_session = rida.pdc.get_pdc_client_session(config)
tag = rida.pdc.get_module_tag(pdc_session, module_info, strict=True)
log.debug("Found tag=%s for module %r" % (tag, build))
log.info("Found tag=%s for module %r" % (tag, build))
# Hang on to this information for later. We need to know which build is
# associated with which koji tag, so that when their repos are regenerated

View File

@@ -35,15 +35,17 @@ class TestModuleWait(unittest.TestCase):
@mock.patch('rida.builder.KojiModuleBuilder')
@mock.patch('rida.database.ModuleBuild.from_module_event')
@mock.patch('rida.pdc.get_pdc_client_session')
def test_wait_basic(self, pdc, from_module_event, KojiModuleBuilder):
@mock.patch('rida.pdc')
def test_init_basic(self, pdc, from_module_event, KojiModuleBuilder):
builder = mock.Mock()
builder.get_disttag_srpm.return_value = 'some srpm disttag'
KojiModuleBuilder.return_value = builder
mocked_module_build = mock.Mock()
mocked_module_build.json.return_value = {
'name': 'foo',
'version': 1,
'release': 1,
'state': 'some state',
}
from_module_event.return_value = mocked_module_build
@@ -51,6 +53,7 @@ class TestModuleWait(unittest.TestCase):
'topic': 'org.fedoraproject.prod.rida.module.state.change',
'msg': {
'id': 1,
'state': 'some state',
},
}
self.fn(config=self.config, session=self.session, msg=msg)

View File

@@ -37,25 +37,27 @@ class TestRepoDone(unittest.TestCase):
self.session = mock.Mock()
self.fn = rida.scheduler.handlers.repos.done
@mock.patch('rida.database.ModuleBuild.get_active_by_koji_tag')
def test_no_match(self, get_active_by_koji_tag):
@mock.patch('rida.database.ModuleBuild.from_repo_done_event')
def test_no_match(self, from_repo_done_event):
""" Test that when a repo msg hits us and we have no match,
that we do nothing gracefully.
"""
get_active_by_koji_tag.return_value = None
from_repo_done_event.return_value = None
msg = {
'topic': 'org.fedoraproject.prod.buildsys.repo.done',
'msg': {'tag': 'no matches for this...'},
}
self.fn(config=self.config, session=self.session, msg=msg)
@mock.patch('rida.builder.KojiModuleBuilder.get_session_from_config')
@mock.patch('rida.builder.KojiModuleBuilder.build')
@mock.patch('rida.builder.KojiModuleBuilder.buildroot_resume')
@mock.patch('rida.database.ModuleBuild.get_active_by_koji_tag')
def test_a_single_match(self, get_active_by_koji_tag, resume, build_fn):
@mock.patch('rida.database.ModuleBuild.from_repo_done_event')
def test_a_single_match(self, from_repo_done_event, resume, build_fn, config):
""" Test that when a repo msg hits us and we have no match,
that we do nothing gracefully.
"""
config.return_value = mock.Mock(), "development"
component_build = mock.Mock()
component_build.package = 'foo'
component_build.scmurl = 'full_scm_url'
@@ -63,10 +65,10 @@ class TestRepoDone(unittest.TestCase):
module_build = mock.Mock()
module_build.component_builds = [component_build]
get_active_by_koji_tag.return_value = module_build
from_repo_done_event.return_value = module_build
msg = {
'topic': 'org.fedoraproject.prod.buildsys.repo.done',
'msg': {'tag': 'no matches for this...'},
}
self.fn(config=self.config, session=self.session, msg=msg)
build_fn.assert_called_once_with('TODO', 'full_scm_url')
build_fn.assert_called_once_with(artifact_name='foo', source='full_scm_url')