incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [19/32] PEP8 cleanup
Date Fri, 10 Jan 2014 18:19:43 GMT
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/Allura/allura/tests/functional/test_auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_auth.py b/Allura/allura/tests/functional/test_auth.py
index 5ac17c6..d9362d4 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -22,13 +22,13 @@ from urlparse import urlparse, parse_qs
 
 import mock
 from nose.tools import (
-        assert_equal,
-        assert_not_equal,
-        assert_is_none,
-        assert_is_not_none,
-        assert_in,
-        assert_true
-    )
+    assert_equal,
+    assert_not_equal,
+    assert_is_none,
+    assert_is_not_none,
+    assert_in,
+    assert_true
+)
 from pylons import tmpl_context as c
 from allura.tests import TestController
 from allura.tests import decorators as td
@@ -46,72 +46,77 @@ from pylons import request
 def unentity(s):
     return s.replace('"', '"')
 
+
 class TestAuth(TestController):
 
     def test_login(self):
         result = self.app.get('/auth/')
-        r = self.app.post('/auth/send_verification_link', params=dict(a='test@example.com'))
+        r = self.app.post('/auth/send_verification_link',
+                          params=dict(a='test@example.com'))
         email = M.User.query.get(username='test-admin').email_addresses[0]
         r = self.app.post('/auth/send_verification_link', params=dict(a=email))
         ThreadLocalORMSession.flush_all()
         r = self.app.get('/auth/verify_addr', params=dict(a='foo'))
-        assert json.loads(self.webflash(r))['status'] == 'error', self.webflash(r)
+        assert json.loads(self.webflash(r))[
+            'status'] == 'error', self.webflash(r)
         ea = M.EmailAddress.query.find().first()
         r = self.app.get('/auth/verify_addr', params=dict(a=ea.nonce))
         assert json.loads(self.webflash(r))['status'] == 'ok', self.webflash(r)
         r = self.app.get('/auth/logout')
         r = self.app.post('/auth/do_login', params=dict(
-                username='test-user', password='foo'))
+            username='test-user', password='foo'))
         r = self.app.post('/auth/do_login', params=dict(
-                username='test-user', password='food'))
+            username='test-user', password='food'))
         assert 'Invalid login' in str(r), r.showbrowser()
         r = self.app.post('/auth/do_login', params=dict(
-                username='test-usera', password='foo'))
+            username='test-usera', password='foo'))
         assert 'Invalid login' in str(r), r.showbrowser()
 
     @td.with_user_project('test-admin')
     def test_prefs(self):
-        r = self.app.get('/auth/preferences/', extra_environ=dict(username='test-admin'))
+        r = self.app.get('/auth/preferences/',
+                         extra_environ=dict(username='test-admin'))
         assert 'test@example.com' not in r
         r = self.app.post('/auth/preferences/update', params={
-                 'preferences.display_name':'Test Admin',
-                 'new_addr.addr':'test@example.com',
-                 'new_addr.claim':'Claim Address',
-                 'primary_addr':'test-admin@users.localhost',
-                 'preferences.email_format':'plain'},
-                extra_environ=dict(username='test-admin'))
+            'preferences.display_name': 'Test Admin',
+            'new_addr.addr': 'test@example.com',
+            'new_addr.claim': 'Claim Address',
+            'primary_addr': 'test-admin@users.localhost',
+            'preferences.email_format': 'plain'},
+            extra_environ=dict(username='test-admin'))
         r = self.app.get('/auth/preferences/')
         assert 'test@example.com' in r
         r = self.app.post('/auth/preferences/update', params={
-                 'preferences.display_name':'Test Admin',
-                 'addr-1.ord':'1',
-                 'addr-2.ord':'1',
-                 'addr-2.delete':'on',
-                 'new_addr.addr':'',
-                 'primary_addr':'test-admin@users.localhost',
-                 'preferences.email_format':'plain'},
-                extra_environ=dict(username='test-admin'))
+            'preferences.display_name': 'Test Admin',
+            'addr-1.ord': '1',
+            'addr-2.ord': '1',
+            'addr-2.delete': 'on',
+            'new_addr.addr': '',
+            'primary_addr': 'test-admin@users.localhost',
+            'preferences.email_format': 'plain'},
+            extra_environ=dict(username='test-admin'))
         r = self.app.get('/auth/preferences/')
         assert 'test@example.com' not in r
         ea = M.EmailAddress.query.get(_id='test-admin@users.localhost')
         ea.confirmed = True
         ThreadLocalORMSession.flush_all()
         r = self.app.post('/auth/preferences/update', params={
-                 'preferences.display_name':'Test Admin',
-                 'new_addr.addr':'test-admin@users.localhost',
-                 'new_addr.claim':'Claim Address',
-                 'primary_addr':'test-admin@users.localhost',
-                 'preferences.email_format':'plain'},
-                extra_environ=dict(username='test-admin'))
+            'preferences.display_name': 'Test Admin',
+            'new_addr.addr': 'test-admin@users.localhost',
+            'new_addr.claim': 'Claim Address',
+            'primary_addr': 'test-admin@users.localhost',
+            'preferences.email_format': 'plain'},
+            extra_environ=dict(username='test-admin'))
 
     @td.with_user_project('test-admin')
     def test_prefs_subscriptions(self):
         r = self.app.get('/auth/subscriptions/',
-                extra_environ=dict(username='test-admin'))
+                         extra_environ=dict(username='test-admin'))
         subscriptions = M.Mailbox.query.find(dict(
             user_id=c.user._id, is_flash=False)).all()
         # make sure page actually lists all the user's subscriptions
-        assert len(subscriptions) > 0, 'Test user has no subscriptions, cannot verify that they are shown'
+        assert len(
+            subscriptions) > 0, 'Test user has no subscriptions, cannot verify that they are shown'
         for m in subscriptions:
             assert m._id in r, "Page doesn't list subscription for Mailbox._id = %s" % m._id
 
@@ -130,7 +135,7 @@ class TestAuth(TestController):
         for f in r.forms.itervalues():
             if f.action == 'update_subscriptions':
                 form = f
-                break;
+                break
         assert form is not None, "Can't find subscriptions form"
         return form
 
@@ -149,7 +154,7 @@ class TestAuth(TestController):
     @td.with_user_project('test-admin')
     def test_prefs_subscriptions_subscribe(self):
         resp = self.app.get('/auth/subscriptions/',
-                extra_environ=dict(username='test-admin'))
+                            extra_environ=dict(username='test-admin'))
         form = self._find_subscriptions_form(resp)
         # find not subscribed tool, subscribe and verify
         field_name = self._find_subscriptions_field(form, subscribed=False)
@@ -165,7 +170,7 @@ class TestAuth(TestController):
     @td.with_user_project('test-admin')
     def test_prefs_subscriptions_unsubscribe(self):
         resp = self.app.get('/auth/subscriptions/',
-                extra_environ=dict(username='test-admin'))
+                            extra_environ=dict(username='test-admin'))
         form = self._find_subscriptions_form(resp)
         field_name = self._find_subscriptions_field(form, subscribed=True)
         s_id = ObjectId(form.fields[field_name + '.subscription_id'][0].value)
@@ -177,59 +182,62 @@ class TestAuth(TestController):
         assert not s, "User still has subscription with Mailbox._id %s" % s_id
 
     def test_format_email(self):
-        self.app.post('/auth/subscriptions/update_subscriptions', params={'email_format': 'html', 'subscriptions': ''})
+        self.app.post('/auth/subscriptions/update_subscriptions',
+                      params={'email_format': 'html', 'subscriptions': ''})
         r = self.app.get('/auth/subscriptions/')
         assert '<option selected value="html">HTML</option>' in r
-        self.app.post('/auth/subscriptions/update_subscriptions', params={'email_format': 'plain', 'subscriptions': ''})
+        self.app.post('/auth/subscriptions/update_subscriptions',
+                      params={'email_format': 'plain', 'subscriptions': ''})
         r = self.app.get('/auth/subscriptions/')
         assert '<option selected value="plain">Plain Text</option>' in r
-        self.app.post('/auth/subscriptions/update_subscriptions', params={'email_format': 'both', 'subscriptions': ''})
+        self.app.post('/auth/subscriptions/update_subscriptions',
+                      params={'email_format': 'both', 'subscriptions': ''})
         r = self.app.get('/auth/subscriptions/')
         assert '<option selected value="both">Combined</option>' in r
 
     def test_api_key(self):
-         r = self.app.get('/auth/preferences/')
-         assert 'No API token generated' in r
-         r = self.app.post('/auth/preferences/gen_api_token', status=302)
-         r = self.app.get('/auth/preferences/')
-         assert 'No API token generated' not in r
-         assert 'API Key:' in r
-         assert 'Secret Key:' in r
-         r = self.app.post('/auth/preferences/del_api_token', status=302)
-         r = self.app.get('/auth/preferences/')
-         assert 'No API token generated' in r
+        r = self.app.get('/auth/preferences/')
+        assert 'No API token generated' in r
+        r = self.app.post('/auth/preferences/gen_api_token', status=302)
+        r = self.app.get('/auth/preferences/')
+        assert 'No API token generated' not in r
+        assert 'API Key:' in r
+        assert 'Secret Key:' in r
+        r = self.app.post('/auth/preferences/del_api_token', status=302)
+        r = self.app.get('/auth/preferences/')
+        assert 'No API token generated' in r
 
     @mock.patch('allura.controllers.auth.verify_oid')
     def test_login_verify_oid_with_provider(self, verify_oid):
         verify_oid.return_value = dict()
         result = self.app.get('/auth/login_verify_oid', params=dict(
-                provider='http://www.google.com/accounts/o8/id', username='rick446@usa.net'),
-                status=200)
+            provider='http://www.google.com/accounts/o8/id', username='rick446@usa.net'),
+            status=200)
         verify_oid.assert_called_with('http://www.google.com/accounts/o8/id',
-                failure_redirect='.',
-                return_to='login_process_oid?return_to=None',
-                title='OpenID Login',
-                prompt='Click below to continue');
+                                      failure_redirect='.',
+                                      return_to='login_process_oid?return_to=None',
+                                      title='OpenID Login',
+                                      prompt='Click below to continue')
 
     @mock.patch('allura.controllers.auth.verify_oid')
     def test_login_verify_oid_without_provider(self, verify_oid):
         verify_oid.return_value = dict()
         result = self.app.get('/auth/login_verify_oid', params=dict(
-                provider='', username='rick446@usa.net'),
-                status=200)
+            provider='', username='rick446@usa.net'),
+            status=200)
         verify_oid.assert_called_with('rick446@usa.net',
-                failure_redirect='.',
-                return_to='login_process_oid?return_to=None',
-                title='OpenID Login',
-                prompt='Click below to continue');
+                                      failure_redirect='.',
+                                      return_to='login_process_oid?return_to=None',
+                                      title='OpenID Login',
+                                      prompt='Click below to continue')
 
     @mock.patch('allura.lib.oid_helper.consumer.Consumer')
     def test_login_verify_oid_good_provider_no_redirect(self, Consumer):
         Consumer().begin().shouldSendRedirect.return_value = False
         Consumer().begin().formMarkup.return_value = "<!-- I'm a mock object! -->"
         result = self.app.get('/auth/login_verify_oid', params=dict(
-                provider='http://www.google.com/accounts/o8/id', username='rick446@usa.net'),
-                status=200)
+            provider='http://www.google.com/accounts/o8/id', username='rick446@usa.net'),
+            status=200)
         flash = self.webflash(result)
         assert_equal(flash, '')
 
@@ -238,18 +246,19 @@ class TestAuth(TestController):
         Consumer().begin().shouldSendRedirect.return_value = True
         Consumer().begin().redirectURL.return_value = 'http://some.url/'
         result = self.app.get('/auth/login_verify_oid', params=dict(
-                provider='http://www.google.com/accounts/o8/id', username='rick446@usa.net'),
-                status=302)
+            provider='http://www.google.com/accounts/o8/id', username='rick446@usa.net'),
+            status=302)
         assert_equal(result.headers['Location'], 'http://some.url/')
         flash = self.webflash(result)
         assert_equal(flash, '')
 
     @mock.patch('allura.lib.oid_helper.consumer.Consumer')
     def test_login_verify_oid_bad_provider(self, Consumer):
-        Consumer().begin.side_effect = oid_helper.consumer.DiscoveryFailure('bad', mock.Mock('response'))
+        Consumer().begin.side_effect = oid_helper.consumer.DiscoveryFailure(
+            'bad', mock.Mock('response'))
         result = self.app.get('/auth/login_verify_oid', params=dict(
-                provider='http://www.google.com/accounts/', username='rick446@usa.net'),
-                              status=302)
+            provider='http://www.google.com/accounts/', username='rick446@usa.net'),
+            status=302)
         flash = self.webflash(result)
         assert_equal(flash, '{"status": "error", "message": "bad"}')
 
@@ -257,42 +266,43 @@ class TestAuth(TestController):
     def test_login_verify_oid_bad_provider2(self, Consumer):
         Consumer().begin.return_value = None
         result = self.app.get('/auth/login_verify_oid', params=dict(
-                provider='http://www.google.com/accounts/', username='rick446@usa.net'),
-                              status=302)
+            provider='http://www.google.com/accounts/', username='rick446@usa.net'),
+            status=302)
         flash = self.webflash(result)
-        assert_equal(flash, '{"status": "error", "message": "No openid services found for <code>http://www.google.com/accounts/</code>"}')
+        assert_equal(
+            flash, '{"status": "error", "message": "No openid services found for <code>http://www.google.com/accounts/</code>"}')
 
     @mock.patch('allura.controllers.auth.verify_oid')
     def test_claim_verify_oid_with_provider(self, verify_oid):
         verify_oid.return_value = dict()
         result = self.app.get('/auth/claim_verify_oid', params=dict(
-                provider='http://www.google.com/accounts/o8/id', username='rick446@usa.net'),
-                status=200)
+            provider='http://www.google.com/accounts/o8/id', username='rick446@usa.net'),
+            status=200)
         verify_oid.assert_called_with('http://www.google.com/accounts/o8/id',
-                failure_redirect='claim_oid',
-                return_to='claim_process_oid',
-                title='Claim OpenID',
-                prompt='Click below to continue');
+                                      failure_redirect='claim_oid',
+                                      return_to='claim_process_oid',
+                                      title='Claim OpenID',
+                                      prompt='Click below to continue')
 
     @mock.patch('allura.controllers.auth.verify_oid')
     def test_claim_verify_oid_without_provider(self, verify_oid):
         verify_oid.return_value = dict()
         result = self.app.get('/auth/claim_verify_oid', params=dict(
-                provider='', username='rick446@usa.net'),
-                status=200)
+            provider='', username='rick446@usa.net'),
+            status=200)
         verify_oid.assert_called_with('rick446@usa.net',
-                failure_redirect='claim_oid',
-                return_to='claim_process_oid',
-                title='Claim OpenID',
-                prompt='Click below to continue');
+                                      failure_redirect='claim_oid',
+                                      return_to='claim_process_oid',
+                                      title='Claim OpenID',
+                                      prompt='Click below to continue')
 
     @mock.patch('allura.lib.oid_helper.consumer.Consumer')
     def test_claim_verify_oid_good_provider_no_redirect(self, Consumer):
         Consumer().begin().shouldSendRedirect.return_value = False
         Consumer().begin().formMarkup.return_value = "<!-- I'm a mock object! -->"
         result = self.app.get('/auth/claim_verify_oid', params=dict(
-                provider='http://www.google.com/accounts/o8/id', username='rick446@usa.net'),
-                status=200)
+            provider='http://www.google.com/accounts/o8/id', username='rick446@usa.net'),
+            status=200)
         flash = self.webflash(result)
         assert_equal(flash, '')
 
@@ -301,18 +311,19 @@ class TestAuth(TestController):
         Consumer().begin().shouldSendRedirect.return_value = True
         Consumer().begin().redirectURL.return_value = 'http://some.url/'
         result = self.app.get('/auth/claim_verify_oid', params=dict(
-                provider='http://www.google.com/accounts/o8/id', username='rick446@usa.net'),
-                status=302)
+            provider='http://www.google.com/accounts/o8/id', username='rick446@usa.net'),
+            status=302)
         assert_equal(result.headers['Location'], 'http://some.url/')
         flash = self.webflash(result)
         assert_equal(flash, '')
 
     @mock.patch('allura.lib.oid_helper.consumer.Consumer')
     def test_claim_verify_oid_bad_provider(self, Consumer):
-        Consumer().begin.side_effect = oid_helper.consumer.DiscoveryFailure('bad', mock.Mock('response'))
+        Consumer().begin.side_effect = oid_helper.consumer.DiscoveryFailure(
+            'bad', mock.Mock('response'))
         result = self.app.get('/auth/claim_verify_oid', params=dict(
-                provider='http://www.google.com/accounts/', username='rick446@usa.net'),
-                              status=302)
+            provider='http://www.google.com/accounts/', username='rick446@usa.net'),
+            status=302)
         flash = self.webflash(result)
         assert_equal(flash, '{"status": "error", "message": "bad"}')
 
@@ -320,36 +331,41 @@ class TestAuth(TestController):
     def test_claim_verify_oid_bad_provider2(self, Consumer):
         Consumer().begin.return_value = None
         result = self.app.get('/auth/claim_verify_oid', params=dict(
-                provider='http://www.google.com/accounts/', username='rick446@usa.net'),
-                              status=302)
+            provider='http://www.google.com/accounts/', username='rick446@usa.net'),
+            status=302)
         flash = self.webflash(result)
-        assert_equal(flash, '{"status": "error", "message": "No openid services found for <code>http://www.google.com/accounts/</code>"}')
+        assert_equal(
+            flash, '{"status": "error", "message": "No openid services found for <code>http://www.google.com/accounts/</code>"}')
 
     def test_setup_openid_user_current_user(self):
         r = self.app.get('/auth/setup_openid_user')
         r = self.app.post('/auth/do_setup_openid_user', params=dict(
-                username='test-admin', display_name='Test Admin'))
+            username='test-admin', display_name='Test Admin'))
         flash = self.webflash(r)
-        assert_equal(flash, '{"status": "ok", "message": "Your username has been set to test-admin."}')
+        assert_equal(
+            flash, '{"status": "ok", "message": "Your username has been set to test-admin."}')
 
     def test_setup_openid_user_taken_user(self):
         r = self.app.get('/auth/setup_openid_user')
         r = self.app.post('/auth/do_setup_openid_user', params=dict(
-                username='test-user', display_name='Test User'))
+            username='test-user', display_name='Test User'))
         flash = self.webflash(r)
-        assert_equal(flash, '{"status": "error", "message": "That username is already taken.  Please choose another."}')
+        assert_equal(
+            flash, '{"status": "error", "message": "That username is already taken.  Please choose another."}')
 
     def test_setup_openid_user_new_user(self):
         r = self.app.get('/auth/setup_openid_user')
         r = self.app.post('/auth/do_setup_openid_user', params=dict(
-                username='test-alkajs', display_name='Test Alkajs'))
+            username='test-alkajs', display_name='Test Alkajs'))
         flash = self.webflash(r)
-        assert_equal(flash, '{"status": "ok", "message": "Your username has been set to test-alkajs."}')
+        assert_equal(
+            flash, '{"status": "ok", "message": "Your username has been set to test-alkajs."}')
 
     def test_create_account(self):
         r = self.app.get('/auth/create_account')
         assert 'Create an Account' in r
-        r = self.app.post('/auth/save_new', params=dict(username='aaa',pw='123'))
+        r = self.app.post('/auth/save_new',
+                          params=dict(username='aaa', pw='123'))
         assert 'Enter a value 8 characters long or more' in r
         r = self.app.post(
             '/auth/save_new',
@@ -381,14 +397,17 @@ class TestAuth(TestController):
         p_nbhd = M.Neighborhood.query.get(name='Projects')
         p = M.Project.query.get(shortname='test', neighborhood_id=p_nbhd._id)
         self.app.post('/auth/save_new', params=dict(
-                username='aaa',
-                pw='12345678',
-                pw2='12345678',
-                display_name='Test Me')).follow()
+            username='aaa',
+            pw='12345678',
+            pw2='12345678',
+            display_name='Test Me')).follow()
         user = M.User.query.get(username='aaa')
-        assert M.ProjectRole.query.find(dict(user_id=user._id, project_id=p._id)).count() == 0
-        r = self.app.get('/p/test/admin/permissions',extra_environ=dict(username='aaa'), status=403)
-        assert M.ProjectRole.query.find(dict(user_id=user._id, project_id=p._id)).count() <= 1
+        assert M.ProjectRole.query.find(
+            dict(user_id=user._id, project_id=p._id)).count() == 0
+        r = self.app.get('/p/test/admin/permissions',
+                         extra_environ=dict(username='aaa'), status=403)
+        assert M.ProjectRole.query.find(
+            dict(user_id=user._id, project_id=p._id)).count() <= 1
 
     def test_default_lookup(self):
         # Make sure that default _lookup() throws 404
@@ -398,16 +417,19 @@ class TestAuth(TestController):
         user = M.User.query.get(username='test-admin')
         sess = session(user)
         assert not user.disabled
-        r = self.app.get('/p/test/admin/', extra_environ={'username':'test-admin'})
+        r = self.app.get('/p/test/admin/',
+                         extra_environ={'username': 'test-admin'})
         assert_equal(r.status_int, 200, 'Redirect to %s' % r.location)
         user.disabled = True
         sess.save(user)
         sess.flush()
         user = M.User.query.get(username='test-admin')
         assert user.disabled
-        r = self.app.get('/p/test/admin/', extra_environ={'username':'test-admin'})
+        r = self.app.get('/p/test/admin/',
+                         extra_environ={'username': 'test-admin'})
         assert_equal(r.status_int, 302)
-        assert_equal(r.location, 'http://localhost/auth/?return_to=%2Fp%2Ftest%2Fadmin%2F')
+        assert_equal(r.location,
+                     'http://localhost/auth/?return_to=%2Fp%2Ftest%2Fadmin%2F')
 
 
 class TestPreferences(TestController):
@@ -419,14 +441,14 @@ class TestPreferences(TestController):
             ('Male', '19/08/1988', 'IT', 'Milan', 'Europe/Rome')
         result = self.app.get('/auth/user_info/')
 
-        #Check if personal data is properly set
+        # Check if personal data is properly set
         r = self.app.post('/auth/user_info/change_personal_data',
-             params=dict(
-                 sex=setsex,
-                 birthdate=setbirthdate,
-                 country=setcountry,
-                 city=setcity,
-                 timezone=settimezone))
+                          params=dict(
+                              sex=setsex,
+                              birthdate=setbirthdate,
+                              country=setcountry,
+                              city=setcity,
+                              timezone=settimezone))
         user = M.User.query.get(username='test-admin')
         sex = user.sex
         assert sex == setsex
@@ -439,9 +461,9 @@ class TestPreferences(TestController):
         timezone = user.timezone
         assert timezone == settimezone
 
-        #Check if setting a wrong date everything works correctly
+        # Check if setting a wrong date everything works correctly
         r = self.app.post('/auth/user_info/change_personal_data',
-             params=dict(birthdate='30/02/1998'))
+                          params=dict(birthdate='30/02/1998'))
         assert 'Please enter a valid date' in str(r)
         user = M.User.query.get(username='test-admin')
         sex = user.sex
@@ -455,108 +477,114 @@ class TestPreferences(TestController):
         timezone = user.timezone
         assert timezone == settimezone
 
-        #Check deleting birthdate
+        # Check deleting birthdate
         r = self.app.post('/auth/user_info/change_personal_data',
-             params=dict(
-                 sex=setsex,
-                 birthdate='',
-                 country=setcountry,
-                 city=setcity,
-                 timezone=settimezone))
+                          params=dict(
+                              sex=setsex,
+                              birthdate='',
+                              country=setcountry,
+                              city=setcity,
+                              timezone=settimezone))
         user = M.User.query.get(username='test-admin')
         assert user.birthdate is None
 
     @td.with_user_project('test-admin')
     def test_contacts(self):
-        #Add skype account
+        # Add skype account
         testvalue = 'testaccount'
         result = self.app.get('/auth/user_info/contacts/')
         r = self.app.post('/auth/user_info/contacts/skype_account',
-             params=dict(skypeaccount=testvalue))
+                          params=dict(skypeaccount=testvalue))
         user = M.User.query.get(username='test-admin')
         assert user.skypeaccount == testvalue
 
-        #Add social network account
+        # Add social network account
         socialnetwork = 'Facebook'
         accounturl = 'http://www.facebook.com/test'
         r = self.app.post('/auth/user_info/contacts/add_social_network',
-             params=dict(socialnetwork=socialnetwork,
-                         accounturl = accounturl))
+                          params=dict(socialnetwork=socialnetwork,
+                                      accounturl=accounturl))
         user = M.User.query.get(username='test-admin')
         assert len(user.socialnetworks) == 1 and \
-               user.socialnetworks[0].socialnetwork == socialnetwork and \
-               user.socialnetworks[0].accounturl == accounturl
+            user.socialnetworks[0].socialnetwork == socialnetwork and \
+            user.socialnetworks[0].accounturl == accounturl
 
-        #Add second social network account
+        # Add second social network account
         socialnetwork2 = 'Twitter'
         accounturl2 = 'http://twitter.com/test'
         r = self.app.post('/auth/user_info/contacts/add_social_network',
-             params=dict(socialnetwork=socialnetwork2,
-                         accounturl = '@test'))
+                          params=dict(socialnetwork=socialnetwork2,
+                                      accounturl='@test'))
         user = M.User.query.get(username='test-admin')
         assert len(user.socialnetworks) == 2 and \
-               ({'socialnetwork':socialnetwork, 'accounturl':accounturl} in user.socialnetworks and \
-                {'socialnetwork':socialnetwork2, 'accounturl':accounturl2} in user.socialnetworks)
+            ({'socialnetwork': socialnetwork, 'accounturl': accounturl} in user.socialnetworks and
+             {'socialnetwork': socialnetwork2, 'accounturl': accounturl2} in user.socialnetworks)
 
-        #Remove first social network account
+        # Remove first social network account
         r = self.app.post('/auth/user_info/contacts/remove_social_network',
-             params=dict(socialnetwork=socialnetwork,
-                         account = accounturl))
+                          params=dict(socialnetwork=socialnetwork,
+                                      account=accounturl))
         user = M.User.query.get(username='test-admin')
         assert len(user.socialnetworks) == 1 and \
-               {'socialnetwork':socialnetwork2, 'accounturl':accounturl2} in user.socialnetworks
+            {'socialnetwork': socialnetwork2, 'accounturl':
+             accounturl2} in user.socialnetworks
 
-        #Add empty social network account
+        # Add empty social network account
         r = self.app.post('/auth/user_info/contacts/add_social_network',
-             params=dict(accounturl = accounturl, socialnetwork=''))
+                          params=dict(accounturl=accounturl, socialnetwork=''))
         user = M.User.query.get(username='test-admin')
         assert len(user.socialnetworks) == 1 and \
-               {'socialnetwork':socialnetwork2, 'accounturl':accounturl2} in user.socialnetworks
+            {'socialnetwork': socialnetwork2, 'accounturl':
+             accounturl2} in user.socialnetworks
 
-        #Add invalid social network account
+        # Add invalid social network account
         r = self.app.post('/auth/user_info/contacts/add_social_network',
-             params=dict(accounturl = accounturl, socialnetwork='invalid'))
+                          params=dict(accounturl=accounturl, socialnetwork='invalid'))
         user = M.User.query.get(username='test-admin')
         assert len(user.socialnetworks) == 1 and \
-               {'socialnetwork':socialnetwork2, 'accounturl':accounturl2} in user.socialnetworks
+            {'socialnetwork': socialnetwork2, 'accounturl':
+             accounturl2} in user.socialnetworks
 
-        #Add telephone number
+        # Add telephone number
         telnumber = '+3902123456'
         r = self.app.post('/auth/user_info/contacts/add_telnumber',
-             params=dict(newnumber=telnumber))
+                          params=dict(newnumber=telnumber))
         user = M.User.query.get(username='test-admin')
-        assert (len(user.telnumbers) == 1 and (user.telnumbers[0] == telnumber))
+        assert (len(user.telnumbers)
+                == 1 and (user.telnumbers[0] == telnumber))
 
-        #Add second telephone number
+        # Add second telephone number
         telnumber2 = '+3902654321'
         r = self.app.post('/auth/user_info/contacts/add_telnumber',
-             params=dict(newnumber=telnumber2))
+                          params=dict(newnumber=telnumber2))
         user = M.User.query.get(username='test-admin')
-        assert (len(user.telnumbers) == 2 and telnumber in user.telnumbers and telnumber2 in user.telnumbers)
+        assert (len(user.telnumbers)
+                == 2 and telnumber in user.telnumbers and telnumber2 in user.telnumbers)
 
-        #Remove first telephone number
+        # Remove first telephone number
         r = self.app.post('/auth/user_info/contacts/remove_telnumber',
-             params=dict(oldvalue=telnumber))
+                          params=dict(oldvalue=telnumber))
         user = M.User.query.get(username='test-admin')
         assert (len(user.telnumbers) == 1 and telnumber2 in user.telnumbers)
 
-        #Add website
+        # Add website
         website = 'http://www.testurl.com'
         r = self.app.post('/auth/user_info/contacts/add_webpage',
-             params=dict(newwebsite=website))
+                          params=dict(newwebsite=website))
         user = M.User.query.get(username='test-admin')
         assert (len(user.webpages) == 1 and (website in user.webpages))
 
-        #Add second website
+        # Add second website
         website2 = 'http://www.testurl2.com'
         r = self.app.post('/auth/user_info/contacts/add_webpage',
-             params=dict(newwebsite=website2))
+                          params=dict(newwebsite=website2))
         user = M.User.query.get(username='test-admin')
-        assert (len(user.webpages) == 2 and website in user.webpages and website2 in user.webpages)
+        assert (len(user.webpages)
+                == 2 and website in user.webpages and website2 in user.webpages)
 
-        #Remove first website
+        # Remove first website
         r = self.app.post('/auth/user_info/contacts/remove_webpage',
-             params=dict(oldvalue=website))
+                          params=dict(oldvalue=website))
         user = M.User.query.get(username='test-admin')
         assert (len(user.webpages) == 1 and website2 in user.webpages)
 
@@ -564,169 +592,187 @@ class TestPreferences(TestController):
     def test_availability(self):
         from datetime import time
 
-        #Add availability timeslot
+        # Add availability timeslot
         weekday = 'Monday'
-        starttime = time(9,0,0)
+        starttime = time(9, 0, 0)
         endtime = time(12, 0, 0)
 
         result = self.app.get('/auth/user_info/availability/')
         r = self.app.post('/auth/user_info/availability/add_timeslot',
-             params=dict(
-                 weekday=weekday,
-                 starttime=starttime.strftime('%H:%M'),
-                 endtime=endtime.strftime('%H:%M')))
+                          params=dict(
+                              weekday=weekday,
+                              starttime=starttime.strftime('%H:%M'),
+                              endtime=endtime.strftime('%H:%M')))
         user = M.User.query.get(username='test-admin')
-        timeslot1dict = dict(week_day=weekday, start_time=starttime, end_time=endtime)
-        assert len(user.availability) == 1 and timeslot1dict in user.get_availability_timeslots()
+        timeslot1dict = dict(
+            week_day=weekday, start_time=starttime, end_time=endtime)
+        assert len(
+            user.availability) == 1 and timeslot1dict in user.get_availability_timeslots()
 
         weekday2 = 'Tuesday'
-        starttime2 = time(14,0,0)
+        starttime2 = time(14, 0, 0)
         endtime2 = time(16, 0, 0)
 
-        #Add second availability timeslot
+        # Add second availability timeslot
         r = self.app.post('/auth/user_info/availability/add_timeslot',
-             params=dict(
-                 weekday=weekday2,
-                 starttime=starttime2.strftime('%H:%M'),
-                 endtime=endtime2.strftime('%H:%M')))
+                          params=dict(
+                              weekday=weekday2,
+                              starttime=starttime2.strftime('%H:%M'),
+                              endtime=endtime2.strftime('%H:%M')))
         user = M.User.query.get(username='test-admin')
-        timeslot2dict = dict(week_day=weekday2, start_time=starttime2, end_time=endtime2)
+        timeslot2dict = dict(week_day=weekday2,
+                             start_time=starttime2, end_time=endtime2)
         assert len(user.availability) == 2 and timeslot1dict in user.get_availability_timeslots() \
-               and timeslot2dict in user.get_availability_timeslots()
+            and timeslot2dict in user.get_availability_timeslots()
 
-        #Remove availability timeslot
+        # Remove availability timeslot
         r = self.app.post('/auth/user_info/availability/remove_timeslot',
-             params=dict(
-                 weekday=weekday,
-                 starttime=starttime.strftime('%H:%M'),
-                 endtime=endtime.strftime('%H:%M')))
+                          params=dict(
+                              weekday=weekday,
+                              starttime=starttime.strftime('%H:%M'),
+                              endtime=endtime.strftime('%H:%M')))
         user = M.User.query.get(username='test-admin')
-        assert len(user.availability) == 1 and timeslot2dict in user.get_availability_timeslots()
+        assert len(
+            user.availability) == 1 and timeslot2dict in user.get_availability_timeslots()
 
-        #Add invalid availability timeslot
+        # Add invalid availability timeslot
         r = self.app.post('/auth/user_info/availability/add_timeslot',
-             params=dict(
-                 weekday=weekday2,
-                 starttime=endtime2.strftime('%H:%M'),
-                 endtime=starttime2.strftime('%H:%M')))
+                          params=dict(
+                              weekday=weekday2,
+                              starttime=endtime2.strftime('%H:%M'),
+                              endtime=starttime2.strftime('%H:%M')))
         assert 'Invalid period:' in str(r)
         user = M.User.query.get(username='test-admin')
-        timeslot2dict = dict(week_day=weekday2, start_time=starttime2, end_time=endtime2)
-        assert len(user.availability) == 1 and timeslot2dict in user.get_availability_timeslots()
+        timeslot2dict = dict(week_day=weekday2,
+                             start_time=starttime2, end_time=endtime2)
+        assert len(
+            user.availability) == 1 and timeslot2dict in user.get_availability_timeslots()
 
     @td.with_user_project('test-admin')
     def test_inactivity(self):
         from datetime import datetime, timedelta
 
-        #Add inactivity period
+        # Add inactivity period
         now = datetime.utcnow().date()
         now = datetime(now.year, now.month, now.day)
         startdate = now + timedelta(days=1)
         enddate = now + timedelta(days=7)
         result = self.app.get('/auth/user_info/availability/')
         r = self.app.post('/auth/user_info/availability/add_inactive_period',
-             params=dict(
-                 startdate=startdate.strftime('%d/%m/%Y'),
-                 enddate=enddate.strftime('%d/%m/%Y')))
+                          params=dict(
+                              startdate=startdate.strftime('%d/%m/%Y'),
+                              enddate=enddate.strftime('%d/%m/%Y')))
         user = M.User.query.get(username='test-admin')
         period1dict = dict(start_date=startdate, end_date=enddate)
-        assert len(user.inactiveperiod) == 1 and period1dict in user.get_inactive_periods()
+        assert len(
+            user.inactiveperiod) == 1 and period1dict in user.get_inactive_periods()
 
-        #Add second inactivity period
-        startdate2 =  now + timedelta(days=24)
+        # Add second inactivity period
+        startdate2 = now + timedelta(days=24)
         enddate2 = now + timedelta(days=28)
         r = self.app.post('/auth/user_info/availability/add_inactive_period',
-             params=dict(
-                 startdate=startdate2.strftime('%d/%m/%Y'),
-                 enddate=enddate2.strftime('%d/%m/%Y')))
+                          params=dict(
+                              startdate=startdate2.strftime('%d/%m/%Y'),
+                              enddate=enddate2.strftime('%d/%m/%Y')))
         user = M.User.query.get(username='test-admin')
         period2dict = dict(start_date=startdate2, end_date=enddate2)
         assert len(user.inactiveperiod) == 2 and period1dict in user.get_inactive_periods() \
-               and period2dict in user.get_inactive_periods()
+            and period2dict in user.get_inactive_periods()
 
-        #Remove first inactivity period
-        r = self.app.post('/auth/user_info/availability/remove_inactive_period',
-             params=dict(
-                 startdate=startdate.strftime('%d/%m/%Y'),
-                 enddate=enddate.strftime('%d/%m/%Y')))
+        # Remove first inactivity period
+        r = self.app.post(
+            '/auth/user_info/availability/remove_inactive_period',
+            params=dict(
+                startdate=startdate.strftime('%d/%m/%Y'),
+                enddate=enddate.strftime('%d/%m/%Y')))
         user = M.User.query.get(username='test-admin')
-        assert len(user.inactiveperiod) == 1 and period2dict in user.get_inactive_periods()
+        assert len(
+            user.inactiveperiod) == 1 and period2dict in user.get_inactive_periods()
 
-        #Add invalid inactivity period
+        # Add invalid inactivity period
         r = self.app.post('/auth/user_info/availability/add_inactive_period',
-             params=dict(
-                 startdate='NOT/A/DATE',
-                 enddate=enddate2.strftime('%d/%m/%Y')))
+                          params=dict(
+                              startdate='NOT/A/DATE',
+                              enddate=enddate2.strftime('%d/%m/%Y')))
         user = M.User.query.get(username='test-admin')
         assert 'Please enter a valid date' in str(r)
-        assert len(user.inactiveperiod) == 1 and period2dict in user.get_inactive_periods()
+        assert len(
+            user.inactiveperiod) == 1 and period2dict in user.get_inactive_periods()
 
     @td.with_user_project('test-admin')
     def test_skills(self):
         from datetime import datetime
 
-        #Add a skill
+        # Add a skill
         skill_cat = M.TroveCategory.query.get(show_as_skill=True)
         level = 'low'
         comment = 'test comment'
         result = self.app.get('/auth/user_info/skills/')
         r = self.app.post('/auth/user_info/skills/save_skill',
-             params=dict(
-                 level=level,
-                 comment=comment,
-                 selected_skill=str(skill_cat.trove_cat_id)))
+                          params=dict(
+                              level=level,
+                              comment=comment,
+                              selected_skill=str(skill_cat.trove_cat_id)))
         user = M.User.query.get(username='test-admin')
-        skilldict = dict(category_id=skill_cat._id, comment=comment, level=level)
+        skilldict = dict(category_id=skill_cat._id,
+                         comment=comment, level=level)
         assert len(user.skills) == 1 and skilldict in user.skills
 
-        #Add again the same skill
+        # Add again the same skill
         level = 'medium'
         comment = 'test comment 2'
         result = self.app.get('/auth/user_info/skills/')
         r = self.app.post('/auth/user_info/skills/save_skill',
-             params=dict(
-                 level=level,
-                 comment=comment,
-                 selected_skill=str(skill_cat.trove_cat_id)))
+                          params=dict(
+                              level=level,
+                              comment=comment,
+                              selected_skill=str(skill_cat.trove_cat_id)))
         user = M.User.query.get(username='test-admin')
-        skilldict = dict(category_id=skill_cat._id, comment=comment, level=level)
+        skilldict = dict(category_id=skill_cat._id,
+                         comment=comment, level=level)
         assert len(user.skills) == 1 and skilldict in user.skills
 
-        #Add an invalid skill
+        # Add an invalid skill
         level2 = 'not a level'
         comment2 = 'test comment 2'
         r = self.app.post('/auth/user_info/skills/save_skill',
-             params=dict(
-                 level=level2,
-                 comment=comment2,
-                 selected_skill=str(skill_cat.trove_cat_id)))
+                          params=dict(
+                              level=level2,
+                              comment=comment2,
+                              selected_skill=str(skill_cat.trove_cat_id)))
         user = M.User.query.get(username='test-admin')
-        #Check that everything is as it was before
+        # Check that everything is as it was before
         assert len(user.skills) == 1 and skilldict in user.skills
 
-        #Remove a skill
+        # Remove a skill
         result = self.app.get('/auth/user_info/skills/')
         r = self.app.post('/auth/user_info/skills/remove_skill',
-             params=dict(
-                 categoryid=str(skill_cat.trove_cat_id)))
+                          params=dict(
+                              categoryid=str(skill_cat.trove_cat_id)))
         user = M.User.query.get(username='test-admin')
         assert len(user.skills) == 0
 
     @td.with_user_project('test-admin')
     def test_user_message(self):
-        assert not M.User.query.get(username='test-admin').get_pref('disable_user_messages')
+        assert not M.User.query.get(
+            username='test-admin').get_pref('disable_user_messages')
         self.app.post('/auth/preferences/user_message')
-        assert M.User.query.get(username='test-admin').get_pref('disable_user_messages')
-        self.app.post('/auth/preferences/user_message', params={'allow_user_messages': 'on'})
-        assert not M.User.query.get(username='test-admin').get_pref('disable_user_messages')
+        assert M.User.query.get(
+            username='test-admin').get_pref('disable_user_messages')
+        self.app.post('/auth/preferences/user_message',
+                      params={'allow_user_messages': 'on'})
+        assert not M.User.query.get(
+            username='test-admin').get_pref('disable_user_messages')
 
 
 class TestPasswordReset(TestController):
+
     @patch('allura.tasks.mail_tasks.sendmail')
     @patch('allura.lib.helpers.gen_message_id')
     def test_email_unconfirmed(self, gen_message_id, sendmail):
         user = M.User.query.get(username='test-admin')
-        email = M.EmailAddress.query.find({'claimed_by_user_id': user._id}).first()
+        email = M.EmailAddress.query.find(
+            {'claimed_by_user_id': user._id}).first()
         email.confirmed = False
         ThreadLocalORMSession.flush_all()
         r = self.app.post('/auth/password_recovery_hash', {'email': email._id})
@@ -737,7 +783,8 @@ class TestPasswordReset(TestController):
     @patch('allura.lib.helpers.gen_message_id')
     def test_user_disabled(self, gen_message_id, sendmail):
         user = M.User.query.get(username='test-admin')
-        email = M.EmailAddress.query.find({'claimed_by_user_id': user._id}).first()
+        email = M.EmailAddress.query.find(
+            {'claimed_by_user_id': user._id}).first()
         user.disabled = True
         ThreadLocalORMSession.flush_all()
         r = self.app.post('/auth/password_recovery_hash', {'email': email._id})
@@ -748,7 +795,8 @@ class TestPasswordReset(TestController):
     @patch('allura.lib.helpers.gen_message_id')
     def test_password_reset(self, gen_message_id, sendmail):
         user = M.User.query.get(username='test-admin')
-        email = M.EmailAddress.query.find({'claimed_by_user_id': user._id}).first()
+        email = M.EmailAddress.query.find(
+            {'claimed_by_user_id': user._id}).first()
         email.confirmed = True
         ThreadLocalORMSession.flush_all()
         old_pw_hash = user.password
@@ -793,16 +841,19 @@ To reset your password on %s, please visit the following URL:
     @patch('allura.lib.helpers.gen_message_id')
     def test_hash_expired(self, gen_message_id, sendmail):
         user = M.User.query.get(username='test-admin')
-        email = M.EmailAddress.query.find({'claimed_by_user_id': user._id}).first()
+        email = M.EmailAddress.query.find(
+            {'claimed_by_user_id': user._id}).first()
         email.confirmed = True
         ThreadLocalORMSession.flush_all()
         r = self.app.post('/auth/password_recovery_hash', {'email': email._id})
         user = M.User.by_username('test-admin')
         hash = user.get_tool_data('AuthPasswordReset', 'hash')
-        user.set_tool_data('AuthPasswordReset', hash_expiry=datetime.datetime(2000, 10, 10))
+        user.set_tool_data('AuthPasswordReset',
+                           hash_expiry=datetime.datetime(2000, 10, 10))
         r = self.app.get('/auth/forgotten_password/%s' % hash.encode('utf-8'))
         assert_in('Unable to process reset, please try again', r.follow().body)
-        r = self.app.post('/auth/set_new_password/%s' % hash.encode('utf-8'), {'pw': '154321', 'pw2': '154321'})
+        r = self.app.post('/auth/set_new_password/%s' %
+                          hash.encode('utf-8'), {'pw': '154321', 'pw2': '154321'})
         assert_in('Unable to process reset, please try again', r.follow().body)
 
     @patch('allura.lib.plugin.AuthenticationProvider')
@@ -812,8 +863,10 @@ To reset your password on %s, please visit the following URL:
         ap.forgotten_password_process = False
         ap.authenticate_request()._id = user._id
         self.app.get('/auth/forgotten_password', status=404)
-        self.app.post('/auth/set_new_password', {'pw': 'foo', 'pw2': 'foo'}, status=404)
-        self.app.post('/auth/password_recovery_hash', {'email': 'foo'}, status=404)
+        self.app.post('/auth/set_new_password',
+                      {'pw': 'foo', 'pw2': 'foo'}, status=404)
+        self.app.post('/auth/password_recovery_hash',
+                      {'email': 'foo'}, status=404)
 
 
 class TestOAuth(TestController):
@@ -821,7 +874,8 @@ class TestOAuth(TestController):
     def test_register_deregister_app(self):
         # register
         r = self.app.get('/auth/oauth/')
-        r = self.app.post('/auth/oauth/register', params={'application_name': 'oautstapp', 'application_description': 'Oauth rulez'}).follow()
+        r = self.app.post('/auth/oauth/register',
+                          params={'application_name': 'oautstapp', 'application_description': 'Oauth rulez'}).follow()
         assert 'oautstapp' in r
         # deregister
         assert_equal(r.forms[0].action, 'deregister')
@@ -831,18 +885,21 @@ class TestOAuth(TestController):
 
     def test_generate_revoke_access_token(self):
         # generate
-        r = self.app.post('/auth/oauth/register', params={'application_name': 'oautstapp', 'application_description': 'Oauth rulez'}).follow()
+        r = self.app.post('/auth/oauth/register',
+                          params={'application_name': 'oautstapp', 'application_description': 'Oauth rulez'}).follow()
         assert_equal(r.forms[1].action, 'generate_access_token')
         r.forms[1].submit()
         r = self.app.get('/auth/oauth/')
         assert 'Bearer Token:' in r
-        assert_not_equal(M.OAuthAccessToken.for_user(M.User.by_username('test-admin')), [])
+        assert_not_equal(
+            M.OAuthAccessToken.for_user(M.User.by_username('test-admin')), [])
         # revoke
         assert_equal(r.forms[0].action, 'revoke_access_token')
         r.forms[0].submit()
         r = self.app.get('/auth/oauth/')
         assert_not_equal(r.forms[0].action, 'revoke_access_token')
-        assert_equal(M.OAuthAccessToken.for_user(M.User.by_username('test-admin')), [])
+        assert_equal(
+            M.OAuthAccessToken.for_user(M.User.by_username('test-admin')), [])
 
     @mock.patch('allura.controllers.rest.oauth.Server')
     @mock.patch('allura.controllers.rest.oauth.Request')
@@ -850,27 +907,28 @@ class TestOAuth(TestController):
         M.OAuthConsumerToken.consumer = mock.Mock()
         user = M.User.by_username('test-admin')
         consumer_token = M.OAuthConsumerToken(
-                api_key='api_key',
-                user_id=user._id,
-                description='ctok_desc',
-            )
+            api_key='api_key',
+            user_id=user._id,
+            description='ctok_desc',
+        )
         ThreadLocalORMSession.flush_all()
         req = Request.from_request.return_value = {
-                'oauth_consumer_key': 'api_key',
-                'oauth_callback': 'http://my.domain.com/callback',
-            }
+            'oauth_consumer_key': 'api_key',
+            'oauth_callback': 'http://my.domain.com/callback',
+        }
         r = self.app.post('/rest/oauth/request_token', params={})
         rtok = parse_qs(r.body)['oauth_token'][0]
-        r = self.app.post('/rest/oauth/authorize', params={'oauth_token':rtok})
+        r = self.app.post('/rest/oauth/authorize',
+                          params={'oauth_token': rtok})
         r = r.forms[0].submit('yes')
         assert r.location.startswith('http://my.domain.com/callback')
         pin = parse_qs(urlparse(r.location).query)['oauth_verifier'][0]
         #pin = r.html.find(text=re.compile('^PIN: ')).split()[1]
         req = Request.from_request.return_value = {
-                'oauth_consumer_key': 'api_key',
-                'oauth_token': rtok,
-                'oauth_verifier': pin,
-            }
+            'oauth_consumer_key': 'api_key',
+            'oauth_token': rtok,
+            'oauth_verifier': pin,
+        }
         r = self.app.get('/rest/oauth/access_token')
         atok = parse_qs(r.body)
         assert_equal(len(atok['oauth_token']), 1)
@@ -882,27 +940,33 @@ class TestOAuth(TestController):
         M.OAuthConsumerToken.consumer = mock.Mock()
         user = M.User.by_username('test-user')
         consumer_token = M.OAuthConsumerToken(
-                api_key='api_key',
-                user_id=user._id,
-            )
+            api_key='api_key',
+            user_id=user._id,
+        )
         ThreadLocalORMSession.flush_all()
-        req = Request.from_request.return_value = {'oauth_consumer_key': 'api_key'}
-        r = self.app.post('/rest/oauth/request_token', params={'key':'value'})
+        req = Request.from_request.return_value = {
+            'oauth_consumer_key': 'api_key'}
+        r = self.app.post('/rest/oauth/request_token', params={'key': 'value'})
         Request.from_request.assert_called_once_with(
-                'POST', 'http://localhost/rest/oauth/request_token',
-                headers={'Host': 'localhost:80', 'Content-Type': 'application/x-www-form-urlencoded; charset="utf-8"'},
-                parameters={'key':'value'},
-                query_string='')
-        Server().verify_request.assert_called_once_with(req, consumer_token.consumer, None)
-        request_token = M.OAuthRequestToken.query.get(consumer_token_id=consumer_token._id)
+            'POST', 'http://localhost/rest/oauth/request_token',
+            headers={'Host': 'localhost:80', 'Content-Type':
+                    'application/x-www-form-urlencoded; charset="utf-8"'},
+            parameters={'key': 'value'},
+            query_string='')
+        Server().verify_request.assert_called_once_with(
+            req, consumer_token.consumer, None)
+        request_token = M.OAuthRequestToken.query.get(
+            consumer_token_id=consumer_token._id)
         assert_is_not_none(request_token)
         assert_equal(r.body, request_token.to_string())
 
     @mock.patch('allura.controllers.rest.oauth.Server')
     @mock.patch('allura.controllers.rest.oauth.Request')
     def test_request_token_no_consumer_token(self, Request, Server):
-        req = Request.from_request.return_value = {'oauth_consumer_key': 'api_key'}
-        r = self.app.post('/rest/oauth/request_token', params={'key':'value'}, status=403)
+        req = Request.from_request.return_value = {
+            'oauth_consumer_key': 'api_key'}
+        r = self.app.post('/rest/oauth/request_token',
+                          params={'key': 'value'}, status=403)
 
     @mock.patch('allura.controllers.rest.oauth.Server')
     @mock.patch('allura.controllers.rest.oauth.Request')
@@ -911,147 +975,157 @@ class TestOAuth(TestController):
         M.OAuthConsumerToken.consumer = mock.Mock()
         user = M.User.by_username('test-user')
         consumer_token = M.OAuthConsumerToken(
-                api_key='api_key',
-                user_id=user._id,
-            )
+            api_key='api_key',
+            user_id=user._id,
+        )
         ThreadLocalORMSession.flush_all()
-        req = Request.from_request.return_value = {'oauth_consumer_key': 'api_key'}
-        r = self.app.post('/rest/oauth/request_token', params={'key':'value'}, status=403)
+        req = Request.from_request.return_value = {
+            'oauth_consumer_key': 'api_key'}
+        r = self.app.post('/rest/oauth/request_token',
+                          params={'key': 'value'}, status=403)
 
     def test_authorize_ok(self):
         user = M.User.by_username('test-admin')
         ctok = M.OAuthConsumerToken(
-                api_key='api_key',
-                user_id=user._id,
-                description='ctok_desc',
-            )
+            api_key='api_key',
+            user_id=user._id,
+            description='ctok_desc',
+        )
         rtok = M.OAuthRequestToken(
-                api_key='api_key',
-                consumer_token_id=ctok._id,
-                callback='oob',
-                user_id=user._id,
-            )
+            api_key='api_key',
+            consumer_token_id=ctok._id,
+            callback='oob',
+            user_id=user._id,
+        )
         ThreadLocalORMSession.flush_all()
-        r = self.app.post('/rest/oauth/authorize', params={'oauth_token':'api_key'})
+        r = self.app.post('/rest/oauth/authorize',
+                          params={'oauth_token': 'api_key'})
         assert_in('ctok_desc', r.body)
         assert_in('api_key', r.body)
 
     def test_authorize_invalid(self):
-        r = self.app.post('/rest/oauth/authorize', params={'oauth_token':'api_key'}, status=403)
+        r = self.app.post('/rest/oauth/authorize',
+                          params={'oauth_token': 'api_key'}, status=403)
 
     def test_do_authorize_no(self):
         user = M.User.by_username('test-admin')
         ctok = M.OAuthConsumerToken(
-                api_key='api_key',
-                user_id=user._id,
-                description='ctok_desc',
-            )
+            api_key='api_key',
+            user_id=user._id,
+            description='ctok_desc',
+        )
         rtok = M.OAuthRequestToken(
-                api_key='api_key',
-                consumer_token_id=ctok._id,
-                callback='oob',
-                user_id=user._id,
-            )
+            api_key='api_key',
+            consumer_token_id=ctok._id,
+            callback='oob',
+            user_id=user._id,
+        )
         ThreadLocalORMSession.flush_all()
-        r = self.app.post('/rest/oauth/do_authorize', params={'no': '1', 'oauth_token': 'api_key'})
+        r = self.app.post('/rest/oauth/do_authorize',
+                          params={'no': '1', 'oauth_token': 'api_key'})
         assert_is_none(M.OAuthRequestToken.query.get(api_key='api_key'))
 
     def test_do_authorize_oob(self):
         user = M.User.by_username('test-admin')
         ctok = M.OAuthConsumerToken(
-                api_key='api_key',
-                user_id=user._id,
-                description='ctok_desc',
-            )
+            api_key='api_key',
+            user_id=user._id,
+            description='ctok_desc',
+        )
         rtok = M.OAuthRequestToken(
-                api_key='api_key',
-                consumer_token_id=ctok._id,
-                callback='oob',
-                user_id=user._id,
-            )
+            api_key='api_key',
+            consumer_token_id=ctok._id,
+            callback='oob',
+            user_id=user._id,
+        )
         ThreadLocalORMSession.flush_all()
-        r = self.app.post('/rest/oauth/do_authorize', params={'yes': '1', 'oauth_token': 'api_key'})
+        r = self.app.post('/rest/oauth/do_authorize',
+                          params={'yes': '1', 'oauth_token': 'api_key'})
         assert_is_not_none(r.html.find(text=re.compile('^PIN: ')))
 
     def test_do_authorize_cb(self):
         user = M.User.by_username('test-admin')
         ctok = M.OAuthConsumerToken(
-                api_key='api_key',
-                user_id=user._id,
-                description='ctok_desc',
-            )
+            api_key='api_key',
+            user_id=user._id,
+            description='ctok_desc',
+        )
         rtok = M.OAuthRequestToken(
-                api_key='api_key',
-                consumer_token_id=ctok._id,
-                callback='http://my.domain.com/callback',
-                user_id=user._id,
-            )
+            api_key='api_key',
+            consumer_token_id=ctok._id,
+            callback='http://my.domain.com/callback',
+            user_id=user._id,
+        )
         ThreadLocalORMSession.flush_all()
-        r = self.app.post('/rest/oauth/do_authorize', params={'yes': '1', 'oauth_token': 'api_key'})
-        assert r.location.startswith('http://my.domain.com/callback?oauth_token=api_key&oauth_verifier=')
+        r = self.app.post('/rest/oauth/do_authorize',
+                          params={'yes': '1', 'oauth_token': 'api_key'})
+        assert r.location.startswith(
+            'http://my.domain.com/callback?oauth_token=api_key&oauth_verifier=')
 
     def test_do_authorize_cb_params(self):
         user = M.User.by_username('test-admin')
         ctok = M.OAuthConsumerToken(
-                api_key='api_key',
-                user_id=user._id,
-                description='ctok_desc',
-            )
+            api_key='api_key',
+            user_id=user._id,
+            description='ctok_desc',
+        )
         rtok = M.OAuthRequestToken(
-                api_key='api_key',
-                consumer_token_id=ctok._id,
-                callback='http://my.domain.com/callback?myparam=foo',
-                user_id=user._id,
-            )
+            api_key='api_key',
+            consumer_token_id=ctok._id,
+            callback='http://my.domain.com/callback?myparam=foo',
+            user_id=user._id,
+        )
         ThreadLocalORMSession.flush_all()
-        r = self.app.post('/rest/oauth/do_authorize', params={'yes': '1', 'oauth_token': 'api_key'})
-        assert r.location.startswith('http://my.domain.com/callback?myparam=foo&oauth_token=api_key&oauth_verifier=')
+        r = self.app.post('/rest/oauth/do_authorize',
+                          params={'yes': '1', 'oauth_token': 'api_key'})
+        assert r.location.startswith(
+            'http://my.domain.com/callback?myparam=foo&oauth_token=api_key&oauth_verifier=')
 
     @mock.patch('allura.controllers.rest.oauth.Request')
     def test_access_token_no_consumer(self, Request):
         req = Request.from_request.return_value = {
-                'oauth_consumer_key': 'api_key',
-                'oauth_token': 'api_key',
-                'oauth_verifier': 'good',
-            }
+            'oauth_consumer_key': 'api_key',
+            'oauth_token': 'api_key',
+            'oauth_verifier': 'good',
+        }
         self.app.get('/rest/oauth/access_token', status=403)
 
     @mock.patch('allura.controllers.rest.oauth.Request')
     def test_access_token_no_request(self, Request):
         req = Request.from_request.return_value = {
-                'oauth_consumer_key': 'api_key',
-                'oauth_token': 'api_key',
-                'oauth_verifier': 'good',
-            }
+            'oauth_consumer_key': 'api_key',
+            'oauth_token': 'api_key',
+            'oauth_verifier': 'good',
+        }
         user = M.User.by_username('test-admin')
         ctok = M.OAuthConsumerToken(
-                api_key='api_key',
-                user_id=user._id,
-                description='ctok_desc',
-            )
+            api_key='api_key',
+            user_id=user._id,
+            description='ctok_desc',
+        )
         ThreadLocalORMSession.flush_all()
         self.app.get('/rest/oauth/access_token', status=403)
 
     @mock.patch('allura.controllers.rest.oauth.Request')
     def test_access_token_bad_pin(self, Request):
         req = Request.from_request.return_value = {
-                'oauth_consumer_key': 'api_key',
-                'oauth_token': 'api_key',
-                'oauth_verifier': 'bad',
-            }
+            'oauth_consumer_key': 'api_key',
+            'oauth_token': 'api_key',
+            'oauth_verifier': 'bad',
+        }
         user = M.User.by_username('test-admin')
         ctok = M.OAuthConsumerToken(
-                api_key='api_key',
-                user_id=user._id,
-                description='ctok_desc',
-            )
+            api_key='api_key',
+            user_id=user._id,
+            description='ctok_desc',
+        )
         rtok = M.OAuthRequestToken(
-                api_key='api_key',
-                consumer_token_id=ctok._id,
-                callback='http://my.domain.com/callback?myparam=foo',
-                user_id=user._id,
-                validation_pin='good',
-            )
+            api_key='api_key',
+            consumer_token_id=ctok._id,
+            callback='http://my.domain.com/callback?myparam=foo',
+            user_id=user._id,
+            validation_pin='good',
+        )
         ThreadLocalORMSession.flush_all()
         self.app.get('/rest/oauth/access_token', status=403)
 
@@ -1059,23 +1133,23 @@ class TestOAuth(TestController):
     @mock.patch('allura.controllers.rest.oauth.Request')
     def test_access_token_bad_sig(self, Request, Server):
         req = Request.from_request.return_value = {
-                'oauth_consumer_key': 'api_key',
-                'oauth_token': 'api_key',
-                'oauth_verifier': 'good',
-            }
+            'oauth_consumer_key': 'api_key',
+            'oauth_token': 'api_key',
+            'oauth_verifier': 'good',
+        }
         user = M.User.by_username('test-admin')
         ctok = M.OAuthConsumerToken(
-                api_key='api_key',
-                user_id=user._id,
-                description='ctok_desc',
-            )
+            api_key='api_key',
+            user_id=user._id,
+            description='ctok_desc',
+        )
         rtok = M.OAuthRequestToken(
-                api_key='api_key',
-                consumer_token_id=ctok._id,
-                callback='http://my.domain.com/callback?myparam=foo',
-                user_id=user._id,
-                validation_pin='good',
-            )
+            api_key='api_key',
+            consumer_token_id=ctok._id,
+            callback='http://my.domain.com/callback?myparam=foo',
+            user_id=user._id,
+            validation_pin='good',
+        )
         ThreadLocalORMSession.flush_all()
         Server().verify_request.side_effect = ValueError
         self.app.get('/rest/oauth/access_token', status=403)
@@ -1084,23 +1158,23 @@ class TestOAuth(TestController):
     @mock.patch('allura.controllers.rest.oauth.Request')
     def test_access_token_ok(self, Request, Server):
         req = Request.from_request.return_value = {
-                'oauth_consumer_key': 'api_key',
-                'oauth_token': 'api_key',
-                'oauth_verifier': 'good',
-            }
+            'oauth_consumer_key': 'api_key',
+            'oauth_token': 'api_key',
+            'oauth_verifier': 'good',
+        }
         user = M.User.by_username('test-admin')
         ctok = M.OAuthConsumerToken(
-                api_key='api_key',
-                user_id=user._id,
-                description='ctok_desc',
-            )
+            api_key='api_key',
+            user_id=user._id,
+            description='ctok_desc',
+        )
         rtok = M.OAuthRequestToken(
-                api_key='api_key',
-                consumer_token_id=ctok._id,
-                callback='http://my.domain.com/callback?myparam=foo',
-                user_id=user._id,
-                validation_pin='good',
-            )
+            api_key='api_key',
+            consumer_token_id=ctok._id,
+            callback='http://my.domain.com/callback?myparam=foo',
+            user_id=user._id,
+            validation_pin='good',
+        )
         ThreadLocalORMSession.flush_all()
         r = self.app.get('/rest/oauth/access_token')
         atok = parse_qs(r.body)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/Allura/allura/tests/functional/test_discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_discuss.py b/Allura/allura/tests/functional/test_discuss.py
index 981fc6e..816b3d5 100644
--- a/Allura/allura/tests/functional/test_discuss.py
+++ b/Allura/allura/tests/functional/test_discuss.py
@@ -20,40 +20,41 @@ from mock import patch
 from allura.tests import TestController
 from allura import model as M
 
+
 class TestDiscuss(TestController):
 
     def test_subscribe_unsubscribe(self):
         home = self.app.get('/wiki/_discuss/')
-        subscribed = [ i for i in home.html.findAll('input')
-                       if i.get('type') == 'checkbox'][0]
+        subscribed = [i for i in home.html.findAll('input')
+                      if i.get('type') == 'checkbox'][0]
         assert 'checked' not in subscribed.attrMap
-        link = [ a for a in home.html.findAll('a')
-                 if 'thread' in a['href'] ][0]
+        link = [a for a in home.html.findAll('a')
+                if 'thread' in a['href']][0]
         params = {
-            'threads-0._id':link['href'][len('/p/test/wiki/_discuss/thread/'):-1],
-            'threads-0.subscription':'on' }
+            'threads-0._id': link['href'][len('/p/test/wiki/_discuss/thread/'):-1],
+            'threads-0.subscription': 'on'}
         r = self.app.post('/wiki/_discuss/subscribe',
                           params=params,
-                          headers={'Referer':'/wiki/_discuss/'})
+                          headers={'Referer': '/wiki/_discuss/'})
         r = r.follow()
-        subscribed = [ i for i in r.html.findAll('input')
-                       if i.get('type') == 'checkbox'][0]
+        subscribed = [i for i in r.html.findAll('input')
+                      if i.get('type') == 'checkbox'][0]
         assert 'checked' in subscribed.attrMap
         params = {
-            'threads-0._id':link['href'][len('/p/test/wiki/_discuss/thread/'):-1]
-            }
+            'threads-0._id': link['href'][len('/p/test/wiki/_discuss/thread/'):-1]
+        }
         r = self.app.post('/wiki/_discuss/subscribe',
                           params=params,
-                          headers={'Referer':'/wiki/_discuss/'})
+                          headers={'Referer': '/wiki/_discuss/'})
         r = r.follow()
-        subscribed = [ i for i in r.html.findAll('input')
-                       if i.get('type') == 'checkbox'][0]
+        subscribed = [i for i in r.html.findAll('input')
+                      if i.get('type') == 'checkbox'][0]
         assert 'checked' not in subscribed.attrMap
 
     def _make_post(self, text):
         home = self.app.get('/wiki/_discuss/')
-        thread_link = [ a for a in home.html.findAll('a')
-                 if 'thread' in a['href'] ][0]['href']
+        thread_link = [a for a in home.html.findAll('a')
+                       if 'thread' in a['href']][0]['href']
         thread = self.app.get(thread_link)
         for f in thread.html.findAll('form'):
             if f.get('action', '').endswith('/post'):
@@ -62,10 +63,11 @@ class TestDiscuss(TestController):
         inputs = f.findAll('input')
         for field in inputs:
             if field.has_key('name'):
-                params[field['name']] = field.has_key('value') and field['value'] or ''
+                params[field['name']] = field.has_key(
+                    'value') and field['value'] or ''
         params[f.find('textarea')['name']] = text
         r = self.app.post(f['action'].encode('utf-8'), params=params,
-                          headers={'Referer':thread_link.encode("utf-8")},
+                          headers={'Referer': thread_link.encode("utf-8")},
                           extra_environ=dict(username='root'))
         r = r.follow()
         return r
@@ -73,49 +75,54 @@ class TestDiscuss(TestController):
     @patch('allura.controllers.discuss.g.spam_checker.submit_spam')
     def test_post(self, submit_spam):
         home = self.app.get('/wiki/_discuss/')
-        thread_link = [ a for a in home.html.findAll('a')
-                 if 'thread' in a['href'] ][0]['href']
+        thread_link = [a for a in home.html.findAll('a')
+                       if 'thread' in a['href']][0]['href']
         r = self._make_post('This is a post')
         assert 'This is a post' in r, r
-        post_link = str(r.html.find('div',{'class':'edit_post_form reply'}).find('form')['action'])
+        post_link = str(
+            r.html.find('div', {'class': 'edit_post_form reply'}).find('form')['action'])
         r = self.app.get(post_link[:-2], status=302)
         r = self.app.get(post_link)
-        post_form = r.html.find('form',{'action':post_link})
+        post_form = r.html.find('form', {'action': post_link})
         params = dict()
         inputs = post_form.findAll('input')
         for field in inputs:
             if field.has_key('name'):
-                params[field['name']] = field.has_key('value') and field['value'] or ''
+                params[field['name']] = field.has_key(
+                    'value') and field['value'] or ''
         params[post_form.find('textarea')['name']] = 'This is a new post'
         r = self.app.post(post_link,
                           params=params,
-                          headers={'Referer':thread_link.encode("utf-8")})
+                          headers={'Referer': thread_link.encode("utf-8")})
         r = r.follow()
         assert 'This is a new post' in r, r
         r = self.app.get(post_link)
         assert str(r).count('This is a new post') == 3
-        post_form = r.html.find('form',{'action':post_link + 'reply'})
+        post_form = r.html.find('form', {'action': post_link + 'reply'})
         params = dict()
         inputs = post_form.findAll('input')
         for field in inputs:
             if field.has_key('name'):
-                params[field['name']] = field.has_key('value') and field['value'] or ''
+                params[field['name']] = field.has_key(
+                    'value') and field['value'] or ''
         params[post_form.find('textarea')['name']] = 'Tis a reply'
         r = self.app.post(post_link + 'reply',
                           params=params,
-                          headers={'Referer':post_link.encode("utf-8")})
+                          headers={'Referer': post_link.encode("utf-8")})
         r = self.app.get(thread_link)
         assert 'Tis a reply' in r, r
-        permalinks = [post.find('form')['action'].encode('utf-8') for post in r.html.findAll('div',{'class':'edit_post_form reply'})]
-        self.app.post(permalinks[1]+'flag')
-        self.app.post(permalinks[1]+'moderate', params=dict(delete='delete'))
-        self.app.post(permalinks[0]+'moderate', params=dict(spam='spam'))
-        assert submit_spam.call_args[0] ==('This is a new post',), submit_spam.call_args[0]
+        permalinks = [post.find('form')['action'].encode('utf-8')
+                      for post in r.html.findAll('div', {'class': 'edit_post_form reply'})]
+        self.app.post(permalinks[1] + 'flag')
+        self.app.post(permalinks[1] + 'moderate', params=dict(delete='delete'))
+        self.app.post(permalinks[0] + 'moderate', params=dict(spam='spam'))
+        assert submit_spam.call_args[0] == (
+            'This is a new post',), submit_spam.call_args[0]
 
     def test_permissions(self):
         home = self.app.get('/wiki/_discuss/')
-        thread_url = [ a for a in home.html.findAll('a')
-                 if 'thread' in a['href'] ][0]['href']
+        thread_url = [a for a in home.html.findAll('a')
+                      if 'thread' in a['href']][0]['href']
         thread_id = thread_url.rstrip('/').split('/')[-1]
         thread = M.Thread.query.get(_id=thread_id)
 
@@ -126,7 +133,8 @@ class TestDiscuss(TestController):
 
         # set wiki page private
         from forgewiki.model import Page
-        page = Page.query.get(_id=thread.ref.artifact._id)  # need to look up the page directly, so ming is aware of our change
+        # need to look up the page directly, so ming is aware of our change
+        page = Page.query.get(_id=thread.ref.artifact._id)
         project = M.Project.query.get(shortname='test')
         role_admin = M.ProjectRole.by_name('Admin', project)._id
         page.acl = [
@@ -134,25 +142,28 @@ class TestDiscuss(TestController):
             M.DENY_ALL,
         ]
 
-        self.app.get(thread_url, status=200, # ok
+        self.app.get(thread_url, status=200,  # ok
                      extra_environ=dict(username='test-admin'))
-        self.app.get(thread_url, status=403, # forbidden
+        self.app.get(thread_url, status=403,  # forbidden
                      extra_environ=dict(username=non_admin))
 
     def test_spam_link(self):
         r = self._make_post('Test post')
         assert '<span>Spam</span>' in r
-        r = self.app.get('/wiki/_discuss/', extra_environ={'username': 'test-user-1'})
+        r = self.app.get('/wiki/_discuss/',
+                         extra_environ={'username': 'test-user-1'})
         assert '<span>Spam</span>' not in r, 'User without moderate perm must not see Spam link'
 
     @patch('allura.controllers.discuss.g.spam_checker.submit_spam')
     def test_moderate(self, submit_spam):
         r = self._make_post('Test post')
-        post_link = str(r.html.find('div', {'class': 'edit_post_form reply'}).find('form')['action'])
+        post_link = str(
+            r.html.find('div', {'class': 'edit_post_form reply'}).find('form')['action'])
         post = M.Post.query.find().first()
         post.status = 'pending'
         self.app.post(post_link + 'moderate', params=dict(spam='spam'))
-        assert submit_spam.call_args[0] ==('Test post',), submit_spam.call_args[0]
+        assert submit_spam.call_args[0] == (
+            'Test post',), submit_spam.call_args[0]
         post = M.Post.query.find().first()
         assert post.status == 'spam'
         self.app.post(post_link + 'moderate', params=dict(approve='approve'))
@@ -163,8 +174,8 @@ class TestDiscuss(TestController):
 
     def test_post_paging(self):
         home = self.app.get('/wiki/_discuss/')
-        thread_link = [ a for a in home.html.findAll('a')
-                 if 'thread' in a['href'] ][0]['href']
+        thread_link = [a for a in home.html.findAll('a')
+                       if 'thread' in a['href']][0]['href']
         # just make sure it doesn't 500
         r = self.app.get('%s?limit=50&page=0' % thread_link)
 
@@ -175,31 +186,37 @@ class TestDiscuss(TestController):
         assert create_activity.call_args[0][1] == 'posted'
         create_activity.reset_mock()
         thread_url = r.request.url
-        reply_form = r.html.find('div',{'class':'edit_post_form reply'}).find('form')
+        reply_form = r.html.find(
+            'div', {'class': 'edit_post_form reply'}).find('form')
         post_link = str(reply_form['action'])
-        assert 'This is a post' in str(r.html.find('div',{'class':'display_post'}))
-        assert 'Last edit:' not in str(r.html.find('div',{'class':'display_post'}))
+        assert 'This is a post' in str(
+            r.html.find('div', {'class': 'display_post'}))
+        assert 'Last edit:' not in str(
+            r.html.find('div', {'class': 'display_post'}))
         params = dict()
         inputs = reply_form.findAll('input')
         for field in inputs:
             if field.has_key('name'):
-                params[field['name']] = field.has_key('value') and field['value'] or ''
+                params[field['name']] = field.has_key(
+                    'value') and field['value'] or ''
         params[reply_form.find('textarea')['name']] = 'zzz'
         self.app.post(post_link, params)
         assert create_activity.call_count == 1, create_activity.call_count
         assert create_activity.call_args[0][1] == 'modified'
         r = self.app.get(thread_url)
-        assert 'zzz' in str(r.html.find('div',{'class':'display_post'}))
-        assert 'Last edit: Test Admin less than 1 minute ago' in str(r.html.find('div',{'class':'display_post'}))
+        assert 'zzz' in str(r.html.find('div', {'class': 'display_post'}))
+        assert 'Last edit: Test Admin less than 1 minute ago' in str(
+            r.html.find('div', {'class': 'display_post'}))
+
 
 class TestAttachment(TestController):
 
     def setUp(self):
         super(TestAttachment, self).setUp()
         home = self.app.get('/wiki/_discuss/')
-        self.thread_link = [ a['href'].encode("utf-8")
-                             for a in home.html.findAll('a')
-                             if 'thread' in a['href'] ][0]
+        self.thread_link = [a['href'].encode("utf-8")
+                            for a in home.html.findAll('a')
+                            if 'thread' in a['href']][0]
         thread = self.app.get(self.thread_link)
         for f in thread.html.findAll('form'):
             if f.get('action', '').endswith('/post'):
@@ -209,12 +226,14 @@ class TestAttachment(TestController):
         inputs = f.findAll('input')
         for field in inputs:
             if field.has_key('name'):
-                params[field['name']] = field.has_key('value') and field['value'] or ''
+                params[field['name']] = field.has_key(
+                    'value') and field['value'] or ''
         params[f.find('textarea')['name']] = 'Test Post'
         r = self.app.post(f['action'].encode('utf-8'), params=params,
-                          headers={'Referer':self.thread_link})
+                          headers={'Referer': self.thread_link})
         r = r.follow()
-        self.post_link = str(r.html.find('div',{'class':'edit_post_form reply'}).find('form')['action'])
+        self.post_link = str(
+            r.html.find('div', {'class': 'edit_post_form reply'}).find('form')['action'])
 
     def test_attach(self):
         r = self.app.post(self.post_link + 'attach',
@@ -237,13 +256,14 @@ class TestAttachment(TestController):
     def test_reply_attach(self, notify):
         notify.return_value = True
         r = self.app.get(self.thread_link)
-        post_form = r.html.find('form', {'action':self.post_link + 'reply'})
+        post_form = r.html.find('form', {'action': self.post_link + 'reply'})
         params = dict()
         inputs = post_form.findAll('input')
 
         for field in inputs:
-            if field.has_key('name') and (field['name']!='file_info'):
-                params[field['name']] = field.has_key('value') and field['value'] or ''
+            if field.has_key('name') and (field['name'] != 'file_info'):
+                params[field['name']] = field.has_key(
+                    'value') and field['value'] or ''
         params[post_form.find('textarea')['name']] = 'Reply'
         r = self.app.post(self.post_link + 'reply',
                           params=params,

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/Allura/allura/tests/functional/test_feeds.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_feeds.py b/Allura/allura/tests/functional/test_feeds.py
index 000ab74..54416a5 100644
--- a/Allura/allura/tests/functional/test_feeds.py
+++ b/Allura/allura/tests/functional/test_feeds.py
@@ -20,7 +20,9 @@ from formencode.variabledecode import variable_encode
 from allura.tests import TestController
 from allura.tests import decorators as td
 
+
 class TestFeeds(TestController):
+
     def setUp(self):
         TestController.setUp(self)
         self._setUp()
@@ -33,7 +35,7 @@ class TestFeeds(TestController):
         self.app.post(
             '/bugs/save_ticket',
             params=variable_encode(dict(
-                    ticket_form=dict(
+                ticket_form=dict(
                     ticket_num='',
                     labels='',
                     assigned_to='',
@@ -49,7 +51,7 @@ class TestFeeds(TestController):
                 title=title,
                 text="Nothing much",
                 labels='',
-                ),
+            ),
             status=302)
         self.app.get('/wiki/%s/' % title)
 
@@ -65,10 +67,10 @@ class TestFeeds(TestController):
     @td.with_wiki
     def test_wiki_page_feed(self):
         self.app.post('/wiki/Root/update', params={
-                'title':'Root',
-                'text':'',
-                'labels':'',
-                'viewable_by-0.id':'all'})
+            'title': 'Root',
+            'text': '',
+            'labels': '',
+            'viewable_by-0.id': 'all'})
         self.app.get('/wiki/Root/feed.rss')
         self.app.get('/wiki/Root/feed.atom')
 
@@ -82,14 +84,13 @@ class TestFeeds(TestController):
         self.app.get('/bugs/1/feed.rss')
         r = self.app.get('/bugs/1/feed.atom')
         self.app.post('/bugs/1/update_ticket', params=dict(
-                assigned_to='',
-                ticket_num='',
-                labels='',
-                summary='This is a new ticket',
-                status='unread',
-                milestone='',
-                description='This is another description'), extra_environ=dict(username='root'))
+            assigned_to='',
+            ticket_num='',
+            labels='',
+            summary='This is a new ticket',
+            status='unread',
+            milestone='',
+            description='This is another description'), extra_environ=dict(username='root'))
         r = self.app.get('/bugs/1/feed.atom')
         assert '=&amp;gt' in r
         assert '\n+' in r
-

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/Allura/allura/tests/functional/test_gravatar.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_gravatar.py b/Allura/allura/tests/functional/test_gravatar.py
index 4f6940b..bea43f3 100644
--- a/Allura/allura/tests/functional/test_gravatar.py
+++ b/Allura/allura/tests/functional/test_gravatar.py
@@ -33,7 +33,8 @@ class TestGravatar(TestController):
         email = u'Vin\u00EDcius@example.com'
         expected_id = 'e00968255d68523b034a6a39c522efdb'
         actual_id = gravatar.id(email)
-        assert expected_id == actual_id, 'Expected gravitar ID %s, got %s' % (repr(expected_id), repr(actual_id))
+        assert expected_id == actual_id, 'Expected gravitar ID %s, got %s' % (
+            repr(expected_id), repr(actual_id))
 
     def test_url(self):
         email = 'Wolf@example.com'


Mime
View raw message