[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [ooni-probe/master] Add to global import table legacy modules
commit 97781606863ec6115bb5e0da47188a510f122826
Author: Arturo Filastò <arturo@xxxxxxxxxxx>
Date: Wed Oct 24 15:40:03 2012 +0000
Add to global import table legacy modules
* Refactor test case directory structure separating legacy tests from new tests
---
ooni/__init__.py | 13 ++++++++++-
tests/legacy/test_plugins.py | 40 +++++++++++++++++++++++++++++++++++++
tests/legacy/test_tests.py | 45 ++++++++++++++++++++++++++++++++++++++++++
tests/test_plugins.py | 40 -------------------------------------
tests/test_tests.py | 45 ------------------------------------------
5 files changed, 96 insertions(+), 87 deletions(-)
diff --git a/ooni/__init__.py b/ooni/__init__.py
index e730eb5..9a4e60f 100644
--- a/ooni/__init__.py
+++ b/ooni/__init__.py
@@ -7,8 +7,17 @@ from . import nettest
from . import oonicli
from . import reporter
from . import runner
-from . import template
+from . import templates
from . import utils
+
+# XXX below are legacy related modules
+from . import ooniprobe
+from . import plugoo
+from . import plugins
+from . import oonitests
+
__all__ = ['config', 'input', 'inputunit', 'kit',
'lib', 'nettest', 'oonicli', 'reporter',
- 'runner', 'templates', 'utils']
+ 'runner', 'templates', 'utils',
+ # XXX below are legacy related modules
+ 'ooniprobe', 'plugoo', 'plugins', 'oonitests']
diff --git a/tests/legacy/test_plugins.py b/tests/legacy/test_plugins.py
new file mode 100644
index 0000000..26bee51
--- /dev/null
+++ b/tests/legacy/test_plugins.py
@@ -0,0 +1,40 @@
+from twisted.internet import defer, reactor
+from twisted.trial import unittest
+
+from ooni.ooniprobe import retrieve_plugoo, runTest, Options
+from ooni.plugoo import work, tests
+
+def asset_file(filename):
+ import os
+ file_dir = os.path.normpath(os.path.join(__file__, '..'))
+ return os.path.join(file_dir, 'assets', filename)
+
+class PluginsTestCase(unittest.TestCase):
+ def test_plugin_blocking(self):
+ suboptions = {'asset': asset_file('urllist.txt')}
+ runTest('blocking', suboptions, Options(), reactor)
+ return
+
+ def test_plugin_tcpconnect(self):
+ suboptions = {'asset': asset_file('ipports.txt')}
+ runTest('tcpconnect', suboptions, Options(), reactor)
+ return
+
+
+ def test_plugin_captivep(self):
+ runTest('blocking', None, Options(), reactor)
+ return
+
+
+ def test_plugin_httphost(self):
+ suboptions = {'asset': asset_file('urllist.txt')}
+ runTest('httphost', suboptions, Options(), reactor)
+ return
+
+
+ def test_plugin_httpt(self):
+ suboptions = {'urls': asset_file('urllist.txt')}
+ runTest('httpt', suboptions, Options(), reactor)
+ return
+
+
diff --git a/tests/legacy/test_tests.py b/tests/legacy/test_tests.py
new file mode 100644
index 0000000..dc89b98
--- /dev/null
+++ b/tests/legacy/test_tests.py
@@ -0,0 +1,45 @@
+from twisted.internet import defer
+from twisted.trial import unittest
+
+from ooni.plugoo import work, tests
+
+class TestsTestCase(unittest.TestCase):
+ def setUp(self):
+ class dummyReport:
+ def __call__(self, *args, **kw):
+ pass
+ self.dummyreport = dummyReport()
+ self.callbackResults = None
+ self.errbackResults = None
+
+ def _callback(self, *args, **kw):
+ #print args, kw
+ self.callbackResults = args, kw
+
+ def _errback(self, *args, **kw):
+ pass
+
+ @defer.inlineCallbacks
+ def test_fallThrough(self):
+ """
+ This tests to make sure that what is returned from the experiment
+ method falls all the way through to control and finish.
+ """
+ test_dict = {"hello": "world"}
+ class DummyTest(tests.OONITest):
+ blocking = False
+ def experiment(self, args):
+ def bla(a):
+ print a
+ return test_dict
+ d2 = defer.Deferred()
+ d2.addCallback(bla)
+ from twisted.internet import reactor
+ reactor.callLater(0.1, d2.callback, None)
+ return d2
+
+ test = DummyTest(None, None, self.dummyreport)
+ yield test.startTest(None).addCallback(self._callback)
+ self.assertEqual(self.callbackResults[0][0]['return_value'], test_dict)
+ return
+
diff --git a/tests/test_plugins.py b/tests/test_plugins.py
deleted file mode 100644
index 26bee51..0000000
--- a/tests/test_plugins.py
+++ /dev/null
@@ -1,40 +0,0 @@
-from twisted.internet import defer, reactor
-from twisted.trial import unittest
-
-from ooni.ooniprobe import retrieve_plugoo, runTest, Options
-from ooni.plugoo import work, tests
-
-def asset_file(filename):
- import os
- file_dir = os.path.normpath(os.path.join(__file__, '..'))
- return os.path.join(file_dir, 'assets', filename)
-
-class PluginsTestCase(unittest.TestCase):
- def test_plugin_blocking(self):
- suboptions = {'asset': asset_file('urllist.txt')}
- runTest('blocking', suboptions, Options(), reactor)
- return
-
- def test_plugin_tcpconnect(self):
- suboptions = {'asset': asset_file('ipports.txt')}
- runTest('tcpconnect', suboptions, Options(), reactor)
- return
-
-
- def test_plugin_captivep(self):
- runTest('blocking', None, Options(), reactor)
- return
-
-
- def test_plugin_httphost(self):
- suboptions = {'asset': asset_file('urllist.txt')}
- runTest('httphost', suboptions, Options(), reactor)
- return
-
-
- def test_plugin_httpt(self):
- suboptions = {'urls': asset_file('urllist.txt')}
- runTest('httpt', suboptions, Options(), reactor)
- return
-
-
diff --git a/tests/test_tests.py b/tests/test_tests.py
deleted file mode 100644
index dc89b98..0000000
--- a/tests/test_tests.py
+++ /dev/null
@@ -1,45 +0,0 @@
-from twisted.internet import defer
-from twisted.trial import unittest
-
-from ooni.plugoo import work, tests
-
-class TestsTestCase(unittest.TestCase):
- def setUp(self):
- class dummyReport:
- def __call__(self, *args, **kw):
- pass
- self.dummyreport = dummyReport()
- self.callbackResults = None
- self.errbackResults = None
-
- def _callback(self, *args, **kw):
- #print args, kw
- self.callbackResults = args, kw
-
- def _errback(self, *args, **kw):
- pass
-
- @defer.inlineCallbacks
- def test_fallThrough(self):
- """
- This tests to make sure that what is returned from the experiment
- method falls all the way through to control and finish.
- """
- test_dict = {"hello": "world"}
- class DummyTest(tests.OONITest):
- blocking = False
- def experiment(self, args):
- def bla(a):
- print a
- return test_dict
- d2 = defer.Deferred()
- d2.addCallback(bla)
- from twisted.internet import reactor
- reactor.callLater(0.1, d2.callback, None)
- return d2
-
- test = DummyTest(None, None, self.dummyreport)
- yield test.startTest(None).addCallback(self._callback)
- self.assertEqual(self.callbackResults[0][0]['return_value'], test_dict)
- return
-
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits