Rename handler.repos.done argument name "repo_tag" to "tag_name"

This to make it same as the `tag_name` argument in
`handlers.tags.tagged`, so we can handle it easily while inspecting the
function signatures.
This commit is contained in:
Qixiang Wan
2019-12-06 22:56:16 +08:00
committed by mprahl
parent 6febdeb04d
commit d01f911bd1
7 changed files with 17 additions and 17 deletions

View File

@@ -204,7 +204,7 @@ class MBSConsumer(fedmsg.consumers.FedmsgConsumer):
if event == events.KOJI_REPO_CHANGE:
return (
ON_REPO_CHANGE_HANDLER,
models.ModuleBuild.get_by_tag(db_session, event_info["repo_tag"])
models.ModuleBuild.get_by_tag(db_session, event_info["tag_name"])
)
if event == events.KOJI_TAG_CHANGE:

View File

@@ -15,20 +15,20 @@ logging.basicConfig(level=logging.DEBUG)
@celery_app.task
@events.mbs_event_handler()
def done(msg_id, repo_tag):
def done(msg_id, tag_name):
"""Called whenever koji rebuilds a repo, any repo.
:param str msg_id: the original id of the message being handled which is
received from the message bus.
:param str repo_tag: the tag name from which the repo is generated.
:param str tag_name: the tag name from which the repo is generated.
"""
# First, find our ModuleBuild associated with this repo, if any.
if conf.system in ("koji", "test") and not repo_tag.endswith("-build"):
log.debug("Tag %r does not end with '-build' suffix, ignoring", repo_tag)
if conf.system in ("koji", "test") and not tag_name.endswith("-build"):
log.debug("Tag %r does not end with '-build' suffix, ignoring", tag_name)
return
tag = repo_tag[:-6] if repo_tag.endswith("-build") else repo_tag
module_build = models.ModuleBuild.get_by_tag(db_session, repo_tag)
tag = tag_name[:-6] if tag_name.endswith("-build") else tag_name
module_build = models.ModuleBuild.get_by_tag(db_session, tag_name)
if not module_build:
log.debug("No module build found associated with koji tag %r" % tag)
return

View File

@@ -92,7 +92,7 @@ class FedmsgMessageParser(MessageParser):
return {
"msg_id": msg_id,
"event": events.KOJI_REPO_CHANGE,
"repo_tag": msg_inner_msg.get("tag")
"tag_name": msg_inner_msg.get("tag")
}
if event == "tag":

View File

@@ -1825,7 +1825,7 @@ class TestBuild(BaseTestBuild):
events_info = [{
"msg_id": "a faked internal message",
"event": events.KOJI_REPO_CHANGE,
"repo_tag": module.koji_tag + "-build"
"tag_name": module.koji_tag + "-build"
}]
db_session.expire_all()
# Stop after processing the seeded message

View File

@@ -74,4 +74,4 @@ class TestFedmsgMessaging:
parser = FedmsgMessageParser(messaging.known_fedmsg_services)
event_info = parser.parse(buildsys_tag_msg)
assert event_info["repo_tag"] == "module-f0f7e44f3c6cccab-build"
assert event_info["tag_name"] == "module-f0f7e44f3c6cccab-build"

View File

@@ -76,4 +76,4 @@ class TestConsumer:
event_info = process_message.call_args[0][0]
assert event_info["event"] == events.KOJI_REPO_CHANGE
assert event_info["msg_id"] == msg["body"]["msg_id"]
assert event_info["repo_tag"] == msg["body"]["msg"]["tag"]
assert event_info["tag_name"] == msg["body"]["msg"]["tag"]

View File

@@ -21,7 +21,7 @@ class TestRepoDone:
get_by_tag.return_value = None
module_build_service.scheduler.handlers.repos.done(
msg_id="no matches for this...",
repo_tag="2016-some-nonexistent-build")
tag_name="2016-some-nonexistent-build")
@mock.patch(
"module_build_service.builder.KojiModuleBuilder."
@@ -58,7 +58,7 @@ class TestRepoDone:
module_build_service.scheduler.handlers.repos.done(
msg_id="some_msg_id",
repo_tag="module-testmodule-master-20170109091357-7c29193d-build")
tag_name="module-testmodule-master-20170109091357-7c29193d-build")
build_fn.assert_called_once_with(
artifact_name="tangerine",
source=(
@@ -118,7 +118,7 @@ class TestRepoDone:
module_build_service.scheduler.handlers.repos.done(
msg_id="some_msg_id",
repo_tag="module-testmodule-master-20170109091357-7c29193d-build")
tag_name="module-testmodule-master-20170109091357-7c29193d-build")
finalizer.assert_called_once()
@@ -158,7 +158,7 @@ class TestRepoDone:
module_build_service.scheduler.handlers.repos.done(
msg_id="some_msg_id",
repo_tag="module-testmodule-master-20170109091357-7c29193d-build")
tag_name="module-testmodule-master-20170109091357-7c29193d-build")
build_fn.assert_called_once_with(
artifact_name="tangerine",
@@ -185,7 +185,7 @@ class TestRepoDone:
module_build_service.scheduler.handlers.repos.done(
msg_id="some_msg_id",
repo_tag="module-testmodule-master-20170109091357-7c29193d-build")
tag_name="module-testmodule-master-20170109091357-7c29193d-build")
mock_log_info.assert_called_with(
"Ignoring repo regen, because not all components are tagged."
@@ -224,7 +224,7 @@ class TestRepoDone:
module_build_service.scheduler.handlers.repos.done(
msg_id="some_msg_id",
repo_tag="module-testmodule-master-20170109091357-7c29193d-build")
tag_name="module-testmodule-master-20170109091357-7c29193d-build")
module_build = module_build_service.models.ModuleBuild.get_by_id(db_session, 2)
assert module_build.state == module_build_service.models.BUILD_STATES["failed"]