This will ensure that a PUT of a result will also set the properties, and not
just the testing-report API.
The HEAD that was used for testing is now stored in the result, which is a
good idea anyway. This requires a small change in the tests.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
mods/testing.py | 15 ++++++++++-----
tests/test_testing.py | 7 ++++++-
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/mods/testing.py b/mods/testing.py
index ccdd336..0266fb9 100644
--- a/mods/testing.py
+++ b/mods/testing.py
@@ -123,6 +123,15 @@ class TestingModule(PatchewModule):
self.recalc_pending_tests(obj)
def on_result_update(self, evt, obj, old_status, result):
+ if result.name.startswith("testing.") and result.status != old_status:
+ if 'tester' in result.data:
+ po = obj if isinstance(obj, Project) else obj.project
+ _instance.tester_check_in(po, result.data['tester'])
+ if not self.get_testing_results(obj,
+ status__in=(Result.PENDING, Result.RUNNING)).exists():
+ obj.set_property("testing.done", True)
+ obj.set_property("testing.tested-head", result.data["head"])
+
if result.name != "git":
return
if isinstance(obj, Message) \
@@ -230,14 +239,11 @@ class TestingModule(PatchewModule):
r = self.get_testing_result(obj, test)
r.data = {"is_timeout": is_timeout,
"user": user.username,
+ "head": head,
"tester": tester or user.username}
r.log = log
r.status = Result.SUCCESS if passed else Result.FAILURE
r.save()
- if not self.get_testing_results(obj,
- status__in=(Result.PENDING, Result.RUNNING)).exists():
- obj.set_property("testing.done", True)
- obj.set_property("testing.tested-head", head)
log_url = self.reverse_testing_log(obj, test, request=request)
html_log_url = self.reverse_testing_log(obj, test, request=request, html=True)
@@ -476,7 +482,6 @@ class TestingReportView(APILoginRequiredView):
def handle(self, request, tester, project, test,
head, base, passed, log, identity,
is_timeout=False):
- _instance.tester_check_in(project, tester or request.user.username)
_instance.add_test_report(request, project, tester,
test, head, base, identity, passed, log,
is_timeout)
diff --git a/tests/test_testing.py b/tests/test_testing.py
index 93aaf8b..c9452a4 100755
--- a/tests/test_testing.py
+++ b/tests/test_testing.py
@@ -38,9 +38,14 @@ class TestingTestCase(PatchewTestCase, metaclass=abc.ABCMeta):
r = obj.results.get(name='testing.a')
except:
r = obj.create_result(name='testing.a')
- if not 'status' in kwargs:
+ if 'status' not in kwargs:
kwargs['status'] = Result.PENDING
+ if kwargs['status'] == Result.SUCCESS or kwargs['status'] == Result.FAILURE:
+ if 'data' not in kwargs:
+ kwargs['data'] = {}
+ if 'head' not in kwargs['data']:
+ kwargs['data']['head'] = '0123456789abcdef'
if len(kwargs):
for k, v in kwargs.items():
setattr(r, k, v)
--
2.17.1
_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel