[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [ooni-probe/master] Update URL List test to take as input also a single URL
commit 2bf3da588442f2f50e78532f8045f48ac457532c
Author: Arturo Filastò <art@xxxxxxxxx>
Date: Mon Nov 12 23:05:41 2012 +0100
Update URL List test to take as input also a single URL
* Refactoring to make the test smaller
---
nettests/core/url_list.py | 34 +++++++++++++++++-----------------
1 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/nettests/core/url_list.py b/nettests/core/url_list.py
index 06a5147..e7178e7 100644
--- a/nettests/core/url_list.py
+++ b/nettests/core/url_list.py
@@ -7,8 +7,10 @@ from twisted.python import usage
from ooni.templates import httpt
class UsageOptions(usage.Options):
- optParameters = [['content', 'c', None,
- 'The file to read from containing the content of a block page']]
+ optParameters = [['content', 'c', None,
+ 'The file to read from containing the content of a block page'],
+ ['url', 'u', None, 'Specify a single URL to test.']
+ ]
class URLList(httpt.HTTPTest):
"""
@@ -18,12 +20,23 @@ class URLList(httpt.HTTPTest):
"""
name = "URL List"
author = "Arturo Filastò"
- version = "0.1.1"
+ version = "0.1.2"
+
+ usageOptions = UsageOptions
inputFile = ['file', 'f', None,
'List of URLS to perform GET and POST requests to']
- requiredOptions = ['file']
+ def setUp(self):
+ """
+ Check for inputs.
+ """
+ if self.input:
+ self.url = self.input
+ elif self.localOptions['url']:
+ self.url = self.localOptions['url']
+ else:
+ raise Exception("No input specified")
def check_for_censorship(self, body):
"""
@@ -44,28 +57,15 @@ class URLList(httpt.HTTPTest):
if response_line != censorship_line:
self.report['censored'] = False
break
-
censorship_page.close()
def test_get(self):
- if self.input:
- self.url = self.input
- else:
- raise Exception("No input specified")
return self.doRequest(self.url, method="GET")
def test_post(self):
- if self.input:
- self.url = self.input
- else:
- raise Exception("No input specified")
return self.doRequest(self.url, method="POST")
def test_put(self):
- if self.input:
- self.url = self.input
- else:
- raise Exception("No input specified")
return self.doRequest(self.url, method="PUT")
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits