[Patchew-devel] [PATCH] fix test report event, and add test case

Paolo Bonzini posted 1 patch 6 years, 4 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/patchew-ci tags/patchew/20180315104807.16030-1-pbonzini@redhat.com
mods/testing.py       |  2 ++
tests/test_testing.py | 42 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+)
[Patchew-devel] [PATCH] fix test report event, and add test case
Posted by Paolo Bonzini 6 years, 4 months ago
The newly added TesterTest found a problem.  Fix it, and add a lower-level
test case that is easier to debug.
---
 mods/testing.py       |  2 ++
 tests/test_testing.py | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/mods/testing.py b/mods/testing.py
index 322ba37..24bd509 100644
--- a/mods/testing.py
+++ b/mods/testing.py
@@ -111,6 +111,8 @@ class TestingModule(PatchewModule):
                       passed="True if the test is passed",
                       test="test name",
                       log="test log",
+                      log_url="URL to test log (text)",
+                      html_log_url="URL to test log (HTML)",
                       is_timeout="whether the test has timeout")
         register_handler("SetProperty", self.on_set_property)
 
diff --git a/tests/test_testing.py b/tests/test_testing.py
index a68e237..0d7e316 100755
--- a/tests/test_testing.py
+++ b/tests/test_testing.py
@@ -53,6 +53,30 @@ class TestingTest(PatchewTestCase):
         self.msg.set_property("testing.done", True)
         self.msg.set_property("testing.ready", None)
 
+    def msg_testing_report(self, **report):
+        self.api_login()
+        r = self.api_call("testing-get",
+                           project="QEMU",
+                           tester="dummy tester",
+                           capabilities=[])
+        self.assertEquals(r['identity']['type'], 'series')
+
+        report['project'] = r["project"]
+        report['identity'] = r["identity"]
+        report['test'] = r["test"]["name"]
+        report['tester'] = 'dummy_tester'
+        report['head'] = r["head"]
+        report['base'] = r["base"]
+        if not 'passed' in report:
+            report['passed'] = True
+        if not 'log' in report:
+            report['log'] = None
+        if not 'is_timeout' in report:
+            report['is_timeout'] = False
+
+        self.api_call("testing-report", **report)
+        return r['identity']['message-id']
+
     def test_basic(self):
         self.api_login()
         td = self.api_call("testing-get",
@@ -90,6 +114,24 @@ class TestingTest(PatchewTestCase):
         self.assertEquals(log.status_code, 200)
         self.assertEquals(log.content, b'sorry no good')
 
+    def test_api_report_success(self):
+        self.api_login()
+        msgid = self.msg_testing_report(log='everything good!', passed=True)
+        resp = self.api_client.get(self.PROJECT_BASE + 'series/' + self.msg.message_id + '/')
+        self.assertEquals(resp.data['results']['testing.a']['status'], 'success')
+        log = self.client.get(resp.data['results']['testing.a']['log_url'])
+        self.assertEquals(log.status_code, 200)
+        self.assertEquals(log.content, b'everything good!')
+
+    def test_api_report_failure(self):
+        self.api_login()
+        msgid = self.msg_testing_report(log='sorry no good', passed=False)
+        resp = self.api_client.get(self.PROJECT_BASE + 'series/' + self.msg.message_id + '/')
+        self.assertEquals(resp.data['results']['testing.a']['status'], 'failure')
+        log = self.client.get(resp.data['results']['testing.a']['log_url'])
+        self.assertEquals(log.status_code, 200)
+        self.assertEquals(log.content, b'sorry no good')
+
 class TesterTest(PatchewTestCase):
 
     def setUp(self):
-- 
2.14.3

_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel