当前位置: 首页>>代码示例>>Python>>正文


Python Director.startNetTest方法代码示例

本文整理汇总了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
开发者ID:willscott,项目名称:ooni-probe,代码行数:29,代码来源:test_nettest.py

示例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
开发者ID:Archer-sys,项目名称:ooni-probe,代码行数:18,代码来源:test_director.py

示例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
开发者ID:bhitov,项目名称:ooni-probe,代码行数:29,代码来源:test_director.py

示例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
开发者ID:qlimaxx,项目名称:ooni-probe-dev,代码行数:16,代码来源:test_nettest.py

示例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
开发者ID:qlimaxx,项目名称:ooni-probe-dev,代码行数:17,代码来源:test_nettest.py

示例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
开发者ID:bhitov,项目名称:ooni-probe,代码行数:18,代码来源:test_nettest.py

示例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
开发者ID:willscott,项目名称:ooni-probe,代码行数:23,代码来源:test_nettest.py


注:本文中的ooni.director.Director.startNetTest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。