incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [20/36] PEP8 cleanup
Date Fri, 10 Jan 2014 21:23:16 GMT
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/Allura/allura/tests/functional/test_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_admin.py b/Allura/allura/tests/functional/test_admin.py
index 5919bb9..a7fb5bf 100644
--- a/Allura/allura/tests/functional/test_admin.py
+++ b/Allura/allura/tests/functional/test_admin.py
@@ -16,7 +16,8 @@
 #       under the License.
 
 import re
-import os, allura
+import os
+import allura
 import shutil
 import pkg_resources
 import StringIO
@@ -51,6 +52,7 @@ from forgetracker.tracker_main import ForgeTrackerApp
 from forgewiki.model import Page
 from forgewiki.wiki_main import ForgeWikiApp
 
+
 @contextmanager
 def audits(*messages):
     M.AuditLog.query.remove()
@@ -59,11 +61,13 @@ def audits(*messages):
     if not messages:
         for e in entries:
             print e.message
-        import pdb; pdb.set_trace()
+        import pdb
+        pdb.set_trace()
     for message in messages:
         assert M.AuditLog.query.find(dict(
             message=re.compile(message))).count(), 'Could not find "%s"' % message
 
+
 class TestProjectAdmin(TestController):
 
     def get_available_tools(self):
@@ -74,15 +78,16 @@ class TestProjectAdmin(TestController):
     def test_admin_controller(self):
         self.app.get('/admin/')
         with audits(
-            'change summary to Milkshakes are for crazy monkeys',
-            'change project name to My Test Project',
-            u'change short description to (\u00bf A Test Project \?){45}'):
+                'change summary to Milkshakes are for crazy monkeys',
+                'change project name to My Test Project',
+                u'change short description to (\u00bf A Test Project \?){45}'):
             self.app.post('/admin/update', params=dict(
-                    name='My Test Project',
-                    shortname='test',
-                    summary='Milkshakes are for crazy monkeys',
-                    short_description=u'\u00bf A Test Project ?'.encode('utf-8') * 45,
-                    labels='aaa,bbb'))
+                name='My Test Project',
+                shortname='test',
+                summary='Milkshakes are for crazy monkeys',
+                short_description=u'\u00bf A Test Project ?'.encode(
+                        'utf-8') * 45,
+                labels='aaa,bbb'))
         r = self.app.get('/admin/overview')
         assert 'A Test Project ?\xc2\xbf A' in r
         assert 'Test Subproject' not in r
@@ -93,84 +98,84 @@ class TestProjectAdmin(TestController):
         # Add a subproject
         with audits('create subproject test-subproject'):
             self.app.post('/admin/update_mounts', params={
-                    'new.install':'install',
-                    'new.ep_name':'',
-                    'new.ordinal':'1',
-                    'new.mount_point':'test-subproject',
-                    'new.mount_label':'Test Subproject'})
+                'new.install': 'install',
+                'new.ep_name': '',
+                'new.ordinal': '1',
+                'new.mount_point': 'test-subproject',
+                'new.mount_label': 'Test Subproject'})
         r = self.app.get('/admin/overview')
         assert 'Test Subproject' in r
         # Rename a subproject
         with audits('update subproject test/test-subproject'):
             self.app.post('/admin/update_mounts', params={
-                    'subproject-0.shortname':'test/test-subproject',
-                    'subproject-0.name':'Tst Sbprj',
-                    'subproject-0.ordinal':'100',
-                    })
+                'subproject-0.shortname': 'test/test-subproject',
+                'subproject-0.name': 'Tst Sbprj',
+                'subproject-0.ordinal': '100',
+            })
         r = self.app.get('/admin/overview')
         assert 'Tst Sbprj' in r
         # Remove a subproject
         with audits('delete subproject test/test-subproject'):
             self.app.post('/admin/update_mounts', params={
-                    'subproject-0.delete':'on',
-                    'subproject-0.shortname':'test/test-subproject',
-                    'new.ep_name':'',
-                    })
+                'subproject-0.delete': 'on',
+                'subproject-0.shortname': 'test/test-subproject',
+                'new.ep_name': '',
+            })
 
         # Add a tool
         with audits('install tool test-tool'):
             r = self.app.post('/admin/update_mounts', params={
-                    'new.install':'install',
-                    'new.ep_name':'Wiki',
-                    'new.ordinal':'1',
-                    'new.mount_point':'test-tool',
-                    'new.mount_label':'Test Tool'})
+                'new.install': 'install',
+                'new.ep_name': 'Wiki',
+                'new.ordinal': '1',
+                'new.mount_point': 'test-tool',
+                'new.mount_label': 'Test Tool'})
         assert 'error' not in self.webflash(r)
         # check tool in the nav
         r = self.app.get('/p/test/test-tool/').follow()
-        active_link = r.html.findAll('li',{'class':'selected'})
+        active_link = r.html.findAll('li', {'class': 'selected'})
         assert_equals(len(active_link), 1)
         assert active_link[0].contents[1]['href'] == '/p/test/test-tool/'
         with audits('install tool test-tool2'):
             r = self.app.post('/admin/update_mounts', params={
-                    'new.install':'install',
-                    'new.ep_name':'Wiki',
-                    'new.ordinal':'1',
-                    'new.mount_point':'test-tool2',
-                    'new.mount_label':'Test Tool2'})
+                'new.install': 'install',
+                'new.ep_name': 'Wiki',
+                'new.ordinal': '1',
+                'new.mount_point': 'test-tool2',
+                'new.mount_label': 'Test Tool2'})
         assert 'error' not in self.webflash(r)
         # check the nav - tools of same type are grouped
         r = self.app.get('/p/test/test-tool/Home/')
-        active_link = r.html.findAll('li',{'class':'selected'})
+        active_link = r.html.findAll('li', {'class': 'selected'})
         assert len(active_link) == 2
         assert active_link[0].contents[1]['href'] == '/p/test/_list/wiki'
-        assert r.html.findAll('a', {'href':'/p/test/test-tool2/'})
-        assert r.html.findAll('a', {'href':'/p/test/test-tool/'})
+        assert r.html.findAll('a', {'href': '/p/test/test-tool2/'})
+        assert r.html.findAll('a', {'href': '/p/test/test-tool/'})
 
         # check can't create dup tool
         r = self.app.post('/admin/update_mounts', params={
-                'new.install':'install',
-                'new.ep_name':'Wiki',
-                'new.ordinal':'1',
-                'new.mount_point':'test-tool',
-                'new.mount_label':'Test Tool'})
+            'new.install': 'install',
+            'new.ep_name': 'Wiki',
+            'new.ordinal': '1',
+            'new.mount_point': 'test-tool',
+            'new.mount_label': 'Test Tool'})
         assert 'error' in self.webflash(r)
         # Rename a tool
         with audits('update tool test-tool'):
             self.app.post('/admin/update_mounts', params={
-                    'tool-0.mount_point':'test-tool',
-                    'tool-0.mount_label':'Tst Tuul',
-                    'tool-0.ordinal':'200',
-                    })
+                'tool-0.mount_point': 'test-tool',
+                'tool-0.mount_label': 'Tst Tuul',
+                'tool-0.ordinal': '200',
+            })
         r = self.app.get('/admin/overview')
         assert 'Tst Tuul' in r
         # Remove a tool
         with audits('uninstall tool test-tool'):
             self.app.post('/admin/update_mounts', params={
-                    'tool-0.delete':'on',
-                    'tool-0.mount_point':'test-tool',
-                    'new.ep_name':'',
-                    })
+                'tool-0.delete': 'on',
+                'tool-0.mount_point': 'test-tool',
+                'new.ep_name': '',
+            })
 
         # Check the audit log
         r = self.app.get('/admin/audit/')
@@ -178,12 +183,14 @@ class TestProjectAdmin(TestController):
 
     @td.with_wiki
     def test_block_user_empty_data(self):
-        r = self.app.post('/admin/wiki/block_user', params={'username': '', 'perm': '', 'reason': ''})
+        r = self.app.post('/admin/wiki/block_user',
+                          params={'username': '', 'perm': '', 'reason': ''})
         assert_equals(r.json, dict(error='Enter username'))
 
     @td.with_wiki
     def test_unblock_user_empty_data(self):
-        r = self.app.post('/admin/wiki/unblock_user', params={'user_id': '', 'perm': ''})
+        r = self.app.post('/admin/wiki/unblock_user',
+                          params={'user_id': '', 'perm': ''})
         assert_equals(r.json, dict(error='Select user to unblock'))
 
     @td.with_wiki
@@ -192,8 +199,10 @@ class TestProjectAdmin(TestController):
         assert '<input type="checkbox" name="user_id"' not in r
 
         user = M.User.by_username('test-admin')
-        r = self.app.post('/admin/wiki/block_user', params={'username': 'test-admin', 'perm': 'read', 'reason': 'Comment'})
-        assert_equals(r.json, dict(user_id=str(user._id), username='test-admin', reason='Comment'))
+        r = self.app.post('/admin/wiki/block_user',
+                          params={'username': 'test-admin', 'perm': 'read', 'reason': 'Comment'})
+        assert_equals(
+            r.json, dict(user_id=str(user._id), username='test-admin', reason='Comment'))
         user = M.User.by_username('test-admin')
         admin_role = M.ProjectRole.by_user(user)
         app = M.Project.query.get(shortname='test').app_instance('wiki')
@@ -204,7 +213,8 @@ class TestProjectAdmin(TestController):
 
     @td.with_wiki
     def test_unblock_user(self):
-        r = self.app.post('/admin/wiki/block_user', params={'username': 'test-admin', 'perm': 'read'})
+        r = self.app.post('/admin/wiki/block_user',
+                          params={'username': 'test-admin', 'perm': 'read'})
         user = M.User.by_username('test-admin')
         admin_role = M.ProjectRole.by_user(user)
         app = M.Project.query.get(shortname='test').app_instance('wiki')
@@ -213,7 +223,8 @@ class TestProjectAdmin(TestController):
         assert '<input type="checkbox" name="user_id" value="%s">test-admin' % user._id in r
         app = M.Project.query.get(shortname='test').app_instance('wiki')
         assert M.ACL.contains(ace, app.acl) is not None
-        r = self.app.post('/admin/wiki/unblock_user', params={'user_id': str(user._id), 'perm': 'read'})
+        r = self.app.post('/admin/wiki/unblock_user',
+                          params={'user_id': str(user._id), 'perm': 'read'})
         assert_equals(r.json, dict(unblocked=[str(user._id)]))
         assert M.ACL.contains(ace, app.acl) is None
         r = self.app.get('/admin/wiki/permissions')
@@ -221,8 +232,10 @@ class TestProjectAdmin(TestController):
 
     @td.with_wiki
     def test_block_unblock_multiple_users(self):
-        self.app.post('/admin/wiki/block_user', params={'username': 'test-admin', 'perm': 'read', 'reason': 'Spammer'})
-        self.app.post('/admin/wiki/block_user', params={'username': 'test-user', 'perm': 'read'})
+        self.app.post('/admin/wiki/block_user',
+                      params={'username': 'test-admin', 'perm': 'read', 'reason': 'Spammer'})
+        self.app.post('/admin/wiki/block_user',
+                      params={'username': 'test-user', 'perm': 'read'})
         admin = M.User.by_username('test-admin')
         user = M.User.by_username('test-user')
         admin_role = M.ProjectRole.by_user(admin)
@@ -236,8 +249,10 @@ class TestProjectAdmin(TestController):
         assert '<input type="checkbox" name="user_id" value="%s">test-admin (Spammer)' % admin._id in r
         assert '<input type="checkbox" name="user_id" value="%s">test-user' % user._id in r
 
-        self.app.post('/admin/wiki/unblock_user', params={'user_id': str(user._id), 'perm': 'read'})
-        self.app.post('/admin/wiki/unblock_user', params={'user_id': str(admin._id), 'perm': 'read'})
+        self.app.post('/admin/wiki/unblock_user',
+                      params={'user_id': str(user._id), 'perm': 'read'})
+        self.app.post('/admin/wiki/unblock_user',
+                      params={'user_id': str(admin._id), 'perm': 'read'})
         app = M.Project.query.get(shortname='test').app_instance('wiki')
         assert M.ACL.contains(deny_admin, app.acl) is None
         assert M.ACL.contains(deny_user, app.acl) is None
@@ -246,8 +261,10 @@ class TestProjectAdmin(TestController):
 
     @td.with_wiki
     def test_blocked_users_remains_after_saving_all_permissions(self):
-        self.app.post('/admin/wiki/block_user', params={'username': 'test-user', 'perm': 'read', 'reason': 'Comment'})
-        self.app.post('/admin/wiki/block_user', params={'username': 'test-user', 'perm': 'post', 'reason': 'Comment'})
+        self.app.post('/admin/wiki/block_user',
+                      params={'username': 'test-user', 'perm': 'read', 'reason': 'Comment'})
+        self.app.post('/admin/wiki/block_user',
+                      params={'username': 'test-user', 'perm': 'post', 'reason': 'Comment'})
         user = M.User.by_username('test-user')
         user_role = M.ProjectRole.by_user(user)
         app = M.Project.query.get(shortname='test').app_instance('wiki')
@@ -268,39 +285,40 @@ class TestProjectAdmin(TestController):
 
     def test_tool_permissions(self):
         BUILTIN_APPS = ['activity', 'blog', 'discussion', 'git', 'link',
-                'shorturl', 'svn', 'tickets', 'userstats', 'wiki']
+                        'shorturl', 'svn', 'tickets', 'userstats', 'wiki']
         self.app.get('/admin/')
         project = M.Project.query.get(shortname='test')
         for i, ep in enumerate(pkg_resources.iter_entry_points('allura')):
             App = ep.load()
             tool = ep.name
             cfg = M.AppConfig(
-                    project_id=project._id,
-                    tool_name=tool,
-                    options={'mount_point': '', 'mount_label': ''})
+                project_id=project._id,
+                tool_name=tool,
+                options={'mount_point': '', 'mount_label': ''})
             app = App(project, cfg)
             if not app.installable or ep.name.lower() not in BUILTIN_APPS:
                 continue
             with audits('install tool test-%d' % i):
                 self.app.post('/admin/update_mounts', params={
-                        'new.install':'install',
-                        'new.ep_name':tool,
-                        'new.ordinal':str(i),
-                        'new.mount_point':'test-%d' % i,
-                        'new.mount_label':tool })
+                    'new.install': 'install',
+                    'new.ep_name': tool,
+                    'new.ordinal': str(i),
+                    'new.mount_point': 'test-%d' % i,
+                    'new.mount_label': tool})
             r = self.app.get('/admin/test-%d/permissions' % i)
             cards = [
                 tag for tag in r.html.findAll('input')
                 if (
                     tag.get('type') == 'hidden' and
                     tag['name'].startswith('card-') and
-                    tag['name'].endswith('.id')) ]
+                    tag['name'].endswith('.id'))]
             assert len(cards) == len(app.permissions), cards
 
     def test_tool_list(self):
         r = self.app.get('/admin/tools')
-        new_ep_opts = r.html.findAll('a',{'class':"install_trig"})
-        tool_strings = [ ' '.join(opt.find('span').string.strip().split()) for opt in new_ep_opts ]
+        new_ep_opts = r.html.findAll('a', {'class': "install_trig"})
+        tool_strings = [' '.join(opt.find('span').string.strip().split())
+                        for opt in new_ep_opts]
         expected_tools = [
             'Wiki',
             'Tickets',
@@ -318,76 +336,82 @@ class TestProjectAdmin(TestController):
             available_tools = self.get_available_tools()
             assert_in('Wiki', available_tools)
             r = self.app.post('/admin/update_mounts/', params={
-                    'new.install': 'install',
-                    'new.ep_name': 'Wiki',
-                    'new.ordinal': '1',
-                    'new.mount_point': 'wiki',
-                    'new.mount_label': 'Wiki'})
+                'new.install': 'install',
+                'new.ep_name': 'Wiki',
+                'new.ordinal': '1',
+                'new.mount_point': 'wiki',
+                'new.mount_label': 'Wiki'})
             available_tools = self.get_available_tools()
             assert_not_in('Wiki', available_tools)
             r = self.app.post('/admin/update_mounts/', params={
-                    'new.install': 'install',
-                    'new.ep_name': 'Wiki',
-                    'new.ordinal': '1',
-                    'new.mount_point': 'wiki2',
-                    'new.mount_label': 'Wiki 2'})
+                'new.install': 'install',
+                'new.ep_name': 'Wiki',
+                'new.ordinal': '1',
+                'new.mount_point': 'wiki2',
+                'new.mount_label': 'Wiki 2'})
             assert 'error' in self.webflash(r)
             assert 'limit exceeded' in self.webflash(r)
 
     def test_grouping_threshold(self):
         r = self.app.get('/admin/tools')
-        grouping_threshold = r.html.find('input',{'name':'grouping_threshold'})
+        grouping_threshold = r.html.find(
+            'input', {'name': 'grouping_threshold'})
         assert_equals(grouping_threshold['value'], '1')
         r = self.app.post('/admin/configure_tool_grouping', params={
-                'grouping_threshold': '2',
-            }).follow()
-        grouping_threshold = r.html.find('input',{'name':'grouping_threshold'})
+            'grouping_threshold': '2',
+        }).follow()
+        grouping_threshold = r.html.find(
+            'input', {'name': 'grouping_threshold'})
         assert_equals(grouping_threshold['value'], '2')
         r = self.app.get('/admin/tools')
-        grouping_threshold = r.html.find('input',{'name':'grouping_threshold'})
+        grouping_threshold = r.html.find(
+            'input', {'name': 'grouping_threshold'})
         assert_equals(grouping_threshold['value'], '2')
 
     def test_project_icon(self):
         file_name = 'neo-icon-set-454545-256x350.png'
-        file_path = os.path.join(allura.__path__[0],'nf','allura','images',file_name)
+        file_path = os.path.join(
+            allura.__path__[0], 'nf', 'allura', 'images', file_name)
         file_data = file(file_path).read()
         upload = ('icon', file_name, file_data)
 
         self.app.get('/admin/')
         with audits('update project icon'):
             self.app.post('/admin/update', params=dict(
-                    name='Test Project',
-                    shortname='test',
-                    short_description='A Test Project'),
-                    upload_files=[upload])
+                name='Test Project',
+                shortname='test',
+                short_description='A Test Project'),
+                upload_files=[upload])
         r = self.app.get('/p/test/icon')
         image = PIL.Image.open(StringIO.StringIO(r.body))
-        assert image.size == (48,48)
+        assert image.size == (48, 48)
 
         r = self.app.get('/p/test/icon?foo=bar')
 
     def test_project_screenshot(self):
         file_name = 'neo-icon-set-454545-256x350.png'
-        file_path = os.path.join(allura.__path__[0],'nf','allura','images',file_name)
+        file_path = os.path.join(
+            allura.__path__[0], 'nf', 'allura', 'images', file_name)
         file_data = file(file_path).read()
         upload = ('screenshot', file_name, file_data)
 
         self.app.get('/admin/')
         with audits('add screenshot'):
             self.app.post('/admin/add_screenshot', params=dict(
-                    caption='test me'),
-                    upload_files=[upload])
+                caption='test me'),
+                upload_files=[upload])
         p_nbhd = M.Neighborhood.query.get(name='Projects')
-        project = M.Project.query.get(shortname='test', neighborhood_id=p_nbhd._id)
+        project = M.Project.query.get(
+            shortname='test', neighborhood_id=p_nbhd._id)
         filename = project.get_screenshots()[0].filename
-        r = self.app.get('/p/test/screenshot/'+filename)
+        r = self.app.get('/p/test/screenshot/' + filename)
         uploaded = PIL.Image.open(file_path)
         screenshot = PIL.Image.open(StringIO.StringIO(r.body))
         assert uploaded.size == screenshot.size
-        r = self.app.get('/p/test/screenshot/'+filename+'/thumb')
+        r = self.app.get('/p/test/screenshot/' + filename + '/thumb')
         thumb = PIL.Image.open(StringIO.StringIO(r.body))
-        assert thumb.size == (150,150)
-        #FIX: home pages don't currently support screenshots (now that they're a wiki);
+        assert thumb.size == (150, 150)
+        # FIX: home pages don't currently support screenshots (now that they're a wiki);
         # reinstate this code (or appropriate) when we have a macro for that
         #r = self.app.get('/p/test/home/')
         #assert '/p/test/screenshot/'+filename in r
@@ -407,22 +431,22 @@ class TestProjectAdmin(TestController):
     def test_sort_screenshots(self):
         for file_name in ('admin_24.png', 'admin_32.png'):
             file_path = os.path.join(allura.__path__[0], 'nf', 'allura',
-                    'images', file_name)
+                                     'images', file_name)
             file_data = file(file_path).read()
             upload = ('screenshot', file_name, file_data)
             self.app.post('/admin/add_screenshot', params=dict(
-                    caption=file_name),
-                    upload_files=[upload])
+                caption=file_name),
+                upload_files=[upload])
 
         p_nbhd = M.Neighborhood.query.get(name='Projects')
         project = M.Project.query.get(shortname='test',
-                neighborhood_id=p_nbhd._id)
+                                      neighborhood_id=p_nbhd._id)
         # first uploaded is first by default
         screenshots = project.get_screenshots()
         assert_equals(screenshots[0].filename, 'admin_24.png')
         # reverse order
         params = dict((str(ss._id), len(screenshots) - 1 - i)
-                for i, ss in enumerate(screenshots))
+                      for i, ss in enumerate(screenshots))
         self.app.post('/admin/sort_screenshots', params)
         assert_equals(project.get_screenshots()[0].filename, 'admin_32.png')
 
@@ -430,40 +454,46 @@ class TestProjectAdmin(TestController):
         # create a subproject
         with audits('create subproject sub-del-undel'):
             self.app.post('/admin/update_mounts', params={
-                    'new.install':'install',
-                    'new.ep_name':'',
-                    'new.ordinal':'1',
-                    'new.mount_point':'sub-del-undel',
-                    'new.mount_label':'sub-del-undel'})
+                'new.install': 'install',
+                'new.ep_name': '',
+                'new.ordinal': '1',
+                'new.mount_point': 'sub-del-undel',
+                'new.mount_label': 'sub-del-undel'})
         r = self.app.get('/p/test/admin/overview')
         assert 'This project has been deleted and is not visible to non-admin users' not in r
-        assert r.html.find('input',{'name':'removal','value':''}).has_key('checked')
-        assert not r.html.find('input',{'name':'removal','value':'deleted'}).has_key('checked')
+        assert r.html.find(
+            'input', {'name': 'removal', 'value': ''}).has_key('checked')
+        assert not r.html.find(
+            'input', {'name': 'removal', 'value': 'deleted'}).has_key('checked')
         with audits('delete project'):
             self.app.post('/admin/update', params=dict(
-                    name='Test Project',
-                    shortname='test',
-                    removal='deleted',
-                    short_description='A Test Project',
-                    delete='on'))
+                name='Test Project',
+                shortname='test',
+                removal='deleted',
+                short_description='A Test Project',
+                delete='on'))
         r = self.app.get('/p/test/admin/overview')
         assert 'This project has been deleted and is not visible to non-admin users' in r
-        assert not r.html.find('input',{'name':'removal','value':''}).has_key('checked')
-        assert r.html.find('input',{'name':'removal','value':'deleted'}).has_key('checked')
+        assert not r.html.find(
+            'input', {'name': 'removal', 'value': ''}).has_key('checked')
+        assert r.html.find(
+            'input', {'name': 'removal', 'value': 'deleted'}).has_key('checked')
         # make sure subprojects get deleted too
         r = self.app.get('/p/test/sub-del-undel/admin/overview')
         assert 'This project has been deleted and is not visible to non-admin users' in r
         with audits('undelete project'):
             self.app.post('/admin/update', params=dict(
-                    name='Test Project',
-                    shortname='test',
-                    removal='',
-                    short_description='A Test Project',
-                    undelete='on'))
+                name='Test Project',
+                shortname='test',
+                removal='',
+                short_description='A Test Project',
+                undelete='on'))
         r = self.app.get('/p/test/admin/overview')
         assert 'This project has been deleted and is not visible to non-admin users' not in r
-        assert r.html.find('input',{'name':'removal','value':''}).has_key('checked')
-        assert not r.html.find('input',{'name':'removal','value':'deleted'}).has_key('checked')
+        assert r.html.find(
+            'input', {'name': 'removal', 'value': ''}).has_key('checked')
+        assert not r.html.find(
+            'input', {'name': 'removal', 'value': 'deleted'}).has_key('checked')
 
     def test_project_delete_not_allowed(self):
         # turn off project delete option
@@ -474,39 +504,42 @@ class TestProjectAdmin(TestController):
             # create a subproject
             with audits('create subproject sub-no-del'):
                 self.app.post('/admin/update_mounts', params={
-                        'new.install':'install',
-                        'new.ep_name':'',
-                        'new.ordinal':'1',
-                        'new.mount_point':'sub-no-del',
-                        'new.mount_label':'sub-no-del'})
+                    'new.install': 'install',
+                    'new.ep_name': '',
+                    'new.ordinal': '1',
+                    'new.mount_point': 'sub-no-del',
+                    'new.mount_label': 'sub-no-del'})
             # root project doesn't have delete option
             r = self.app.get('/p/test/admin/overview')
-            assert not r.html.find('input',{'name':'removal','value':'deleted'})
+            assert not r.html.find(
+                'input', {'name': 'removal', 'value': 'deleted'})
             # subprojects can still be deleted
             r = self.app.get('/p/test/sub-no-del/admin/overview')
-            assert r.html.find('input',{'name':'removal','value':'deleted'})
+            assert r.html.find(
+                'input', {'name': 'removal', 'value': 'deleted'})
             # attempt to delete root project won't do anything
             self.app.post('/admin/update', params=dict(
-                    name='Test Project',
-                    shortname='test',
-                    removal='deleted',
-                    short_description='A Test Project',
-                    delete='on'))
+                name='Test Project',
+                shortname='test',
+                removal='deleted',
+                short_description='A Test Project',
+                delete='on'))
             r = self.app.get('/p/test/admin/overview')
             assert 'This project has been deleted and is not visible to non-admin users' not in r
             # make sure subproject delete works
             with audits(
-                'change project removal status to deleted',
-                'delete project'):
+                    'change project removal status to deleted',
+                    'delete project'):
                 self.app.post('/p/test/sub-no-del/admin/update', params=dict(
-                        name='sub1',
-                        shortname='sub1',
-                        removal='deleted',
-                        short_description='A Test Project',
-                        delete='on'))
+                    name='sub1',
+                    shortname='sub1',
+                    removal='deleted',
+                    short_description='A Test Project',
+                    delete='on'))
             r = self.app.get('/p/test/sub-no-del/admin/overview')
             assert 'This project has been deleted and is not visible to non-admin users' in r
-            assert r.html.find('input',{'name':'removal','value':'deleted'}).has_key('checked')
+            assert r.html.find(
+                'input', {'name': 'removal', 'value': 'deleted'}).has_key('checked')
         finally:
             if old_allow_project_delete == ():
                 del config['allow_project_delete']
@@ -563,14 +596,14 @@ class TestProjectAdmin(TestController):
 
         with audits('updated "admin" permission: "Admin" => "Admin, Developer" for wiki'):
             self.app.post('/admin/wiki/update', params={
-                        'card-0.new': opt_developer['value'],
-                        'card-0.value': opt_admin['value'],
-                        'card-0.id': 'admin'})
+                'card-0.new': opt_developer['value'],
+                'card-0.value': opt_admin['value'],
+                'card-0.id': 'admin'})
 
         with audits('updated "admin" permission: "Admin, Developer" => "Admin" for wiki'):
             self.app.post('/admin/wiki/update', params={
-                        'card-0.value': opt_admin['value'],
-                        'card-0.id': 'admin'})
+                'card-0.value': opt_admin['value'],
+                'card-0.id': 'admin'})
 
     def test_project_permissions(self):
         r = self.app.get('/admin/permissions/')
@@ -582,11 +615,12 @@ class TestProjectAdmin(TestController):
         assert opt_developer.name == 'option'
         with audits('updated "admin" permissions: "Admin" => "Admin,Developer"'):
             r = self.app.post('/admin/permissions/update', params={
-                    'card-0.new': opt_developer['value'],
-                    'card-0.value': opt_admin['value'],
-                    'card-0.id': 'admin'})
+                'card-0.new': opt_developer['value'],
+                'card-0.value': opt_admin['value'],
+                'card-0.id': 'admin'})
         r = self.app.get('/admin/permissions/')
-        assigned_ids = [t['value'] for t in r.html.findAll('input', {'name': 'card-0.value'})]
+        assigned_ids = [t['value']
+                        for t in r.html.findAll('input', {'name': 'card-0.value'})]
         assert len(assigned_ids) == 2
         assert opt_developer['value'] in assigned_ids
         assert opt_admin['value'] in assigned_ids
@@ -594,11 +628,11 @@ class TestProjectAdmin(TestController):
     def test_subproject_permissions(self):
         with audits('create subproject test-subproject'):
             self.app.post('/admin/update_mounts', params={
-                    'new.install':'install',
-                    'new.ep_name':'',
-                    'new.ordinal':'1',
-                    'new.mount_point':'test-subproject',
-                    'new.mount_label':'Test Subproject'})
+                'new.install': 'install',
+                'new.ep_name': '',
+                'new.ordinal': '1',
+                'new.mount_point': 'test-subproject',
+                'new.mount_label': 'Test Subproject'})
         r = self.app.get('/test-subproject/admin/permissions/')
         assert len(r.html.findAll('input', {'name': 'card-0.value'})) == 0
         select = r.html.find('select', {'name': 'card-0.new'})
@@ -608,34 +642,40 @@ class TestProjectAdmin(TestController):
         assert opt_developer.name == 'option'
         with audits('updated "admin" permissions: "" => "Admin,Developer"'):
             r = self.app.post('/test-subproject/admin/permissions/update', params={
-                    'card-0.new': opt_developer['value'],
-                    'card-0.value': opt_admin['value'],
-                    'card-0.id': 'admin'})
+                'card-0.new': opt_developer['value'],
+                'card-0.value': opt_admin['value'],
+                'card-0.id': 'admin'})
         r = self.app.get('/test-subproject/admin/permissions/')
-        assigned_ids = [t['value'] for t in r.html.findAll('input', {'name': 'card-0.value'})]
+        assigned_ids = [t['value']
+                        for t in r.html.findAll('input', {'name': 'card-0.value'})]
         assert len(assigned_ids) == 2
         assert opt_developer['value'] in assigned_ids
         assert opt_admin['value'] in assigned_ids
 
     def test_project_groups(self):
         r = self.app.get('/admin/groups/')
-        dev_holder = r.html.find('table',{'id':'usergroup_admin'}).findAll('tr')[2]
+        dev_holder = r.html.find(
+            'table', {'id': 'usergroup_admin'}).findAll('tr')[2]
         developer_id = dev_holder['data-group']
         with audits('add user test-user to Developer'):
             r = self.app.post('/admin/groups/add_user', params={
-                    'role_id': developer_id,
-                    'username': 'test-user'})
+                'role_id': developer_id,
+                'username': 'test-user'})
         r = self.app.get('/admin/groups/')
-        dev_holder = r.html.find('table',{'id':'usergroup_admin'}).findAll('tr')[2]
-        users = dev_holder.find('ul',{'class':'users'}).findAll('li',{'class':'deleter'})
+        dev_holder = r.html.find(
+            'table', {'id': 'usergroup_admin'}).findAll('tr')[2]
+        users = dev_holder.find('ul', {'class': 'users'}).findAll(
+            'li', {'class': 'deleter'})
         assert 'test-user' in users[0]['data-user']
         # Make sure we can open role page for builtin role
-        r = self.app.get('/admin/groups/' + developer_id + '/', validate_chunk=True)
+        r = self.app.get('/admin/groups/' + developer_id +
+                         '/', validate_chunk=True)
 
     def test_new_admin_subscriptions(self):
         """Newly added admin must be subscribed to all the tools in the project"""
         r = self.app.get('/admin/groups/')
-        admin_holder = r.html.find('table', {'id': 'usergroup_admin'}).findAll('tr')[1]
+        admin_holder = r.html.find(
+            'table', {'id': 'usergroup_admin'}).findAll('tr')[1]
         admin_id = admin_holder['data-group']
         with audits('add user test-user to Admin'):
             self.app.post('/admin/groups/add_user', params={
@@ -645,13 +685,15 @@ class TestProjectAdmin(TestController):
         p = M.Project.query.get(shortname='test', neighborhood_id=p_nbhd._id)
         uid = M.User.by_username('test-user')._id
         for ac in p.app_configs:
-            sub = M.Mailbox.subscribed(user_id=uid, project_id=p._id, app_config_id=ac._id)
+            sub = M.Mailbox.subscribed(
+                user_id=uid, project_id=p._id, app_config_id=ac._id)
             assert sub, 'New admin not subscribed to app %s' % ac
 
     def test_new_user_subscriptions(self):
         """Newly added user must not be subscribed to all the tools in the project if he is not admin"""
         r = self.app.get('/admin/groups/')
-        dev_holder = r.html.find('table',{'id':'usergroup_admin'}).findAll('tr')[2]
+        dev_holder = r.html.find(
+            'table', {'id': 'usergroup_admin'}).findAll('tr')[2]
         developer_id = dev_holder['data-group']
         with audits('add user test-user to Developer'):
             self.app.post('/admin/groups/add_user', params={
@@ -661,33 +703,37 @@ class TestProjectAdmin(TestController):
         p = M.Project.query.get(shortname='test', neighborhood_id=p_nbhd._id)
         uid = M.User.by_username('test-user')._id
         for ac in p.app_configs:
-            sub = M.Mailbox.subscribed(user_id=uid, project_id=p._id, app_config_id=ac._id)
+            sub = M.Mailbox.subscribed(
+                user_id=uid, project_id=p._id, app_config_id=ac._id)
             assert not sub, 'New user subscribed to app %s' % ac
 
     def test_subroles(self):
         """Make sure subroles are preserved during group updates."""
         def check_roles(r):
-            dev_holder = r.html.find('table',{'id':'usergroup_admin'}).findAll('tr')[2]
-            mem_holder = r.html.find('table',{'id':'usergroup_admin'}).findAll('tr')[3]
+            dev_holder = r.html.find(
+                'table', {'id': 'usergroup_admin'}).findAll('tr')[2]
+            mem_holder = r.html.find(
+                'table', {'id': 'usergroup_admin'}).findAll('tr')[3]
             assert 'All users in Admin group' in str(dev_holder)
             assert 'All users in Developer group' in str(mem_holder)
 
         r = self.app.get('/admin/groups/')
 
-        admin_holder = r.html.find('table',{'id':'usergroup_admin'}).findAll('tr')[1]
+        admin_holder = r.html.find(
+            'table', {'id': 'usergroup_admin'}).findAll('tr')[1]
         admin_id = admin_holder['data-group']
         # test that subroles are intact after user added
         with audits('add user test-user to Admin'):
             r = self.app.post('/admin/groups/add_user', params={
-                    'role_id': admin_id,
-                    'username': 'test-user'})
+                'role_id': admin_id,
+                'username': 'test-user'})
         r = self.app.get('/admin/groups/')
         check_roles(r)
         # test that subroles are intact after user deleted
         with audits('remove user test-user from Admin'):
             r = self.app.post('/admin/groups/remove_user', params={
-                    'role_id': admin_id,
-                    'username': 'test-user'})
+                'role_id': admin_id,
+                'username': 'test-user'})
         r = self.app.get('/admin/groups/')
         check_roles(r)
 
@@ -695,56 +741,66 @@ class TestProjectAdmin(TestController):
         """Must always have at least one user with the Admin role (and anon
         doesn't count)."""
         r = self.app.get('/admin/groups/')
-        admin_holder = r.html.find('table',{'id':'usergroup_admin'}).findAll('tr')[1]
+        admin_holder = r.html.find(
+            'table', {'id': 'usergroup_admin'}).findAll('tr')[1]
         admin_id = admin_holder['data-group']
-        users = admin_holder.find('ul',{'class':'users'}).findAll('li',{'class':'deleter'})
+        users = admin_holder.find('ul', {'class': 'users'}).findAll(
+            'li', {'class': 'deleter'})
         assert len(users) == 1
         r = self.app.post('/admin/groups/remove_user', params={
-                'role_id': admin_id,
-                'username': 'admin1'})
-        assert r.json['error'] == 'You must have at least one user with the Admin role.'
+            'role_id': admin_id,
+            'username': 'admin1'})
+        assert r.json[
+            'error'] == 'You must have at least one user with the Admin role.'
         r = self.app.get('/admin/groups/')
-        admin_holder = r.html.find('table',{'id':'usergroup_admin'}).findAll('tr')[1]
-        users = admin_holder.find('ul',{'class':'users'}).findAll('li',{'class':'deleter'})
+        admin_holder = r.html.find(
+            'table', {'id': 'usergroup_admin'}).findAll('tr')[1]
+        users = admin_holder.find('ul', {'class': 'users'}).findAll(
+            'li', {'class': 'deleter'})
         assert len(users) == 1
 
     def test_cannot_add_anon_to_group(self):
         r = self.app.get('/admin/groups/')
-        dev_holder = r.html.find('table',{'id':'usergroup_admin'}).findAll('tr')[2]
+        dev_holder = r.html.find(
+            'table', {'id': 'usergroup_admin'}).findAll('tr')[2]
         developer_id = dev_holder['data-group']
         r = self.app.post('/admin/groups/add_user', params={
-                'role_id': developer_id,
-                'username': ''})
+            'role_id': developer_id,
+            'username': ''})
         assert r.json['error'] == 'You must choose a user to add.'
         r = self.app.get('/admin/groups/')
-        dev_holder = r.html.find('table',{'id':'usergroup_admin'}).findAll('tr')[2]
-        users = dev_holder.find('ul',{'class':'users'}).findAll('li',{'class':'deleter'})
+        dev_holder = r.html.find(
+            'table', {'id': 'usergroup_admin'}).findAll('tr')[2]
+        users = dev_holder.find('ul', {'class': 'users'}).findAll(
+            'li', {'class': 'deleter'})
         # no user was added
         assert len(users) == 0
         assert M.ProjectRole.query.find(dict(
-                name='*anonymous', user_id=None,
-                roles={'$ne': []})).count() == 0
+            name='*anonymous', user_id=None,
+            roles={'$ne': []})).count() == 0
 
     def test_project_multi_groups(self):
         r = self.app.get('/admin/groups/')
         user_id = M.User.by_username('test-admin')._id
-        admin_holder = r.html.find('table',{'id':'usergroup_admin'}).findAll('tr')[1]
+        admin_holder = r.html.find(
+            'table', {'id': 'usergroup_admin'}).findAll('tr')[1]
         admin_id = admin_holder['data-group']
         with audits('add user test-user to Admin'):
             r = self.app.post('/admin/groups/add_user', params={
-                    'role_id': admin_id,
-                    'username': 'test-user'})
-            assert 'error' not in r.json
-        r = self.app.post('/admin/groups/add_user', params={
                 'role_id': admin_id,
                 'username': 'test-user'})
-        assert r.json['error'] == 'Test User (test-user) is already in the group Admin.'
+            assert 'error' not in r.json
+        r = self.app.post('/admin/groups/add_user', params={
+            'role_id': admin_id,
+            'username': 'test-user'})
+        assert r.json[
+            'error'] == 'Test User (test-user) is already in the group Admin.'
         r = self.app.get('/admin/groups/')
         assert 'test-user' in str(r), r.showbrowser()
         with audits('remove user test-user from Admin'):
             r = self.app.post('/admin/groups/remove_user', params={
-                    'role_id': admin_id,
-                    'username': 'test-user'})
+                'role_id': admin_id,
+                'username': 'test-user'})
         r = self.app.get('/admin/groups/')
         assert 'test-user' not in str(r), r.showbrowser()
 
@@ -752,12 +808,15 @@ class TestProjectAdmin(TestController):
     def test_new_group(self):
         r = self.app.get('/admin/groups/new', validate_chunk=True)
         with audits('create group Developer'):
-            r = self.app.post('/admin/groups/create', params={'name': 'Developer'})
+            r = self.app.post('/admin/groups/create',
+                              params={'name': 'Developer'})
         assert 'error' in self.webflash(r)
         with audits('create group RoleNew1'):
-            r = self.app.post('/admin/groups/create', params={'name': 'RoleNew1'})
+            r = self.app.post('/admin/groups/create',
+                              params={'name': 'RoleNew1'})
         r = self.app.get('/admin/groups/')
-        role_holder = r.html.find('table',{'id':'usergroup_admin'}).findAll('tr')[4]
+        role_holder = r.html.find(
+            'table', {'id': 'usergroup_admin'}).findAll('tr')[4]
         assert 'RoleNew1' in str(role_holder)
         role_id = role_holder['data-group']
         r = self.app.get('/admin/groups/' + role_id + '/', validate_chunk=True)
@@ -767,120 +826,147 @@ class TestProjectAdmin(TestController):
         assert 'already exists' in self.webflash(r)
 
         with audits('update group name RoleNew1=>rleNew2'):
-            r = self.app.post('/admin/groups/' + str(role_id) + '/update', params={'_id': role_id, 'name': 'rleNew2'}).follow()
+            r = self.app.post('/admin/groups/' + str(role_id) + '/update',
+                              params={'_id': role_id, 'name': 'rleNew2'}).follow()
         assert 'RoleNew1' not in r
         assert 'rleNew2' in r
 
         # add test-user to role
-        role_holder = r.html.find('table',{'id':'usergroup_admin'}).findAll('tr')[4]
+        role_holder = r.html.find(
+            'table', {'id': 'usergroup_admin'}).findAll('tr')[4]
         rleNew2_id = role_holder['data-group']
         with audits('add user test-user to rleNew2'):
             r = self.app.post('/admin/groups/add_user', params={
-                    'role_id': rleNew2_id,
-                    'username': 'test-user'})
+                'role_id': rleNew2_id,
+                'username': 'test-user'})
 
         with audits('delete group rleNew2'):
             r = self.app.post('/admin/groups/delete_group', params={
-                    'group_name': 'rleNew2'})
+                'group_name': 'rleNew2'})
         assert 'deleted' in self.webflash(r)
         r = self.app.get('/admin/groups/', status=200)
-        roles = [str(t) for t in r.html.findAll('td',{'class':'group'})]
+        roles = [str(t) for t in r.html.findAll('td', {'class': 'group'})]
         assert 'RoleNew1' not in roles
         assert 'rleNew2' not in roles
 
-        # make sure can still access homepage after one of user's roles were deleted
-        r = self.app.get('/p/test/wiki/', extra_environ=dict(username='test-user')).follow()
+        # make sure can still access homepage after one of user's roles were
+        # deleted
+        r = self.app.get('/p/test/wiki/',
+                         extra_environ=dict(username='test-user')).follow()
         assert r.status == '200 OK'
 
     def test_change_perms(self):
         r = self.app.get('/admin/groups/')
-        dev_holder = r.html.find('table',{'id':'usergroup_admin'}).findAll('tr')[2]
-        mem_holder = r.html.find('table',{'id':'usergroup_admin'}).findAll('tr')[3]
+        dev_holder = r.html.find(
+            'table', {'id': 'usergroup_admin'}).findAll('tr')[2]
+        mem_holder = r.html.find(
+            'table', {'id': 'usergroup_admin'}).findAll('tr')[3]
         mem_id = mem_holder['data-group']
         # neither group has update permission
         assert dev_holder.findAll('ul')[1].findAll('li')[2]['class'] == "no"
         assert mem_holder.findAll('ul')[1].findAll('li')[2]['class'] == "no"
         # add update permission to Member
         r = self.app.post('/admin/groups/change_perm', params={
-                'role_id': mem_id,
-                'permission': 'create',
-                'allow': 'true'})
+            'role_id': mem_id,
+            'permission': 'create',
+            'allow': 'true'})
         r = self.app.get('/admin/groups/')
-        dev_holder = r.html.find('table',{'id':'usergroup_admin'}).findAll('tr')[2]
-        mem_holder = r.html.find('table',{'id':'usergroup_admin'}).findAll('tr')[3]
+        dev_holder = r.html.find(
+            'table', {'id': 'usergroup_admin'}).findAll('tr')[2]
+        mem_holder = r.html.find(
+            'table', {'id': 'usergroup_admin'}).findAll('tr')[3]
         # Member now has update permission
         assert mem_holder.findAll('ul')[1].findAll('li')[2]['class'] == "yes"
         # Developer has inherited update permission from Member
-        assert dev_holder.findAll('ul')[1].findAll('li')[2]['class'] == "inherit"
+        assert dev_holder.findAll('ul')[1].findAll(
+            'li')[2]['class'] == "inherit"
         # remove update permission from Member
         r = self.app.post('/admin/groups/change_perm', params={
-                'role_id': mem_id,
-                'permission': 'create',
-                'allow': 'false'})
+            'role_id': mem_id,
+            'permission': 'create',
+            'allow': 'false'})
         r = self.app.get('/admin/groups/')
-        dev_holder = r.html.find('table',{'id':'usergroup_admin'}).findAll('tr')[2]
-        mem_holder = r.html.find('table',{'id':'usergroup_admin'}).findAll('tr')[3]
+        dev_holder = r.html.find(
+            'table', {'id': 'usergroup_admin'}).findAll('tr')[2]
+        mem_holder = r.html.find(
+            'table', {'id': 'usergroup_admin'}).findAll('tr')[3]
         # neither group has update permission
         assert dev_holder.findAll('ul')[1].findAll('li')[2]['class'] == "no"
         assert mem_holder.findAll('ul')[1].findAll('li')[2]['class'] == "no"
 
     def test_permission_inherit(self):
         r = self.app.get('/admin/groups/')
-        admin_holder = r.html.find('table',{'id':'usergroup_admin'}).findAll('tr')[1]
+        admin_holder = r.html.find(
+            'table', {'id': 'usergroup_admin'}).findAll('tr')[1]
         admin_id = admin_holder['data-group']
-        mem_holder = r.html.find('table',{'id':'usergroup_admin'}).findAll('tr')[3]
+        mem_holder = r.html.find(
+            'table', {'id': 'usergroup_admin'}).findAll('tr')[3]
         mem_id = mem_holder['data-group']
-        anon_holder = r.html.find('table',{'id':'usergroup_admin'}).findAll('tr')[5]
+        anon_holder = r.html.find(
+            'table', {'id': 'usergroup_admin'}).findAll('tr')[5]
         anon_id = anon_holder['data-group']
-        #first remove create from Admin so we can see it inherit
+        # first remove create from Admin so we can see it inherit
         r = self.app.post('/admin/groups/change_perm', params={
-                'role_id': admin_id,
-                'permission': 'create',
-                'allow': 'false'})
+            'role_id': admin_id,
+            'permission': 'create',
+            'allow': 'false'})
         # updates to anon inherit up
         r = self.app.post('/admin/groups/change_perm', params={
-                'role_id': anon_id,
-                'permission': 'create',
-                'allow': 'true'})
-        assert {u'text': u'Inherited permission create from Anonymous', u'has': u'inherit', u'name': u'create'} in r.json[admin_id]
-        assert {u'text': u'Inherited permission create from Anonymous', u'has': u'inherit', u'name': u'create'} in r.json[mem_id]
-        assert {u'text': u'Has permission create', u'has': u'yes', u'name': u'create'} in r.json[anon_id]
+            'role_id': anon_id,
+            'permission': 'create',
+            'allow': 'true'})
+        assert {u'text': u'Inherited permission create from Anonymous',
+                u'has': u'inherit', u'name': u'create'} in r.json[admin_id]
+        assert {u'text': u'Inherited permission create from Anonymous',
+                u'has': u'inherit', u'name': u'create'} in r.json[mem_id]
+        assert {u'text': u'Has permission create', u'has':
+                u'yes', u'name': u'create'} in r.json[anon_id]
         r = self.app.post('/admin/groups/change_perm', params={
-                'role_id': anon_id,
-                'permission': 'create',
-                'allow': 'false'})
-        assert {u'text': u'Does not have permission create', u'has': u'no', u'name': u'create'} in r.json[admin_id]
-        assert {u'text': u'Does not have permission create', u'has': u'no', u'name': u'create'} in r.json[mem_id]
-        assert {u'text': u'Does not have permission create', u'has': u'no', u'name': u'create'} in r.json[anon_id]
+            'role_id': anon_id,
+            'permission': 'create',
+            'allow': 'false'})
+        assert {u'text': u'Does not have permission create',
+                u'has': u'no', u'name': u'create'} in r.json[admin_id]
+        assert {u'text': u'Does not have permission create',
+                u'has': u'no', u'name': u'create'} in r.json[mem_id]
+        assert {u'text': u'Does not have permission create',
+                u'has': u'no', u'name': u'create'} in r.json[anon_id]
         # updates to Member inherit up
         r = self.app.post('/admin/groups/change_perm', params={
-                'role_id': mem_id,
-                'permission': 'create',
-                'allow': 'true'})
-        assert {u'text': u'Inherited permission create from Member', u'has': u'inherit', u'name': u'create'} in r.json[admin_id]
-        assert {u'text': u'Has permission create', u'has': u'yes', u'name': u'create'} in r.json[mem_id]
-        assert {u'text': u'Does not have permission create', u'has': u'no', u'name': u'create'} in r.json[anon_id]
+            'role_id': mem_id,
+            'permission': 'create',
+            'allow': 'true'})
+        assert {u'text': u'Inherited permission create from Member',
+                u'has': u'inherit', u'name': u'create'} in r.json[admin_id]
+        assert {u'text': u'Has permission create', u'has':
+                u'yes', u'name': u'create'} in r.json[mem_id]
+        assert {u'text': u'Does not have permission create',
+                u'has': u'no', u'name': u'create'} in r.json[anon_id]
         r = self.app.post('/admin/groups/change_perm', params={
-                'role_id': mem_id,
-                'permission': 'create',
-                'allow': 'false'})
-        assert {u'text': u'Does not have permission create', u'has': u'no', u'name': u'create'} in r.json[admin_id]
-        assert {u'text': u'Does not have permission create', u'has': u'no', u'name': u'create'} in r.json[mem_id]
-        assert {u'text': u'Does not have permission create', u'has': u'no', u'name': u'create'} in r.json[anon_id]
-
+            'role_id': mem_id,
+            'permission': 'create',
+            'allow': 'false'})
+        assert {u'text': u'Does not have permission create',
+                u'has': u'no', u'name': u'create'} in r.json[admin_id]
+        assert {u'text': u'Does not have permission create',
+                u'has': u'no', u'name': u'create'} in r.json[mem_id]
+        assert {u'text': u'Does not have permission create',
+                u'has': u'no', u'name': u'create'} in r.json[anon_id]
 
     def test_admin_extension_sidebar(self):
 
         class FooSettingsController(object):
+
             @expose()
             def index(self, *a, **kw):
                 return 'here the foo settings go'
 
-
         class FooSettingsExtension(AdminExtension):
+
             def update_project_sidebar_menu(self, sidebar_links):
-                base_url = c.project.url()+'admin/ext/'
-                sidebar_links.append(SitemapEntry('Foo Settings', base_url+'foo'))
+                base_url = c.project.url() + 'admin/ext/'
+                sidebar_links.append(
+                    SitemapEntry('Foo Settings', base_url + 'foo'))
 
             @property
             def project_admin_controllers(self):
@@ -916,13 +1002,15 @@ class TestExport(TestController):
     def test_exportable_tools_for(self):
         project = M.Project.query.get(shortname='test')
         exportable_tools = AdminApp.exportable_tools_for(project)
-        exportable_mount_points = [t.options.mount_point for t in exportable_tools]
+        exportable_mount_points = [
+            t.options.mount_point for t in exportable_tools]
         assert_equals(exportable_mount_points, [u'admin', u'wiki', u'wiki2'])
 
     def test_access(self):
         r = self.app.get('/admin/export',
                          extra_environ={'username': '*anonymous'}).follow()
-        assert_equals(r.request.url, 'http://localhost/auth/?return_to=%2Fadmin%2Fexport')
+        assert_equals(r.request.url,
+                      'http://localhost/auth/?return_to=%2Fadmin%2Fexport')
         self.app.get('/admin/export',
                      extra_environ={'username': 'test-user'},
                      status=403)
@@ -945,15 +1033,19 @@ class TestExport(TestController):
     def test_export_page_contains_exportable_tools(self):
         r = self.app.get('/admin/export')
         assert_in('Wiki</label> <a href="/p/test/wiki/">/p/test/wiki/</a>', r)
-        assert_in('Wiki2</label> <a href="/p/test/wiki2/">/p/test/wiki2/</a>', r)
-        assert_not_in('Search</label> <a href="/p/test/search/">/p/test/search/</a>', r)
+        assert_in(
+            'Wiki2</label> <a href="/p/test/wiki2/">/p/test/wiki2/</a>', r)
+        assert_not_in(
+            'Search</label> <a href="/p/test/search/">/p/test/search/</a>', r)
 
     def test_export_page_contains_hidden_tools(self):
         with mock.patch('allura.ext.search.search_main.SearchApp.exportable'):
             project = M.Project.query.get(shortname='test')
             exportable_tools = AdminApp.exportable_tools_for(project)
-            exportable_mount_points = [t.options.mount_point for t in exportable_tools]
-            assert_equals(exportable_mount_points, [u'admin', u'search', u'wiki', u'wiki2'])
+            exportable_mount_points = [
+                t.options.mount_point for t in exportable_tools]
+            assert_equals(exportable_mount_points,
+                          [u'admin', u'search', u'wiki', u'wiki2'])
 
     def test_tools_not_selected(self):
         r = self.app.post('/admin/export')
@@ -967,13 +1059,15 @@ class TestExport(TestController):
     def test_selected_one_tool(self, export_tasks):
         r = self.app.post('/admin/export', {'tools': u'wiki'})
         assert_in('ok', self.webflash(r))
-        export_tasks.bulk_export.post.assert_called_once_with([u'wiki'], 'test.zip', send_email=True)
+        export_tasks.bulk_export.post.assert_called_once_with(
+            [u'wiki'], 'test.zip', send_email=True)
 
     @mock.patch('allura.ext.admin.admin_main.export_tasks')
     def test_selected_multiple_tools(self, export_tasks):
         r = self.app.post('/admin/export', {'tools': [u'wiki', u'wiki2']})
         assert_in('ok', self.webflash(r))
-        export_tasks.bulk_export.post.assert_called_once_with([u'wiki', u'wiki2'], 'test.zip', send_email=True)
+        export_tasks.bulk_export.post.assert_called_once_with(
+            [u'wiki', u'wiki2'], 'test.zip', send_email=True)
 
     def test_export_in_progress(self):
         from allura.tasks import export_tasks
@@ -984,7 +1078,8 @@ class TestExport(TestController):
     @td.with_user_project('test-user')
     def test_bulk_export_path_for_user_project(self):
         project = M.Project.query.get(shortname='u/test-user')
-        assert_equals(project.bulk_export_path(), '/tmp/bulk_export/u/test-user')
+        assert_equals(project.bulk_export_path(),
+                      '/tmp/bulk_export/u/test-user')
 
     @td.with_user_project('test-user')
     def test_bulk_export_filename_for_user_project(self):
@@ -1006,6 +1101,7 @@ class TestExport(TestController):
 
 
 class TestRestExport(TestRestApiBase):
+
     @mock.patch('allura.model.project.MonQTask')
     def test_export_status(self, MonQTask):
         MonQTask.query.get.return_value = None
@@ -1022,7 +1118,8 @@ class TestRestExport(TestRestApiBase):
     def test_export_no_exportable_tools(self, bulk_export, exportable_tools, MonQTask):
         MonQTask.query.get.return_value = None
         exportable_tools.return_value = []
-        r = self.api_post('/rest/p/test/admin/export', tools='tickets, discussion', status=400)
+        r = self.api_post('/rest/p/test/admin/export',
+                          tools='tickets, discussion', status=400)
         assert_equals(bulk_export.post.call_count, 0)
 
     @mock.patch('allura.model.project.MonQTask')
@@ -1031,9 +1128,9 @@ class TestRestExport(TestRestApiBase):
     def test_export_no_tools_specified(self, bulk_export, exportable_tools, MonQTask):
         MonQTask.query.get.return_value = None
         exportable_tools.return_value = [
-                mock.Mock(options=mock.Mock(mount_point='tickets')),
-                mock.Mock(options=mock.Mock(mount_point='discussion')),
-            ]
+            mock.Mock(options=mock.Mock(mount_point='tickets')),
+            mock.Mock(options=mock.Mock(mount_point='discussion')),
+        ]
         r = self.api_post('/rest/p/test/admin/export', status=400)
         assert_equals(bulk_export.post.call_count, 0)
 
@@ -1043,10 +1140,11 @@ class TestRestExport(TestRestApiBase):
     def test_export_busy(self, bulk_export, exportable_tools, MonQTask):
         MonQTask.query.get.return_value = 'something'
         exportable_tools.return_value = [
-                mock.Mock(options=mock.Mock(mount_point='tickets')),
-                mock.Mock(options=mock.Mock(mount_point='discussion')),
-            ]
-        r = self.api_post('/rest/p/test/admin/export', tools='tickets, discussion', status=503)
+            mock.Mock(options=mock.Mock(mount_point='tickets')),
+            mock.Mock(options=mock.Mock(mount_point='discussion')),
+        ]
+        r = self.api_post('/rest/p/test/admin/export',
+                          tools='tickets, discussion', status=503)
         assert_equals(bulk_export.post.call_count, 0)
 
     @mock.patch('allura.model.project.MonQTask')
@@ -1055,18 +1153,21 @@ class TestRestExport(TestRestApiBase):
     def test_export_ok(self, bulk_export, exportable_tools, MonQTask):
         MonQTask.query.get.return_value = None
         exportable_tools.return_value = [
-                mock.Mock(options=mock.Mock(mount_point='tickets')),
-                mock.Mock(options=mock.Mock(mount_point='discussion')),
-            ]
-        r = self.api_post('/rest/p/test/admin/export', tools='tickets, discussion', status=200)
+            mock.Mock(options=mock.Mock(mount_point='tickets')),
+            mock.Mock(options=mock.Mock(mount_point='discussion')),
+        ]
+        r = self.api_post('/rest/p/test/admin/export',
+                          tools='tickets, discussion', status=200)
         assert_equals(r.json, {
-                'filename': 'test.zip',
-                'status': 'in progress',
-            })
-        bulk_export.post.assert_called_once_with(['tickets', 'discussion'], 'test.zip', send_email=False)
+            'filename': 'test.zip',
+            'status': 'in progress',
+        })
+        bulk_export.post.assert_called_once_with(
+            ['tickets', 'discussion'], 'test.zip', send_email=False)
 
 
 class TestRestInstallTool(TestRestApiBase):
+
     def test_missing_mount_info(self):
         r = self.api_get('/rest/p/test/')
         tools_names = [t['name'] for t in r.json['tools']]
@@ -1091,7 +1192,8 @@ class TestRestInstallTool(TestRestApiBase):
         }
         r = self.api_post('/rest/p/test/admin/install_tool/', **data)
         assert_equals(r.json['success'], False)
-        assert_equals(r.json['info'], 'Incorrect tool name, or limit is reached.')
+        assert_equals(r.json['info'],
+                      'Incorrect tool name, or limit is reached.')
 
     def test_bad_mount(self):
         r = self.api_get('/rest/p/test/')
@@ -1105,7 +1207,8 @@ class TestRestInstallTool(TestRestApiBase):
         }
         r = self.api_post('/rest/p/test/admin/install_tool/', **data)
         assert_equals(r.json['success'], False)
-        assert_equals(r.json['info'], 'Mount point "tickets_mount1" is invalid')
+        assert_equals(r.json['info'],
+                      'Mount point "tickets_mount1" is invalid')
 
     def test_install_tool_ok(self):
         r = self.api_get('/rest/p/test/')
@@ -1120,12 +1223,14 @@ class TestRestInstallTool(TestRestApiBase):
         r = self.api_post('/rest/p/test/admin/install_tool/', **data)
         assert_equals(r.json['success'], True)
         assert_equals(r.json['info'],
-                     'Tool %s with mount_point %s and mount_label %s was created.'
-                     % ('tickets', 'ticketsmount1', 'tickets_label1'))
+                      'Tool %s with mount_point %s and mount_label %s was created.'
+                      % ('tickets', 'ticketsmount1', 'tickets_label1'))
 
         project = M.Project.query.get(shortname='test')
-        assert_equals(project.ordered_mounts()[-1]['ac'].options.mount_point, 'ticketsmount1')
-        audit_log = M.AuditLog.query.find({'project_id': project._id}).sort({'_id': -1}).first()
+        assert_equals(project.ordered_mounts()
+                      [-1]['ac'].options.mount_point, 'ticketsmount1')
+        audit_log = M.AuditLog.query.find(
+            {'project_id': project._id}).sort({'_id': -1}).first()
         assert_equals(audit_log.message, 'install tool ticketsmount1')
 
     def test_tool_exists(self):
@@ -1164,7 +1269,8 @@ class TestRestInstallTool(TestRestApiBase):
             data['mount_label'] = 'wiki_label1'
             r = self.api_post('/rest/p/test/admin/install_tool/', **data)
             assert_equals(r.json['success'], False)
-            assert_equals(r.json['info'], 'Incorrect tool name, or limit is reached.')
+            assert_equals(r.json['info'],
+                          'Incorrect tool name, or limit is reached.')
 
     def test_unauthorized(self):
         r = self.api_get('/rest/p/test/')
@@ -1177,9 +1283,9 @@ class TestRestInstallTool(TestRestApiBase):
             'mount_label': 'wiki_label1'
         }
         r = self.app.post('/rest/p/test/admin/install_tool/',
-                             extra_environ={'username': '*anonymous'},
-                             status=401,
-                             params=data)
+                          extra_environ={'username': '*anonymous'},
+                          status=401,
+                          params=data)
         assert_equals(r.status, '401 Unauthorized')
 
     def test_order(self):
@@ -1192,38 +1298,40 @@ class TestRestInstallTool(TestRestApiBase):
                 elif 'sub' in mount:
                     labels.append(mount['sub'].name)
             return labels
-        assert_equals(get_labels(), ['Admin', 'Search', 'Activity', 'A Subproject'])
+        assert_equals(get_labels(),
+                      ['Admin', 'Search', 'Activity', 'A Subproject'])
 
         data = [
-                {
-                    'tool': 'tickets',
-                    'mount_point': 'ticketsmount1',
-                    'mount_label': 'ta',
-                },
-                {
-                    'tool': 'tickets',
-                    'mount_point': 'ticketsmount2',
-                    'mount_label': 'tc',
-                    'order': 'last'
-                },
-                {
-                    'tool': 'tickets',
-                    'mount_point': 'ticketsmount3',
-                    'mount_label': 'tb',
-                    'order': 'alpha_tool'
-                },
-                {
-                    'tool': 'tickets',
-                    'mount_point': 'ticketsmount4',
-                    'mount_label': 't1',
-                    'order': 'first'
-                },
-            ]
+            {
+                'tool': 'tickets',
+                'mount_point': 'ticketsmount1',
+                'mount_label': 'ta',
+            },
+            {
+                'tool': 'tickets',
+                'mount_point': 'ticketsmount2',
+                'mount_label': 'tc',
+                'order': 'last'
+            },
+            {
+                'tool': 'tickets',
+                'mount_point': 'ticketsmount3',
+                'mount_label': 'tb',
+                'order': 'alpha_tool'
+            },
+            {
+                'tool': 'tickets',
+                'mount_point': 'ticketsmount4',
+                'mount_label': 't1',
+                'order': 'first'
+            },
+        ]
         for datum in data:
             r = self.api_post('/rest/p/test/admin/install_tool/', **datum)
             assert_equals(r.json['success'], True)
             assert_equals(r.json['info'],
-                         'Tool %s with mount_point %s and mount_label %s was created.'
-                         % (datum['tool'], datum['mount_point'], datum['mount_label']))
+                          'Tool %s with mount_point %s and mount_label %s was created.'
+                          % (datum['tool'], datum['mount_point'], datum['mount_label']))
 
-        assert_equals(get_labels(), ['t1', 'Admin', 'Search', 'Activity', 'A Subproject', 'ta', 'tb', 'tc'])
+        assert_equals(
+            get_labels(), ['t1', 'Admin', 'Search', 'Activity', 'A Subproject', 'ta', 'tb', 'tc'])


Mime
View raw message