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

[tor-commits] [ooni-probe/master] Move Reporter Mocks into mocks.py



commit 6cbbfb206624f4d399a7cca06cb8997a63dafd46
Author: aagbsn <aagbsn@xxxxxxxx>
Date:   Tue Jan 15 12:31:24 2013 +0000

    Move Reporter Mocks into mocks.py
---
 tests/mocks.py         |   25 +++++++++++++++++++++++++
 tests/test_reporter.py |   34 +++-------------------------------
 2 files changed, 28 insertions(+), 31 deletions(-)

diff --git a/tests/mocks.py b/tests/mocks.py
index 687e247..60727e5 100644
--- a/tests/mocks.py
+++ b/tests/mocks.py
@@ -114,3 +114,28 @@ class MockDirector(object):
 
     def measurementSucceeded(self, measurement):
         self.successes.append(measurement)
+
+## from test_reporter.py
+class MockOReporter(object):
+    def __init__(self):
+        self.created = defer.Deferred()
+
+    def writeReportEntry(self, entry):
+        pass
+
+    def finish(self):
+        pass
+
+    def createReport(self):
+        pass
+
+
+class MockTaskManager(TaskManager):
+    def __init__(self):
+        self.successes = []
+
+    def failed(self, failure, task):
+        pass
+
+    def succeeded(self, result, task):
+        self.successes.append((result, task))
diff --git a/tests/test_reporter.py b/tests/test_reporter.py
index 1754ad0..e1c7fca 100644
--- a/tests/test_reporter.py
+++ b/tests/test_reporter.py
@@ -6,39 +6,11 @@ from ooni.managers import ReportEntryManager, TaskManager
 from ooni.nettest import NetTest
 
 from ooni.tasks import TaskMediator, TaskWithTimeout
+from tests.mocks import MockOReporter, MockTaskManager
+from tests.mocks import MockMeasurement, MockNetTest
 
 mockReportOptions = {'name':'foo_test', 'version': '0.1'}
 
-class MockOReporter(object):
-    def __init__(self):
-        self.created = defer.Deferred()
-
-    def writeReportEntry(self, entry):
-        pass
-
-    def finish(self):
-        pass
-
-    def createReport(self):
-        pass
-
-class MockMeasurement(TaskWithTimeout):
-    def __init__(self):
-        TaskWithTimeout.__init__(self)
-
-    def succeeded(self, result):
-        pass
-
-class MockTaskManager(TaskManager):
-    def __init__(self):
-        self.successes = []
-
-    def failed(self, failure, task):
-        pass
-
-    def succeeded(self, result, task):
-        self.successes.append((result, task))
-
 class TestReport(unittest.TestCase):
     def setUp(self):
         self.report = Report([MockOReporter])
@@ -46,7 +18,7 @@ class TestReport(unittest.TestCase):
 
     def test_report_alltasksdone_callback_fires(self):
         for m in range(10):
-            measurement = MockMeasurement()
+            measurement = MockMeasurement(MockNetTest())
             self.report.write(measurement)
 
         self.report.report_mediator.allTasksScheduled()



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