From 064e9ab510901db095433f526536a199bac8ce85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arturo=20Filast=C3=B2?= Date: Wed, 29 Jan 2014 21:22:21 +0100 Subject: [PATCH] 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 b5957c47..f166ae7f 100644 --- a/ooni/tests/test_oonibclient.py +++ b/ooni/tests/test_oonibclient.py @@ -111,3 +111,39 @@ def all_requests(path): 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')