[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [ooni-probe/master] Move setUpNetTestCases into start() and set up measurementManager
commit 786436d45d9dfc4c62a46dbf6e2bf0ab9ca94f61
Author: aagbsn <aagbsn@xxxxxxxx>
Date: Sun Jan 13 12:58:26 2013 +0000
Move setUpNetTestCases into start() and set up measurementManager
Also updates the test cases.
---
ooni/nettest.py | 8 ++++----
tests/test_nettest.py | 20 ++++++++++++++------
2 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/ooni/nettest.py b/ooni/nettest.py
index 0fb5038..01dde72 100644
--- a/ooni/nettest.py
+++ b/ooni/nettest.py
@@ -13,7 +13,7 @@ class NoTestCasesFound(Exception):
pass
class NetTest(object):
- director = None
+ measurementManager = None
method_prefix = 'test'
def __init__(self, net_test_file, options, report):
@@ -26,15 +26,15 @@ class NetTest(object):
"""
self.options = options
self.report = report
-
self.test_cases = self.loadNetTest(net_test_file)
- self.setUpNetTestCases()
def start(self):
"""
+ Set up tests and start running.
Start tests and generate measurements.
"""
- raise NotImplementedError
+ self.setUpNetTestCases()
+ self.measurementManager.schedule(self.generateMeasurements())
def loadNetTest(self, net_test_file):
"""
diff --git a/tests/test_nettest.py b/tests/test_nettest.py
index 07e991e..a23d16b 100644
--- a/tests/test_nettest.py
+++ b/tests/test_nettest.py
@@ -190,24 +190,29 @@ class TestNetTest(unittest.TestCase):
net_test = NetTest(StringIO(net_test_string),
dummyOptions, None)
self.assertIsInstance(net_test, NetTest)
+ net_test.setUpNetTestCases()
for test_klass, test_meth in net_test.test_cases:
for option in dummyOptions.keys():
self.assertIn(option, test_klass.usageOptions())
def test_load_with_invalid_option(self):
try:
- NetTest(StringIO(net_test_string), dummyInvalidOptions, None)
+ net_test = NetTest(StringIO(net_test_string), dummyInvalidOptions, None)
+ net_test.setUpNetTestCases()
except InvalidOption:
pass
def test_load_with_required_option(self):
- self.assertIsInstance(NetTest(StringIO(net_test_with_required_option),
- dummyOptionsWithRequiredOptions, None), NetTest)
+ net_test = NetTest(StringIO(net_test_with_required_option),
+ dummyOptionsWithRequiredOptions, None)
+ net_test.setUpNetTestCases()
+ self.assertIsInstance(net_test, NetTest)
def test_load_with_missing_required_option(self):
try:
- NetTest(StringIO(net_test_with_required_option),
+ net_test = NetTest(StringIO(net_test_with_required_option),
dummyOptions, None)
+ net_test.setUpNetTestCases()
except MissingRequiredOption:
pass
@@ -217,6 +222,7 @@ class TestNetTest(unittest.TestCase):
net_test = NetTest(StringIO(net_test_string_with_file),
dummyOptionsWithFile, None)
+ net_test.setUpNetTestCases()
for test_class, test_method in net_test.test_cases:
self.assertEqual(len(list(test_class.inputs)), 10)
@@ -224,6 +230,7 @@ class TestNetTest(unittest.TestCase):
def test_setup_local_options_in_test_cases(self):
net_test = NetTest(StringIO(net_test_string),
dummyOptions, None)
+ net_test.setUpNetTestCases()
for test_class, test_method in net_test.test_cases:
self.assertEqual(test_class.localOptions, dummyOptions)
@@ -234,7 +241,7 @@ class TestNetTest(unittest.TestCase):
net_test = NetTest(StringIO(net_test_string_with_file),
dummyOptionsWithFile, None)
-
+ net_test.setUpNetTestCases()
measurements = list(net_test.generateMeasurements())
self.assertEqual(len(measurements), 20)
@@ -248,8 +255,9 @@ class TestNetTest(unittest.TestCase):
def test_require_root_failed(self):
#XXX: will fail if you run as root
try:
- NetTest(StringIO(net_test_root_required),
+ net_test = NetTest(StringIO(net_test_root_required),
dummyOptions, None)
+ net_test.setUpNetTestCases()
except NotRootError:
pass
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits