commit a511a8b36c85c0535c6019fbc1081fd5e6235379 Author: Arturo Filastò art@fuffa.org Date: Sat Nov 10 20:23:22 2012 +0100
Add test_name to the report Remove simple test --- nettests/simpletest.py | 27 --------------------------- ooni/config.py | 2 +- ooni/reporter.py | 15 +++++---------- ooni/runner.py | 10 +++++----- 4 files changed, 11 insertions(+), 43 deletions(-)
diff --git a/nettests/simpletest.py b/nettests/simpletest.py deleted file mode 100644 index d72c00c..0000000 --- a/nettests/simpletest.py +++ /dev/null @@ -1,27 +0,0 @@ -#-*- coding: utf-8 -*- -"""Contains classes for testing the basic functionality of oonicli.""" - -from ooni import nettest - -class SimpleTest(nettest.NetTestCase): - """ - A very simple test which prints integers, for testing that oonicli is - working correctly. - """ - inputs = range(0, 20) - optParameters = [['asset', 'a', None, 'Asset file'], - ['controlserver', 'c', 'google.com', - 'Specify the control server'], - ['resume', 'r', 0, 'Resume at this index'], - ['other', 'o', None, 'Other arguments']] - def test_foo(self): - """Test that tests are working.""" - print "Running %s with %s" % ("test_foo", self.input) - self.report['test_foo'] = 'Antani' - self.report['shared'] = "sblinda" - - def test_f4oo(self): - """Test that tests are working.""" - print "Running %s with %s" % ("test_f4oo", self.input) - self.report['test_f4oo'] = 'Antani' - self.report['shared'] = "sblinda2" diff --git a/ooni/config.py b/ooni/config.py index cec9146..a2ce917 100644 --- a/ooni/config.py +++ b/ooni/config.py @@ -1,6 +1,6 @@ # -*- encoding: utf-8 -*- # -# :authors: Arturo "hellais" Filastò art@fuffa.org +# :authors: Arturo Filastò # :licence: see LICENSE
import os diff --git a/ooni/reporter.py b/ooni/reporter.py index 33b4675..5d29d54 100644 --- a/ooni/reporter.py +++ b/ooni/reporter.py @@ -95,15 +95,11 @@ class OONIBReporter(object): self.backend_url = backend_url
def _newReportCreated(self, data): - #log.debug("Got this as result: %s" % data) - print "Got this as result: %s" % data - + log.debug("Got this as result: %s" % data) return data
def _processResponseBody(self, response, body_cb): - #log.debug("Got response %s" % response) - print "Got response %s" % response - + log.debug("Got response %s" % response) done = defer.Deferred() response.deliverBody(BodyReceiver(done)) done.addCallback(body_cb) @@ -111,8 +107,6 @@ class OONIBReporter(object):
def newReport(self, test_name, test_version): url = self.backend_url + '/new' - print "Creating report via url %s" % url - software_version = '0.0.1'
request = {'software_name': 'ooni-probe', @@ -120,7 +114,7 @@ class OONIBReporter(object): 'test_name': test_name, 'test_version': test_version, 'progress': 0}
- #log.debug("Creating report via url %s" % url) + log.debug("Creating report via url %s" % url) bodyProducer = StringProducer(json.dumps(request)) d = self.agent.request("POST", url, bodyProducer=bodyProducer) d.addCallback(self._processResponseBody, self._newReportCreated) @@ -211,7 +205,7 @@ class OReporter(YamlReporter): } self.writeReportEntry(test_details)
- def testDone(self, test): + def testDone(self, test, test_name): test_report = dict(test.report)
# XXX the scapy test has an example of how @@ -225,6 +219,7 @@ class OReporter(YamlReporter): test_runtime = test_started - time.time()
report = {'input': test_input, + 'test_name': test_name, 'test_started': test_started, 'report': test_report} self.writeReportEntry(report) diff --git a/ooni/runner.py b/ooni/runner.py index d03f6c6..1affb15 100644 --- a/ooni/runner.py +++ b/ooni/runner.py @@ -153,10 +153,10 @@ def loadTestsAndOptions(classes, cmd_line_options):
def runTestWithInput(test_class, test_method, test_input, oreporter): log.debug("Running %s with %s" % (test_method, test_input)) - def test_done(result, test_instance): - oreporter.testDone(test_instance) + def test_done(result, test_instance, test_name): + oreporter.testDone(test_instance, test_name)
- def test_error(error, test_instance): + def test_error(error, test_instance, test_name): log.err("%s\n" % error)
test_instance = test_class() @@ -169,8 +169,8 @@ def runTestWithInput(test_class, test_method, test_input, oreporter): test_instance.setUp() test = getattr(test_instance, test_method) d = defer.maybeDeferred(test) - d.addCallback(test_done, test_instance) - d.addErrback(test_error, test_instance) + d.addCallback(test_done, test_instance, test_method) + d.addErrback(test_error, test_instance, test_method) log.debug("returning %s input" % test_method) return d