[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

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



commit 064e9ab510901db095433f526536a199bac8ce85
Author: Arturo Filastò <art@xxxxxxxxx>
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')



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits