本文整理汇总了Python中ooni.director.Director.startNetTest方法的典型用法代码示例。如果您正苦于以下问题:Python Director.startNetTest方法的具体用法?Python Director.startNetTest怎么用?Python Director.startNetTest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ooni.director.Director
的用法示例。
在下文中一共展示了Director.startNetTest方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_singular_input_processor
# 需要导入模块: from ooni.director import Director [as 别名]
# 或者: from ooni.director.Director import startNetTest [as 别名]
def test_singular_input_processor(self):
"""
Verify that all measurements use the same object as their input processor.
"""
ntl = NetTestLoader(dummyArgs)
ntl.loadNetTestString(generator_id_net_test)
ntl.checkOptions()
director = Director()
self.filename = 'dummy_report.yamloo'
d = director.startNetTest(ntl, self.filename)
@d.addCallback
def complete(result):
with open(self.filename) as report_file:
all_report_entries = yaml.safe_load_all(report_file)
header = all_report_entries.next()
results_case_a = all_report_entries.next()
aa_test, ab_test, ac_test = results_case_a.get('results', [])
results_case_b = all_report_entries.next()
ba_test = results_case_b.get('results', [])[0]
# Within a NetTestCase an inputs object will be consistent
self.assertEqual(aa_test, ab_test, ac_test)
# An inputs object will be different between different NetTestCases
self.assertNotEqual(aa_test, ba_test)
return d
示例2: test_run_test_fails_twice
# 需要导入模块: from ooni.director import Director [as 别名]
# 或者: from ooni.director.Director import startNetTest [as 别名]
def test_run_test_fails_twice(self):
finished = defer.Deferred()
def net_test_done(net_test):
summary_items = net_test.summary.items()
self.assertEqual(len(summary_items), 50)
for input_name, run_count in summary_items:
self.assertEqual(run_count, 3)
finished.callback(None)
net_test_loader = NetTestLoader(('spam','ham'))
net_test_loader.loadNetTestString(test_failing_twice)
director = Director()
director.netTestDone = net_test_done
director.startNetTest(net_test_loader, None, no_yamloo=True)
return finished
示例3: TestDirector
# 需要导入模块: from ooni.director import Director [as 别名]
# 或者: from ooni.director.Director import startNetTest [as 别名]
class TestDirector(unittest.TestCase):
timeout = 1
def setUp(self):
with open('dummyInputFile.txt', 'w') as f:
for i in range(10):
f.write("%s\n" % i)
self.reporters = [MockReporter()]
self.director = Director()
def tearDown(self):
pass
def test_start_net_test(self):
options = {'test':net_test_string, 'subargs':dummyArgs}
net_test_loader = NetTestLoader(options)
net_test_loader.checkOptions()
d = self.director.startNetTest('', net_test_loader, self.reporters)
@d.addCallback
def done(result):
self.assertEqual(self.director.successfulMeasurements, 20)
return d
def test_stop_net_test(self):
pass
示例4: test_nettest_timeout
# 需要导入模块: from ooni.director import Director [as 别名]
# 或者: from ooni.director.Director import startNetTest [as 别名]
def test_nettest_timeout(self):
ntl = NetTestLoader(('-u', 'http://localhost:8007/'))
ntl.loadNetTestString(http_net_test)
ntl.checkOptions()
director = Director()
d = director.startNetTest(ntl, [MockReporter()])
@d.addCallback
def complete(result):
assert director.failedMeasurements == 1
return d
示例5: test_net_test_completed_callback
# 需要导入模块: from ooni.director import Director [as 别名]
# 或者: from ooni.director.Director import startNetTest [as 别名]
def test_net_test_completed_callback(self):
ntl = NetTestLoader(dummyArgsWithFile)
ntl.loadNetTestString(net_test_string_with_file)
ntl.checkOptions()
director = Director()
d = director.startNetTest(ntl, [MockReporter()])
@d.addCallback
def complete(result):
self.assertEqual(result, None)
self.assertEqual(director.successfulMeasurements, 20)
return d
示例6: test_net_test_completed_callback
# 需要导入模块: from ooni.director import Director [as 别名]
# 或者: from ooni.director.Director import startNetTest [as 别名]
def test_net_test_completed_callback(self):
options = {'subargs':dummyArgsWithFile,
'test':StringIO(net_test_string_with_file)}
ntl = NetTestLoader(options)
ntl.checkOptions()
director = Director()
d = director.startNetTest('', ntl, [MockReporter()])
@d.addCallback
def complete(result):
#XXX: why is the return type (True, None) ?
self.assertEqual(result, [(True,None)])
self.assertEqual(director.successfulMeasurements, 20)
return d
示例7: test_send_to_inputs_generator
# 需要导入模块: from ooni.director import Director [as 别名]
# 或者: from ooni.director.Director import startNetTest [as 别名]
def test_send_to_inputs_generator(self):
"""
Verify that a net test can send information back into an inputs generator.
"""
ntl = NetTestLoader(dummyArgs)
ntl.loadNetTestString(generator_net_test)
ntl.checkOptions()
director = Director()
self.filename = 'dummy_report.yamloo'
d = director.startNetTest(ntl, self.filename)
@d.addCallback
def complete(result):
with open(self.filename) as report_file:
all_report_entries = yaml.safe_load_all(report_file)
header = all_report_entries.next()
results = [x['input'] for x in all_report_entries]
self.assertEqual(results, [9, 8, 7, 6, 5, 5, 3, 2, 1, 0])
return d