[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [ooni-probe/master] Add a useful Test template
commit 2d2991f65c1c539e1235ec4ef9f2c0ec4b1d02f3
Author: Arturo Filastò <hellais@xxxxxxxxx>
Date: Tue Mar 6 21:16:45 2012 -0800
Add a useful Test template
* Remove useless test example
---
tests/exampletest.py | 6 ----
tests/template.py | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+), 6 deletions(-)
diff --git a/tests/exampletest.py b/tests/exampletest.py
deleted file mode 100644
index ff3a89d..0000000
--- a/tests/exampletest.py
+++ /dev/null
@@ -1,6 +0,0 @@
-# This is an example test that just defines the
-# two strings that are used to ouput a descrption
-# in the cli interface
-__plugoo__ = "this is an example test"
-__desc__ = "This is the description of the example test"
-
diff --git a/tests/template.py b/tests/template.py
new file mode 100644
index 0000000..42952bf
--- /dev/null
+++ b/tests/template.py
@@ -0,0 +1,63 @@
+"""
+ Test Template
+ *************
+
+ This is a Test template, to be used when writing your
+ own OONI probe Tests.
+"""
+from plugoo.assets import Asset
+from plugoo.tests import Test
+
+__plugoo__ = "Test Template"
+__desc__ = "This a test template to be used to build your own tests"
+
+class TestTemplateAsset(Asset):
+ """
+ This is the asset that should be used by the Test. It will
+ contain all the code responsible for parsing the asset file
+ and should be passed on instantiation to the test.
+ """
+ def __init__(self, file=None):
+ self = asset.__init__(self, file)
+
+
+class TestTemplate(Test):
+ """
+ The main Test class
+ """
+
+ def experiment(self, *a, **kw):
+ """
+ Fill this up with the tasks that should be performed
+ on the "dirty" network and should be compared with the
+ control.
+ """
+ pass
+
+ def control(self):
+ """
+ Fill this up with the control related code.
+ """
+ pass
+
+def run(ooni):
+ """
+ This is the function that will be called by OONI
+ and it is responsible for instantiating and passing
+ the arguments to the Test class.
+ """
+ config = ooni.config
+
+ # This the assets array to be passed to the run function of
+ # the test
+ assets = [TestTemplateAsset(os.path.join(config.main.assetdir, \
+ "someasset.txt"))]
+
+ # Instantiate the Test
+ thetest = TestTemplate(ooni)
+ ooni.logger.info("starting TestTemplate...")
+ # Run the test with argument assets
+ thetest.run(assets)
+ ooni.logger.info("finished.")
+
+
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits