[tor-commits] [ooni-probe/master] Fix unittests of oonireport

art at torproject.org art at torproject.org
Mon Sep 19 12:14:24 UTC 2016


commit e490533b48c7c62da5e6d28832434dbc51fb85f0
Author: Arturo Filastò <arturo at filasto.net>
Date:   Fri Jul 29 23:49:32 2016 +0200

    Fix unittests of oonireport
---
 ooni/tests/test_oonireport.py | 19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)

diff --git a/ooni/tests/test_oonireport.py b/ooni/tests/test_oonireport.py
index 4769682..fe5e420 100644
--- a/ooni/tests/test_oonireport.py
+++ b/ooni/tests/test_oonireport.py
@@ -1,5 +1,3 @@
-import yaml
-
 from mock import patch, MagicMock
 
 from twisted.internet import defer
@@ -9,15 +7,6 @@ mock_tor_check = MagicMock(return_value=True)
 
 class TestOONIReport(ConfigTestCase):
 
-    def _create_reporting_yaml(self, filename):
-        from ooni.settings import config
-        with open(config.report_log_file, 'w+') as f:
-            yaml.dump({
-                filename: {
-                    "collector": "httpo://thirteenchars123.onion"
-                }
-            }, f)
-
     def _write_dummy_report(self, filename):
         from ooni.reporter import YAMLReporter
         from .test_reporter import test_details
@@ -65,10 +54,9 @@ class TestOONIReport(ConfigTestCase):
         mock_oonib_report_log_i.closed.return_value = defer.succeed(True)
 
         report_name = "dummy_report.yaml"
-        self._create_reporting_yaml(report_name)
         self._write_dummy_report(report_name)
         from ooni.scripts import oonireport
-        d = oonireport.upload(report_name)
+        d = oonireport.upload(report_name, collector='httpo://thirteenchars123.onion')
         @d.addCallback
         def cb(result):
             mock_oonib_reporter_i.writeReportEntry.assert_called_with(
@@ -90,14 +78,13 @@ class TestOONIReport(ConfigTestCase):
         mock_oonib_report_log_i = mock_oonib_report_log.return_value
         mock_oonib_report_log_i.created.return_value = defer.succeed(True)
         mock_oonib_report_log_i.closed.return_value = defer.succeed(True)
-        mock_oonib_report_log_i.reports_to_upload = [("dummy_report.yaml", None)]
+        mock_oonib_report_log_i.get_to_upload.return_value = defer.succeed([("dummy_report.yaml", {'measurement_id': 'XX'})])
 
         report_name = "dummy_report.yaml"
-        self._create_reporting_yaml(report_name)
         self._write_dummy_report(report_name)
 
         from ooni.scripts import oonireport
-        d = oonireport.upload_all()
+        d = oonireport.upload_all(collector='httpo://thirteenchars123.onion')
         @d.addCallback
         def cb(result):
             mock_oonib_reporter_i.writeReportEntry.assert_called_with(





More information about the tor-commits mailing list