def test_generate_measurements_size(self): ntl = NetTestLoader(dummyArgsWithFile) ntl.loadNetTestString(net_test_string_with_file) ntl.checkOptions() net_test = NetTest(ntl, None) net_test.initializeInputProcessor() measurements = list(net_test.generateMeasurements()) self.assertEqual(len(measurements), 20)
def test_net_test_inputs(self): ntl = NetTestLoader(dummyArgsWithFile) ntl.loadNetTestString(net_test_string_with_file) ntl.checkOptions() nt = NetTest(ntl.getTestCases(), ntl.getTestDetails(), None) nt.initializeInputProcessor() # XXX: if you use the same test_class twice you will have consumed all # of its inputs! tested = set([]) for test_instance, test_method, inputs in nt.testInstances: self.assertEqual(len(list(inputs)), 10)
def test_net_test_inputs(self): ntl = NetTestLoader(dummyArgsWithFile) ntl.loadNetTestString(net_test_string_with_file) ntl.checkOptions() nt = NetTest(ntl,None) nt.initializeInputProcessor() # XXX: if you use the same test_class twice you will have consumed all # of its inputs! tested = set([]) for test_class, test_method in ntl.testCases: if test_class not in tested: tested.update([test_class]) self.assertEqual(len(list(test_class.inputs)), 10)
def test_net_test_inputs(self): ntl = NetTestLoader(dummyArgsWithFile) ntl.loadNetTestString(net_test_string_with_file) ntl.checkOptions() nt = NetTest(ntl, None) nt.initializeInputProcessor() # XXX: if you use the same test_class twice you will have consumed all # of its inputs! tested = set([]) for test_class, test_method in ntl.testCases: if test_class not in tested: tested.update([test_class]) self.assertEqual(len(list(test_class.inputs)), 10)
def startNetTest(self, net_test_loader, report_filename, collector_address=None): """ Create the Report for the NetTest and start the report NetTest. Args: net_test_loader: an instance of :class:ooni.nettest.NetTestLoader """ if self.allTestsDone.called: self.allTestsDone = defer.Deferred() if config.privacy.includepcap: self.startSniffing(net_test_loader.testDetails) report = Report(net_test_loader.testDetails, report_filename, self.reportEntryManager, collector_address) net_test = NetTest(net_test_loader, report) net_test.director = self yield net_test.report.open() yield net_test.initializeInputProcessor() try: self.activeNetTests.append(net_test) self.measurementManager.schedule(net_test.generateMeasurements()) yield net_test.done yield report.close() finally: self.netTestDone(net_test)
def startNetTest(self, net_test_loader, reporters): """ Create the Report for the NetTest and start the report NetTest. Args: net_test_loader: an instance of :class:ooni.nettest.NetTestLoader """ if config.privacy.includepcap: if not config.reports.pcap: config.reports.pcap = config.generatePcapFilename(net_test_loader.testDetails) self.startSniffing() report = Report(reporters, self.reportEntryManager) net_test = NetTest(net_test_loader, report) net_test.director = self yield net_test.report.open() yield net_test.initializeInputProcessor() self.measurementManager.schedule(net_test.generateMeasurements()) self.activeNetTests.append(net_test) yield net_test.done yield report.close() self.netTestDone(net_test)
def startNetTest(self, net_test_loader, report_filename, collector_address=None, no_yamloo=False): """ Create the Report for the NetTest and start the report NetTest. Args: net_test_loader: an instance of :class:ooni.nettest.NetTestLoader """ # Here we set the test details again since the geoip lookups may # not have already been done and probe_asn and probe_ip # are not set. net_test_loader.setTestDetails() if self.allTestsDone.called: self.allTestsDone = defer.Deferred() if config.privacy.includepcap: self.startSniffing(net_test_loader.testDetails) report = Report(net_test_loader.testDetails, report_filename, self.reportEntryManager, collector_address, no_yamloo) net_test = NetTest(net_test_loader, report) net_test.director = self yield net_test.report.open() yield net_test.initializeInputProcessor() try: self.activeNetTests.append(net_test) self.measurementManager.schedule(net_test.generateMeasurements()) yield net_test.done yield report.close() finally: self.netTestDone(net_test)