[tor-commits] [ooni-probe/master] Add tests for the oonib reporting API

art at torproject.org art at torproject.org
Thu Feb 6 16:26:02 UTC 2014


commit 064e9ab510901db095433f526536a199bac8ce85
Author: Arturo Filastò <art at fuffa.org>
Date:   Wed Jan 29 21:22:21 2014 +0100

    Add tests for the oonib reporting API
---
 ooni/tests/test_oonibclient.py |   36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/ooni/tests/test_oonibclient.py b/ooni/tests/test_oonibclient.py
index b5957c4..f166ae7 100644
--- a/ooni/tests/test_oonibclient.py
+++ b/ooni/tests/test_oonibclient.py
@@ -111,3 +111,39 @@ class TestOONIBClient(unittest.TestCase):
         for path in ['/bouncer']:
             self.oonibclient.address = 'http://127.0.0.1:8888'
             yield all_requests(path)
+
+    @defer.inlineCallbacks
+    def test_create_report(self):
+        res = yield self.oonibclient.queryBackend('POST', '/report', {
+                'software_name': 'spam',
+                'software_version': '2.0',
+                'probe_asn': 'AS0',
+                'probe_cc': 'ZZ',
+                'test_name': 'foobar',
+                'test_version': '1.0',
+                'input_hashes': []
+        })
+        assert isinstance(res['report_id'], unicode)
+
+    @defer.inlineCallbacks
+    def test_report_lifecycle(self):
+        res = yield self.oonibclient.queryBackend('POST', '/report', {
+                'software_name': 'spam',
+                'software_version': '2.0',
+                'probe_asn': 'AS0',
+                'probe_cc': 'ZZ',
+                'test_name': 'foobar',
+                'test_version': '1.0',
+                'input_hashes': []
+        })
+        report_id = str(res['report_id'])
+
+        res = yield self.oonibclient.queryBackend('POST', '/report/'+report_id, {
+            'content': '---\nspam: ham\n...\n'
+        })
+
+        res = yield self.oonibclient.queryBackend('POST', '/report/'+report_id, {
+            'content': '---\nspam: ham\n...\n'
+        })
+        
+        res = yield self.oonibclient.queryBackend('POST', '/report/'+report_id+'/close')





More information about the tor-commits mailing list