From 6f0fce05aa06eebd2a5e910c3b044904f7d0a1e8 Mon Sep 17 00:00:00 2001 From: Yuming Zhu Date: Apr 16 2018 05:39:06 +0000 Subject: [PATCH 1/2] pass full buildinfo obtained by get_build to postBuildStateChange callbacks relates #725 --- diff --git a/hub/kojihub.py b/hub/kojihub.py index cd46fda..e70a860 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -4910,7 +4910,8 @@ def new_build(data): data['id'] = insert_data['id'] = _singleValue("SELECT nextval('build_id_seq')") insert = InsertProcessor('build', data=insert_data) insert.execute() - koji.plugin.run_callbacks('postBuildStateChange', attribute='state', old=None, new=data['state'], info=data) + new_binfo = get_build(data['id'], strict=True) + koji.plugin.run_callbacks('postBuildStateChange', attribute='state', old=None, new=data['state'], info=new_binfo) #return build_id return data['id'] @@ -4974,8 +4975,9 @@ def recycle_build(old, data): builddir = koji.pathinfo.build(data) if os.path.exists(builddir): koji.util.rmtree(builddir) + buildinfo = get_build(data['id'], strict=True) koji.plugin.run_callbacks('postBuildStateChange', attribute='state', - old=old['state'], new=data['state'], info=data) + old=old['state'], new=data['state'], info=buildinfo) def check_noarch_rpms(basepath, rpms): From a372691b1aff981422abdd10625aa35cdd7dcede Mon Sep 17 00:00:00 2001 From: Yuming Zhu Date: Apr 16 2018 05:58:02 +0000 Subject: [PATCH 2/2] ut: fix test_import_build --- diff --git a/tests/test_hub/test_import_build.py b/tests/test_hub/test_import_build.py index a0d1e56..03ca6fe 100644 --- a/tests/test_hub/test_import_build.py +++ b/tests/test_hub/test_import_build.py @@ -242,8 +242,9 @@ class TestImportBuild(unittest.TestCase): 'id': 12345, } # get_build called once to check for existing, - # then later to get the build info - get_build.side_effect = [None, binfo] + # if it doesn't exist, called another time after creating + # then 3rd later to get the build info + get_build.side_effect = [None, binfo, binfo] kojihub.import_build(self.src_filename, [self.filename])