forked from ooni/probe
/
template.py
65 lines (52 loc) · 1.61 KB
/
template.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""
Test Template
*************
This is a Test template, to be used when writing your
own OONI probe Tests.
"""
import os
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.
"""
return False
def control(self):
"""
Fill this up with the control related code.
"""
return True
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.")