[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [bridgedb/develop] Whitespace fixes for bridgedb.test.test_https.



commit be93cb7c849990bf516c33c1a440ca406b2b3cb9
Author: trygve <tor-dev@xxxxxxxxxxxxxxxxxxxx>
Date:   Fri Aug 8 03:11:31 2014 +0000

    Whitespace fixes for bridgedb.test.test_https.
---
 lib/bridgedb/test/test_https.py |  210 +++++++++++++++++++--------------------
 1 file changed, 105 insertions(+), 105 deletions(-)

diff --git a/lib/bridgedb/test/test_https.py b/lib/bridgedb/test/test_https.py
index 4ffbe08..cad0715 100644
--- a/lib/bridgedb/test/test_https.py
+++ b/lib/bridgedb/test/test_https.py
@@ -33,147 +33,147 @@ CAPTCHA_RESPONSE = 'Tvx74Pmy'
 
 class HTTPTests(unittest.TestCase):
     def setUp(self):
-	self.br = None
+        self.br = None
 
     def tearDown(self):
-	self.br = None
+        self.br = None
 
     def openBrowser(self):
-	# use mechanize to open the BridgeDB website in its browser
-	self.br = mechanize.Browser()
-	self.br.set_handle_robots(False) # prevents 'HTTP Error 403: request disallowed by robots.txt'
-	self.br.open(HTTPS_ROOT)
-
-	# -------------- Home/Root  page
-	self.assertTrue(self.br.viewing_html())
-	self.assertEquals(self.br.response().geturl(), HTTPS_ROOT)
-	self.assertEquals(self.br.title(), "BridgeDB")
-	#for link in self.br.links(): print(link)
-	#for form in self.br.forms(): print(form)
-	return self.br
+        # use mechanize to open the BridgeDB website in its browser
+        self.br = mechanize.Browser()
+        self.br.set_handle_robots(False) # prevents 'HTTP Error 403: request disallowed by robots.txt'
+        self.br.open(HTTPS_ROOT)
+
+        # -------------- Home/Root  page
+        self.assertTrue(self.br.viewing_html())
+        self.assertEquals(self.br.response().geturl(), HTTPS_ROOT)
+        self.assertEquals(self.br.title(), "BridgeDB")
+        #for link in self.br.links(): print(link)
+        #for form in self.br.forms(): print(form)
+        return self.br
 
     def goToOptionsPage(self):
         # check that we are on the root page
-	self.assertTrue(self.br.viewing_html())
-	self.assertEquals(self.br.response().geturl(), HTTPS_ROOT)
-
-	# follow the link with the word 'bridges' in it.
-	# Could also use: text='bridges'
-	# Could also use: url='/options'
-	self.br.follow_link(text_regex='bridges')
-
-	# ------------- Options
-	self.assertEquals(self.br.response().geturl(), HTTPS_ROOT + "/options")
-	#print(self.br.response().read())
-	#for form in self.br.forms(): print(form)
-	return self.br
-     
+        self.assertTrue(self.br.viewing_html())
+        self.assertEquals(self.br.response().geturl(), HTTPS_ROOT)
+
+        # follow the link with the word 'bridges' in it.
+        # Could also use: text='bridges'
+        # Could also use: url='/options'
+        self.br.follow_link(text_regex='bridges')
+
+        # ------------- Options
+        self.assertEquals(self.br.response().geturl(), HTTPS_ROOT + "/options")
+        #print(self.br.response().read())
+        #for form in self.br.forms(): print(form)
+        return self.br
+
     def submitOptions(self, transport, ipv6, captchaResponse):
-	# check that we are on the options page
-	self.assertEquals(self.br.response().geturl(), HTTPS_ROOT + "/options")
-
-	# At this point, we'd like to be able to set some values in
-	# the 'advancedOptions' form. Unfortunately the HTML form
-	# does not define a 'name' attribute, so the we have to rely on
-	# the fact that this is the only form on the page and will therefore
-	# always exist at index 0.
-	#br.select_form(name="advancedOptions")
-	self.br.select_form(nr=0)
-
-	# change the pluggable transport to something else 
-	#print(self.br.form)
-	self.br.form['transport'] = [transport]
+        # check that we are on the options page
+        self.assertEquals(self.br.response().geturl(), HTTPS_ROOT + "/options")
+
+        # At this point, we'd like to be able to set some values in
+        # the 'advancedOptions' form. Unfortunately the HTML form
+        # does not define a 'name' attribute, so the we have to rely on
+        # the fact that this is the only form on the page and will therefore
+        # always exist at index 0.
+        #br.select_form(name="advancedOptions")
+        self.br.select_form(nr=0)
+
+        # change the pluggable transport to something else
+        #print(self.br.form)
+        self.br.form['transport'] = [transport]
         if ipv6:
             self.br.form['ipv6'] = ['yes']
-	self.br.submit()
+        self.br.submit()
 
-	# ------------- Captcha
-	EXPECTED_URL = HTTPS_ROOT + "/bridges?transport=%s" % transport
+        # ------------- Captcha
+        EXPECTED_URL = HTTPS_ROOT + "/bridges?transport=%s" % transport
         if ipv6:
             EXPECTED_URL += "&ipv6=yes"
-	self.assertEquals(self.br.response().geturl(), EXPECTED_URL)
-	#print(self.br.response().read())
-	#for form in self.br.forms(): print(form)
-
-	# As on the previous page, the form does not define a 'name' attribute, forcing 
-	# us to use the index of the form i.e. 0
-	#self.br.select_form(name="captchaSubmission")
-	self.br.select_form(nr=0)
-
-	# input the required captcha response. There is only one captcha defined
-	# by default, so this should always be accepted. Note this will not be possible
-	# to automate if used with a real captcha systems (e.g. reCAPTCHA)
-	#self.br.form['captcha_response_field'] = 'Tvx74PMy'
-	self.br.form['captcha_response_field'] = captchaResponse
-	captcha_response = self.br.submit()
-
-	# ------------- Results
-	# URL should be the same as last time
-	self.assertEquals(self.br.response().geturl(), EXPECTED_URL)
-	soup = BeautifulSoup(captcha_response.read())
-	#print soup.prettify()
-	return soup
+        self.assertEquals(self.br.response().geturl(), EXPECTED_URL)
+        #print(self.br.response().read())
+        #for form in self.br.forms(): print(form)
+
+        # As on the previous page, the form does not define a 'name' attribute, forcing
+        # us to use the index of the form i.e. 0
+        #self.br.select_form(name="captchaSubmission")
+        self.br.select_form(nr=0)
+
+        # input the required captcha response. There is only one captcha defined
+        # by default, so this should always be accepted. Note this will not be possible
+        # to automate if used with a real captcha systems (e.g. reCAPTCHA)
+        #self.br.form['captcha_response_field'] = 'Tvx74PMy'
+        self.br.form['captcha_response_field'] = captchaResponse
+        captcha_response = self.br.submit()
+
+        # ------------- Results
+        # URL should be the same as last time
+        self.assertEquals(self.br.response().geturl(), EXPECTED_URL)
+        soup = BeautifulSoup(captcha_response.read())
+        #print soup.prettify()
+        return soup
 
     def getBridgeLinesFromSoup(self, soup, fieldsPerBridge):
-	# Now we're looking for something like this in the response:
-	#     <div class="bridge-lines">
-	#      obfs2 175.213.252.207:11125 5c6da7d927460317c6ff5420b75c2d0f431f18dd
-	#     </div>
-	bridges = []
-	bridge_lines = soup.findAll(attrs={'class' : 'bridge-lines'})
-	self.assertTrue(len(bridge_lines) > 0, "Found no bridge lines")
-	for bridge_line in bridge_lines:
-	    text = bridge_line.text
-	    #print("Found bridge-line: %s" % text)
-	    items = text.split(' ')
-   	    self.assertEquals(len(items), fieldsPerBridge, "Expected %d fields in bridge line %s" % (fieldsPerBridge, str(items)))
-	    bridges.append(items)
-	return bridges
+        # Now we're looking for something like this in the response:
+        #     <div class="bridge-lines">
+        #      obfs2 175.213.252.207:11125 5c6da7d927460317c6ff5420b75c2d0f431f18dd
+        #     </div>
+        bridges = []
+        bridge_lines = soup.findAll(attrs={'class' : 'bridge-lines'})
+        self.assertTrue(len(bridge_lines) > 0, "Found no bridge lines")
+        for bridge_line in bridge_lines:
+            text = bridge_line.text
+            #print("Found bridge-line: %s" % text)
+            items = text.split(' ')
+            self.assertEquals(len(items), fieldsPerBridge, "Expected %d fields in bridge line %s" % (fieldsPerBridge, str(items)))
+            bridges.append(items)
+        return bridges
 
     def test_get_obfs2_ipv4(self):
-	self.openBrowser()
-	self.goToOptionsPage()
+        self.openBrowser()
+        self.goToOptionsPage()
 
-	PT = 'obfs2'
+        PT = 'obfs2'
         soup = self.submitOptions(transport=PT, ipv6=False, captchaResponse=CAPTCHA_RESPONSE)
 
-	bridges = self.getBridgeLinesFromSoup(soup, fieldsPerBridge=3)
+        bridges = self.getBridgeLinesFromSoup(soup, fieldsPerBridge=3)
         for pt, bridge, fingerprint in bridges:
-	    self.assertEquals(PT, pt)
+            self.assertEquals(PT, pt)
 
     def test_get_obfs3_ipv4(self):
-	self.openBrowser()
-	self.goToOptionsPage()
+        self.openBrowser()
+        self.goToOptionsPage()
 
-	PT = 'obfs3'
+        PT = 'obfs3'
         soup = self.submitOptions(transport=PT, ipv6=False, captchaResponse=CAPTCHA_RESPONSE)
 
-	bridges = self.getBridgeLinesFromSoup(soup, fieldsPerBridge=3)
+        bridges = self.getBridgeLinesFromSoup(soup, fieldsPerBridge=3)
         for pt, bridge, fingerprint in bridges:
-	    self.assertEquals(PT, pt)
+            self.assertEquals(PT, pt)
 
     def test_get_vanilla_ipv4(self):
-	self.openBrowser()
-	self.goToOptionsPage()
+        self.openBrowser()
+        self.goToOptionsPage()
 
-	PT = '0'
+        PT = '0'
         soup = self.submitOptions(transport=PT, ipv6=False, captchaResponse=CAPTCHA_RESPONSE)
 
-	bridges = self.getBridgeLinesFromSoup(soup, fieldsPerBridge=2)
-	for bridge, fingerprint in bridges:
+        bridges = self.getBridgeLinesFromSoup(soup, fieldsPerBridge=2)
+        for bridge, fingerprint in bridges:
            # TODO: do more interesting checks
-	   self.assertTrue(bridge != None) 
+           self.assertTrue(bridge != None)
 
     def test_get_scramblesuit_ipv4(self):
-	self.openBrowser()
-	self.goToOptionsPage()
+        self.openBrowser()
+        self.goToOptionsPage()
 
-	PT = 'scramblesuit'
-	soup = self.submitOptions(transport=PT, ipv6=False, captchaResponse=CAPTCHA_RESPONSE)
+        PT = 'scramblesuit'
+        soup = self.submitOptions(transport=PT, ipv6=False, captchaResponse=CAPTCHA_RESPONSE)
 
-	bridges = self.getBridgeLinesFromSoup(soup, fieldsPerBridge=4)
-	for pt, bridge, fingerprint, password in bridges:
-	    self.assertEquals(PT, pt)
-	    self.assertTrue(password.find("password=") != -1, "Password field missing expected text")
+        bridges = self.getBridgeLinesFromSoup(soup, fieldsPerBridge=4)
+        for pt, bridge, fingerprint, password in bridges:
+            self.assertEquals(PT, pt)
+            self.assertTrue(password.find("password=") != -1, "Password field missing expected text")
 
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits