incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [06/32] PEP8 cleanup
Date Fri, 10 Jan 2014 18:19:30 GMT
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/ForgeTracker/forgetracker/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/functional/test_root.py b/ForgeTracker/forgetracker/tests/functional/test_root.py
index 26791bb..8860b3b 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -41,10 +41,12 @@ from allura.lib.security import has_access
 from allura.lib import helpers as h
 from allura.lib.search import SearchError
 from allura.tests import decorators as td
-from allura.tasks import  mail_tasks
+from allura.tasks import mail_tasks
 from ming.orm.ormsession import ThreadLocalORMSession
 
+
 class TrackerTestController(TestController):
+
     def setUp(self):
         super(TrackerTestController, self).setUp()
         self.setup_with_tools()
@@ -67,7 +69,8 @@ class TrackerTestController(TestController):
             is_usercombo = (field and field.tag == 'select' and
                             field.attrs.get('class') == 'project-user-combobox')
             if is_usercombo:
-                field.options = [('', False)] + [(u.username, False) for u in p.users()]
+                field.options = [('', False)] + [(u.username, False)
+                                                 for u in p.users()]
 
         for k, v in kw.iteritems():
             form['ticket_form.%s' % k] = v
@@ -75,7 +78,9 @@ class TrackerTestController(TestController):
         assert resp.status_int != 200, resp
         return resp
 
+
 class TestMilestones(TrackerTestController):
+
     def test_milestone_list(self):
         r = self.app.get('/bugs/milestones')
         assert '1.0' in r, r.showbrowser()
@@ -92,12 +97,12 @@ class TestMilestones(TrackerTestController):
         app.globals.custom_fields = []
         ThreadLocalORMSession.flush_all()
         d = {
-            'field_name':'_milestone',
-            'milestones-0.old_name':'',
-            'milestones-0.new_name':'1.0',
-            'milestones-0.description':'Version 1',
-            'milestones-0.complete':'Open',
-            'milestones-0.due_date':''
+            'field_name': '_milestone',
+            'milestones-0.old_name': '',
+            'milestones-0.new_name': '1.0',
+            'milestones-0.description': 'Version 1',
+            'milestones-0.complete': 'Open',
+            'milestones-0.due_date': ''
         }
         r = self.app.post('/bugs/update_milestones', d)
         r = self.app.get('/bugs/milestones')
@@ -106,35 +111,36 @@ class TestMilestones(TrackerTestController):
         r = self.app.post('/bugs/update_milestones', d)
         p = M.Project.query.get(shortname='test')
         app = p.app_instance('bugs')
-        assert len(app.globals.custom_fields) == 1, len(app.globals.custom_fields)
+        assert len(app.globals.custom_fields) == 1, len(
+            app.globals.custom_fields)
 
     def test_closed_milestone(self):
         self.new_ticket(summary='bar', _milestone='1.0', status='closed')
         d = {
-            'field_name':'_milestone',
-            'milestones-0.old_name':'1.0',
-            'milestones-0.new_name':'1.0',
-            'milestones-0.description':'',
-            'milestones-0.complete':'Closed',
-            'milestones-0.due_date':''
+            'field_name': '_milestone',
+            'milestones-0.old_name': '1.0',
+            'milestones-0.new_name': '1.0',
+            'milestones-0.description': '',
+            'milestones-0.complete': 'Closed',
+            'milestones-0.due_date': ''
         }
         self.app.post('/bugs/update_milestones', d)
         d = {
-            'field_name':'_milestone',
-            'milestones-9.old_name':'',
-            'milestones-9.new_name':'3.0',
-            'milestones-9.description':'',
-            'milestones-9.complete':'Closed',
-            'milestones-9.due_date':''
+            'field_name': '_milestone',
+            'milestones-9.old_name': '',
+            'milestones-9.new_name': '3.0',
+            'milestones-9.description': '',
+            'milestones-9.complete': 'Closed',
+            'milestones-9.due_date': ''
         }
         self.app.post('/bugs/update_milestones', d)
         d = {
-            'field_name':'_milestone',
-            'milestones-9.old_name':'',
-            'milestones-9.new_name':'4.0',
-            'milestones-9.description':'',
-            'milestones-9.complete':'Closed',
-            'milestones-9.due_date':''
+            'field_name': '_milestone',
+            'milestones-9.old_name': '',
+            'milestones-9.new_name': '4.0',
+            'milestones-9.description': '',
+            'milestones-9.complete': 'Closed',
+            'milestones-9.due_date': ''
         }
         self.app.post('/bugs/update_milestones', d)
         r = self.app.get('/bugs/1/')
@@ -161,12 +167,12 @@ class TestMilestones(TrackerTestController):
     def test_duplicate_milestone(self):
         self.new_ticket(summary='bar', _milestone='1.0', status='closed')
         d = {
-            'field_name':'_milestone',
-            'milestones-0.old_name':'',
-            'milestones-0.new_name':'1.0',
-            'milestones-0.description':'',
-            'milestones-0.complete':'Closed',
-            'milestones-0.due_date':''
+            'field_name': '_milestone',
+            'milestones-0.old_name': '',
+            'milestones-0.new_name': '1.0',
+            'milestones-0.description': '',
+            'milestones-0.complete': 'Closed',
+            'milestones-0.due_date': ''
         }
         r = self.app.post('/bugs/update_milestones', d)
         assert 'error' in self.webflash(r)
@@ -176,27 +182,28 @@ class TestMilestones(TrackerTestController):
         assert len(app.globals.milestone_fields[0]['milestones']) == 2
 
         d = {
-            'field_name':'_milestone',
-            'milestones-0.old_name':'2.0',
-            'milestones-0.new_name':'1.0',
-            'milestones-0.description':'',
-            'milestones-0.complete':'Closed',
-            'milestones-0.due_date':''
+            'field_name': '_milestone',
+            'milestones-0.old_name': '2.0',
+            'milestones-0.new_name': '1.0',
+            'milestones-0.description': '',
+            'milestones-0.complete': 'Closed',
+            'milestones-0.due_date': ''
         }
         r = self.app.post('/bugs/update_milestones', d)
         assert 'error' in self.webflash(r)
-        assert app.globals.milestone_fields[0]['milestones'][1]['name'] == '2.0'
+        assert app.globals.milestone_fields[0][
+            'milestones'][1]['name'] == '2.0'
 
     def test_default_milestone(self):
         self.new_ticket(summary='bar', _milestone='1.0', status='closed')
         d = {
-            'field_name':'_milestone',
-            'milestones-0.old_name':'2.0',
-            'milestones-0.new_name':'2.0',
-            'milestones-0.description':'',
-            'milestones-0.complete':'Open',
-            'milestones-0.default':'on',
-            'milestones-0.due_date':''
+            'field_name': '_milestone',
+            'milestones-0.old_name': '2.0',
+            'milestones-0.new_name': '2.0',
+            'milestones-0.description': '',
+            'milestones-0.complete': 'Open',
+            'milestones-0.default': 'on',
+            'milestones-0.due_date': ''
         }
         self.app.post('/bugs/update_milestones', d)
         r = self.app.get('/bugs/new/')
@@ -213,6 +220,7 @@ def post_install_create_ticket_permission(app):
     if update_permission in acl:
         acl.remove(update_permission)
 
+
 def post_install_update_ticket_permission(app):
     """Set to anonymous permission to create and update tickets"""
     role = M.ProjectRole.by_name('*anonymous')._id
@@ -221,12 +229,13 @@ def post_install_update_ticket_permission(app):
 
 
 class TestSubprojectTrackerController(TrackerTestController):
+
     @td.with_tool('test/sub1', 'Tickets', 'tickets')
     def test_index_page_ticket_visibility(self):
         """Test that non-admin users can see tickets created by admins."""
         self.new_ticket(summary="my ticket", mount_point="/sub1/tickets/")
         response = self.app.get('/p/test/sub1/tickets/',
-                extra_environ=dict(username='*anonymous'))
+                                extra_environ=dict(username='*anonymous'))
         assert 'my ticket' in response
 
     @td.with_tool('test/sub1', 'Tickets', 'tickets')
@@ -237,7 +246,7 @@ class TestSubprojectTrackerController(TrackerTestController):
         M.MonQTask.run_ready()
         ThreadLocalORMSession.flush_all()
         response = self.app.get('/p/test/sub1/tickets/search/?q=my',
-                extra_environ=dict(username='*anonymous'))
+                                extra_environ=dict(username='*anonymous'))
         assert 'my ticket' in response, response.showbrowser()
 
     @td.with_tool('test/sub1', 'Tickets', 'tickets')
@@ -249,12 +258,13 @@ class TestSubprojectTrackerController(TrackerTestController):
         M.MonQTask.run_ready()
         ThreadLocalORMSession.flush_all()
         r = self.app.get('/p/test/sub1/tickets/search/',
-                params=dict(q='test', deleted='True'))
+                         params=dict(q='test', deleted='True'))
         assert '<td><a href="/p/test/sub1/tickets/1/">test' in r
         assert '<tr class=" deleted">' in r
 
 
 class TestFunctionalController(TrackerTestController):
+
     def test_bad_ticket_number(self):
         self.app.get('/bugs/input.project_user_select', status=404)
 
@@ -267,9 +277,9 @@ class TestFunctionalController(TrackerTestController):
         assert create_activity.call_count == 1
         assert create_activity.call_args[0][1] == 'created'
         create_activity.reset_mock()
-        self.app.post('/bugs/1/update_ticket',{
-            'summary':'my ticket',
-            'description':'new description',
+        self.app.post('/bugs/1/update_ticket', {
+            'summary': 'my ticket',
+            'description': 'new description',
         })
         # create_activity is called twice here:
         #   - once for the ticket modification
@@ -284,25 +294,28 @@ class TestFunctionalController(TrackerTestController):
         assert 'class="artifact_subscribe' in ticket_view
 
     def test_new_with_milestone(self):
-        ticket_view = self.new_ticket(summary='test new with milestone', **{'_milestone':'1.0'}).follow()
+        ticket_view = self.new_ticket(
+            summary='test new with milestone', **{'_milestone': '1.0'}).follow()
         assert 'Milestone' in ticket_view
         assert '1.0' in ticket_view
 
     def test_milestone_count(self):
-        self.new_ticket(summary='test new with milestone', **{'_milestone':'1.0'})
-        self.new_ticket(summary='test new with milestone', **{'_milestone':'1.0',
-                                                              'private': '1'})
+        self.new_ticket(summary='test new with milestone',
+                        **{'_milestone': '1.0'})
+        self.new_ticket(
+            summary='test new with milestone', **{'_milestone': '1.0',
+                                                  'private': '1'})
         r = self.app.get('/bugs/milestone_counts')
         counts = {
             'milestone_counts': [
                 {'name': '1.0', 'count': 2},
                 {'name': '2.0', 'count': 0}
-        ]}
+            ]}
         assert_equal(r.body, json.dumps(counts))
         # Private tickets shouldn't be included in counts if user doesn't
         # have read access to private tickets.
         r = self.app.get('/bugs/milestone_counts',
-                extra_environ=dict(username='*anonymous'))
+                         extra_environ=dict(username='*anonymous'))
         counts['milestone_counts'][0]['count'] = 1
         assert_equal(r.body, json.dumps(counts))
 
@@ -311,8 +324,8 @@ class TestFunctionalController(TrackerTestController):
         assert_equal(r.body, json.dumps(counts))
 
     def test_milestone_progress(self):
-        self.new_ticket(summary='Ticket 1', **{'_milestone':'1.0'})
-        self.new_ticket(summary='Ticket 2', **{'_milestone':'1.0',
+        self.new_ticket(summary='Ticket 1', **{'_milestone': '1.0'})
+        self.new_ticket(summary='Ticket 2', **{'_milestone': '1.0',
                                                'status': 'closed',
                                                'private': '1'}).follow()
         r = self.app.get('/bugs/milestone/1.0/')
@@ -377,7 +390,6 @@ class TestFunctionalController(TrackerTestController):
         r = self.app.get('/p/test/bugs/2/')
         assert '<li><strong>Status</strong>: open --&gt; accepted</li>' in r
 
-
     def test_label_for_mass_edit(self):
         self.new_ticket(summary='Ticket1')
         self.new_ticket(summary='Ticket2', labels='tag1')
@@ -409,9 +421,9 @@ class TestFunctionalController(TrackerTestController):
         params = dict(
             custom_fields=[
                 dict(name='_major', label='Major', type='boolean'), ],
-                open_status_names='aa bb',
-                closed_status_names='cc',
-                )
+            open_status_names='aa bb',
+            closed_status_names='cc',
+        )
         self.app.post(
             '/admin/bugs/set_custom_fields',
             params=variable_encode(params))
@@ -560,7 +572,8 @@ class TestFunctionalController(TrackerTestController):
         assert_true('<label class="simple">Private:</label> No' in ticket_view)
         ticket_view = self.new_ticket(summary='Private Ticket',
                                       private=True).follow()
-        assert_true('<label class="simple">Private:</label> Yes' in ticket_view)
+        assert_true(
+            '<label class="simple">Private:</label> Yes' in ticket_view)
         M.MonQTask.run_ready()
         # Creator sees private ticket on list page...
         index_response = self.app.get('/p/test/bugs/')
@@ -581,7 +594,8 @@ class TestFunctionalController(TrackerTestController):
         assert '1 results' in r
         assert 'Private Ticket' not in r
         # ... or in search feed...
-        r = self.app.get('/p/test/bugs/search_feed?q=ticket', extra_environ=env)
+        r = self.app.get('/p/test/bugs/search_feed?q=ticket',
+                         extra_environ=env)
         assert 'Private Ticket' not in r
         # ...and can't get to the private ticket directly.
         r = self.app.get(ticket_view.request.url, extra_environ=env)
@@ -595,23 +609,25 @@ class TestFunctionalController(TrackerTestController):
         assert 'Private Ticket' not in r
 
         # update private ticket
-        self.app.post('/bugs/1/update_ticket_from_widget',{
-            'ticket_form.summary':'Public Ticket',
-            'ticket_form.description':'',
-            'ticket_form.status':'open',
-            'ticket_form._milestone':'1.0',
-            'ticket_form.assigned_to':'',
-            'ticket_form.labels':'',
+        self.app.post('/bugs/1/update_ticket_from_widget', {
+            'ticket_form.summary': 'Public Ticket',
+            'ticket_form.description': '',
+            'ticket_form.status': 'open',
+            'ticket_form._milestone': '1.0',
+            'ticket_form.assigned_to': '',
+            'ticket_form.labels': '',
             'ticket_form.comment': 'gotta be secret about this now',
             'ticket_form.private': 'on',
         })
         response = self.app.get('/bugs/1/')
-        assert_true('<li><strong>private</strong>: No --&gt; Yes</li>' in response)
+        assert_true(
+            '<li><strong>private</strong>: No --&gt; Yes</li>' in response)
 
     @td.with_tool('test', 'Tickets', 'doc-bugs')
     def test_two_trackers(self):
         summary = 'test two trackers'
-        ticket_view = self.new_ticket('/doc-bugs/', summary=summary, _milestone='1.0').follow()
+        ticket_view = self.new_ticket(
+            '/doc-bugs/', summary=summary, _milestone='1.0').follow()
         ThreadLocalORMSession.flush_all()
         M.MonQTask.run_ready()
         ThreadLocalORMSession.flush_all()
@@ -648,9 +664,9 @@ class TestFunctionalController(TrackerTestController):
 
     def test_ticket_diffs(self):
         self.new_ticket(summary='difftest', description='1\n2\n3\n')
-        self.app.post('/bugs/1/update_ticket',{
-            'summary':'difftest',
-            'description':'1\n3\n4\n',
+        self.app.post('/bugs/1/update_ticket', {
+            'summary': 'difftest',
+            'description': '1\n3\n4\n',
         })
         r = self.app.get('/bugs/1/')
         assert '<span class="gd">-2</span>' in r, r.showbrowser()
@@ -659,50 +675,53 @@ class TestFunctionalController(TrackerTestController):
     def test_ticket_label_unlabel(self):
         summary = 'test labeling and unlabeling a ticket'
         self.new_ticket(summary=summary)
-        self.app.post('/bugs/1/update_ticket',{
-            'summary':'aaa',
-            'description':'bbb',
-            'status':'ccc',
-            '_milestone':'',
-            'assigned_to':'',
-            'labels':u'yellow,greén'.encode('utf-8'),
+        self.app.post('/bugs/1/update_ticket', {
+            'summary': 'aaa',
+            'description': 'bbb',
+            'status': 'ccc',
+            '_milestone': '',
+            'assigned_to': '',
+            'labels': u'yellow,greén'.encode('utf-8'),
             'comment': ''
         })
         response = self.app.get('/bugs/1/')
         assert_true('yellow' in response)
         assert_true(u'greén' in response)
-        assert_true('<li><strong>labels</strong>:  --&gt; yellow, greén</li>' in response)
-        self.app.post('/bugs/1/update_ticket',{
-            'summary':'zzz',
-            'description':'bbb',
-            'status':'ccc',
-            '_milestone':'',
-            'assigned_to':'',
-            'labels':'yellow',
+        assert_true(
+            '<li><strong>labels</strong>:  --&gt; yellow, greén</li>' in response)
+        self.app.post('/bugs/1/update_ticket', {
+            'summary': 'zzz',
+            'description': 'bbb',
+            'status': 'ccc',
+            '_milestone': '',
+            'assigned_to': '',
+            'labels': 'yellow',
             'comment': ''
         })
         response = self.app.get('/bugs/1/')
         assert_true('yellow' in response)
-        assert_true('<li><strong>labels</strong>: yellow, greén --&gt; yellow</li>' in response)
-        self.app.post('/bugs/1/update_ticket',{
-            'summary':'zzz',
-            'description':'bbb',
-            'status':'ccc',
-            '_milestone':'',
-            'assigned_to':'',
-            'labels':'',
+        assert_true(
+            '<li><strong>labels</strong>: yellow, greén --&gt; yellow</li>' in response)
+        self.app.post('/bugs/1/update_ticket', {
+            'summary': 'zzz',
+            'description': 'bbb',
+            'status': 'ccc',
+            '_milestone': '',
+            'assigned_to': '',
+            'labels': '',
             'comment': ''
         })
         response = self.app.get('/bugs/1/')
-        assert_true('<li><strong>labels</strong>: yellow --&gt; </li>' in response)
+        assert_true(
+            '<li><strong>labels</strong>: yellow --&gt; </li>' in response)
 
     def test_new_attachment(self):
         file_name = 'test_root.py'
         file_data = file(__file__).read()
         upload = ('attachment', file_name, file_data)
         self.new_ticket(summary='test new attachment')
-        ticket_editor = self.app.post('/bugs/1/update_ticket',{
-            'summary':'zzz'
+        ticket_editor = self.app.post('/bugs/1/update_ticket', {
+            'summary': 'zzz'
         }, upload_files=[upload]).follow()
         assert_true(file_name in ticket_editor)
         assert '<span>py</span>' not in ticket_editor
@@ -712,15 +731,15 @@ class TestFunctionalController(TrackerTestController):
         file_data = file(__file__).read()
         upload = ('attachment', file_name, file_data)
         self.new_ticket(summary='test new attachment')
-        ticket_editor = self.app.post('/bugs/1/update_ticket',{
-            'summary':'zzz'
+        ticket_editor = self.app.post('/bugs/1/update_ticket', {
+            'summary': 'zzz'
         }, upload_files=[upload]).follow()
         assert file_name in ticket_editor, ticket_editor.showbrowser()
         req = self.app.get('/bugs/1/')
         file_link = req.html.findAll('form')[1].findAll('a')[6]
         assert_equal(file_link.string, file_name)
-        self.app.post(str(file_link['href']),{
-            'delete':'True'
+        self.app.post(str(file_link['href']), {
+            'delete': 'True'
         })
         deleted_form = self.app.get('/bugs/1/')
         assert file_name not in deleted_form
@@ -734,14 +753,16 @@ class TestFunctionalController(TrackerTestController):
         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 comment'
         self.app.post(f['action'].encode('utf-8'), params=params,
-                          headers={'Referer': '/bugs/1/'.encode("utf-8")})
+                      headers={'Referer': '/bugs/1/'.encode("utf-8")})
         r = self.app.get('/bugs/1/', dict(page=1))
-        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'])
         self.app.post(post_link + 'attach',
-                          upload_files=[('file_info', 'test.txt', 'HiThere!')])
+                      upload_files=[('file_info', 'test.txt', 'HiThere!')])
         r = self.app.get('/bugs/1/', dict(page=1))
         assert '<input class="submit delete_attachment file" type="submit" value="X"/>' in r
         form = r.forms[5].submit()
@@ -753,10 +774,11 @@ class TestFunctionalController(TrackerTestController):
         file_data = file(__file__).read()
         upload = ('attachment', file_name, file_data)
         self.new_ticket(summary='test new attachment')
-        ticket_editor = self.app.post('/bugs/1/update_ticket',{
-            'summary':'zzz'
+        ticket_editor = self.app.post('/bugs/1/update_ticket', {
+            'summary': 'zzz'
         }, upload_files=[upload]).follow()
-        download = self.app.get(str(ticket_editor.html.findAll('form')[1].findAll('a')[7]['href']))
+        download = self.app.get(
+            str(ticket_editor.html.findAll('form')[1].findAll('a')[7]['href']))
         assert_equal(download.body, file_data)
 
     def test_two_attachments(self):
@@ -764,8 +786,8 @@ class TestFunctionalController(TrackerTestController):
         file_name2 = 'test_root2.py'
         file_data = file(__file__).read()
         self.new_ticket(summary='test new attachment')
-        ticket_editor = self.app.post('/bugs/1/update_ticket',{
-            'summary':'zzz'
+        ticket_editor = self.app.post('/bugs/1/update_ticket', {
+            'summary': 'zzz'
         }, upload_files=[('attachment', file_name1, file_data), ('attachment', file_name2, file_data)]).follow()
 
         assert 'test_root1.py' in ticket_editor
@@ -774,24 +796,25 @@ class TestFunctionalController(TrackerTestController):
     def test_new_image_attachment_content(self):
         h.set_context('test', 'bugs', neighborhood='Projects')
         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 = ('attachment', file_name, file_data)
         self.new_ticket(summary='test new attachment')
-        ticket_editor = self.app.post('/bugs/1/update_ticket',{
-            'summary':'zzz'
+        ticket_editor = self.app.post('/bugs/1/update_ticket', {
+            'summary': 'zzz'
         }, upload_files=[upload]).follow()
-        ticket = tm.Ticket.query.find({'ticket_num':1}).first()
+        ticket = tm.Ticket.query.find({'ticket_num': 1}).first()
         filename = ticket.attachments[0].filename
 
         uploaded = PIL.Image.open(file_path)
-        r = self.app.get('/bugs/1/attachment/'+filename)
+        r = self.app.get('/bugs/1/attachment/' + filename)
         downloaded = PIL.Image.open(StringIO.StringIO(r.body))
         assert uploaded.size == downloaded.size
-        r = self.app.get('/bugs/1/attachment/'+filename+'/thumb')
+        r = self.app.get('/bugs/1/attachment/' + filename + '/thumb')
 
         thumbnail = PIL.Image.open(StringIO.StringIO(r.body))
-        assert thumbnail.size == (100,100)
+        assert thumbnail.size == (100, 100)
 
     def test_sidebar_static_page(self):
         admin = M.User.query.get(username='test-admin')
@@ -808,10 +831,10 @@ class TestFunctionalController(TrackerTestController):
         response = self.app.get('/p/test/bugs/1/')
         assert 'Related Pages' not in response
         self.app.post('/wiki/aaa/update', params={
-                'title':'aaa',
-                'text':'',
-                'labels':'',
-                'viewable_by-0.id':'all'})
+            'title': 'aaa',
+            'text': '',
+            'labels': '',
+            'viewable_by-0.id': 'all'})
         self.new_ticket(summary='bbb')
         ThreadLocalORMSession.flush_all()
         M.MonQTask.run_ready()
@@ -849,8 +872,10 @@ class TestFunctionalController(TrackerTestController):
         self.new_ticket(summary=summary)
         response = self.app.get('/p/test/bugs/1/')
         assert response.html.find('input', {'name': 'ticket_form.summary'})
-        assert response.html.find('select', {'name': 'ticket_form.assigned_to'})
-        assert response.html.find('textarea', {'name': 'ticket_form.description'})
+        assert response.html.find(
+            'select', {'name': 'ticket_form.assigned_to'})
+        assert response.html.find(
+            'textarea', {'name': 'ticket_form.description'})
         assert response.html.find('select', {'name': 'ticket_form.status'})
         assert response.html.find('select', {'name': 'ticket_form._milestone'})
         assert response.html.find('input', {'name': 'ticket_form.labels'})
@@ -860,23 +885,26 @@ class TestFunctionalController(TrackerTestController):
         summary = 'test default assignment'
         self.new_ticket(summary=summary)
         response = self.app.get('/p/test/bugs/1/')
-        assert 'nobody' in str(response.html.find('div', {'class': 'grid-5 ticket-assigned-to'}))
+        assert 'nobody' in str(
+            response.html.find('div', {'class': 'grid-5 ticket-assigned-to'}))
 
     def test_assign_ticket(self):
         summary = 'test assign ticket'
         self.new_ticket(summary=summary)
         response = self.app.get('/p/test/bugs/1/')
-        assert 'nobody' in str(response.html.find('div', {'class': 'grid-5 ticket-assigned-to'}))
-        response = self.app.post('/bugs/1/update_ticket',{
-            'summary':'zzz',
-            'description':'bbb',
-            'status':'ccc',
-            '_milestone':'',
-            'assigned_to':'test-admin',
-            'labels':'',
+        assert 'nobody' in str(
+            response.html.find('div', {'class': 'grid-5 ticket-assigned-to'}))
+        response = self.app.post('/bugs/1/update_ticket', {
+            'summary': 'zzz',
+            'description': 'bbb',
+            'status': 'ccc',
+            '_milestone': '',
+            'assigned_to': 'test-admin',
+            'labels': '',
             'comment': ''
         }).follow()
-        assert 'test-admin' in str(response.html.find('div', {'class': 'grid-5 ticket-assigned-to'}))
+        assert 'test-admin' in str(response.html.find('div',
+                                   {'class': 'grid-5 ticket-assigned-to'}))
         assert '<li><strong>summary</strong>: test assign ticket --&gt; zzz' in response
         assert '<li><strong>status</strong>: open --&gt; ccc' in response
 
@@ -890,14 +918,15 @@ class TestFunctionalController(TrackerTestController):
                 dict(name='_code_review', label='Code Review', type='user')],
             open_status_names='aa bb',
             closed_status_names='cc',
-            )
+        )
         self.app.post(
             '/admin/bugs/set_custom_fields',
             params=variable_encode(params))
-        kw = {'custom_fields._priority':'normal',
-              'custom_fields._category':'helloworld',
-              'custom_fields._code_review':'test-admin'}
-        ticket_view = self.new_ticket(summary='test custom fields', **kw).follow()
+        kw = {'custom_fields._priority': 'normal',
+              'custom_fields._category': 'helloworld',
+              'custom_fields._code_review': 'test-admin'}
+        ticket_view = self.new_ticket(
+            summary='test custom fields', **kw).follow()
         assert 'Priority:' in ticket_view
         assert 'normal' in ticket_view
         assert 'Test Admin' in ticket_view
@@ -907,17 +936,18 @@ class TestFunctionalController(TrackerTestController):
             custom_fields=[
                 dict(name='_testselect', label='Test', type='select',
                      options='"test select"'),
-               ],
+            ],
             open_status_names='aa bb',
             closed_status_names='cc',
-            )
+        )
         self.app.post(
             '/admin/bugs/set_custom_fields',
             params=variable_encode(params))
         r = self.app.get('/bugs/new/')
         assert '<option value="test select">test select</option>' in r
-        kw = {'custom_fields._testselect':'test select'}
-        ticket_view = self.new_ticket(summary='test select custom fields', **kw).follow()
+        kw = {'custom_fields._testselect': 'test select'}
+        ticket_view = self.new_ticket(
+            summary='test select custom fields', **kw).follow()
         assert '<option selected value="test select">test select</option>' in ticket_view
 
     def test_select_custom_field_unicode(self):
@@ -925,10 +955,10 @@ class TestFunctionalController(TrackerTestController):
             custom_fields=[
                 dict(name='_testselect', label='Test', type='select',
                      options='oné "one and á half" two'),
-               ],
+            ],
             open_status_names='aa bb',
             closed_status_names='cc',
-            )
+        )
         self.app.post(
             '/admin/bugs/set_custom_fields',
             params=variable_encode(params))
@@ -942,10 +972,10 @@ class TestFunctionalController(TrackerTestController):
             custom_fields=[
                 dict(name='_testselect', label='Test', type='select',
                      options='closéd "quote missing'),
-               ],
+            ],
             open_status_names='aa bb',
             closed_status_names='cc',
-            )
+        )
         self.app.post(
             '/admin/bugs/set_custom_fields',
             params=variable_encode(params))
@@ -960,31 +990,32 @@ class TestFunctionalController(TrackerTestController):
                 dict(label='Number', type='number', options='')],
             open_status_names='aa bb',
             closed_status_names='cc',
-            )
+        )
         r = self.app.post('/admin/bugs/set_custom_fields',
                           params=variable_encode(params))
-        kw = {'custom_fields._number':''}
-        ticket_view = self.new_ticket(summary='test custom fields', **kw).follow()
+        kw = {'custom_fields._number': ''}
+        ticket_view = self.new_ticket(
+            summary='test custom fields', **kw).follow()
         assert '<strong>Number</strong>:  --&gt;' not in ticket_view
-        ticket_view = self.app.post('/bugs/1/update_ticket',params={
-            'summary':'zzz',
-            'description':'bbb',
-            'status':'ccc',
-            '_milestone':'aaa',
-            'assigned_to':'',
-            'labels':'',
-            'custom_fields._number':'',
+        ticket_view = self.app.post('/bugs/1/update_ticket', params={
+            'summary': 'zzz',
+            'description': 'bbb',
+            'status': 'ccc',
+            '_milestone': 'aaa',
+            'assigned_to': '',
+            'labels': '',
+            'custom_fields._number': '',
             'comment': ''
         }).follow()
         assert '<strong>Number</strong>:  --&gt;' not in ticket_view
-        ticket_view = self.app.post('/bugs/1/update_ticket',params={
-            'summary':'zzz',
-            'description':'bbb',
-            'status':'ccc',
-            '_milestone':'aaa',
-            'assigned_to':'',
-            'labels':'',
-            'custom_fields._number':'4',
+        ticket_view = self.app.post('/bugs/1/update_ticket', params={
+            'summary': 'zzz',
+            'description': 'bbb',
+            'status': 'ccc',
+            '_milestone': 'aaa',
+            'assigned_to': '',
+            'labels': '',
+            'custom_fields._number': '4',
             'comment': ''
         }).follow()
         assert '<strong>Number</strong>:  --&gt;' in ticket_view
@@ -994,24 +1025,24 @@ class TestFunctionalController(TrackerTestController):
             'open_status_names': 'aa bb',
             'closed_status_names': 'cc',
             'custom_fields': [dict(
-                    label='Milestone',
-                    show_in_search='on',
-                    type='milestone',
-                    milestones=[
-                        dict(name='aaaé'),
-                        dict(name='bbb'),
-                        dict(name='ccc')])] }
+                label='Milestone',
+                show_in_search='on',
+                type='milestone',
+                milestones=[
+                    dict(name='aaaé'),
+                    dict(name='bbb'),
+                    dict(name='ccc')])]}
         self.app.post('/admin/bugs/set_custom_fields',
                       variable_encode(params),
                       status=302)
         self.new_ticket(summary='test milestone names')
-        self.app.post('/bugs/1/update_ticket',{
-            'summary':'zzz',
-            'description':'bbb',
-            'status':'ccc',
-            '_milestone':'aaaé',
-            'assigned_to':'',
-            'labels':'',
+        self.app.post('/bugs/1/update_ticket', {
+            'summary': 'zzz',
+            'description': 'bbb',
+            'status': 'ccc',
+            '_milestone': 'aaaé',
+            'assigned_to': '',
+            'labels': '',
             'comment': ''
         })
         ticket_view = self.app.get('/p/test/bugs/1/')
@@ -1020,13 +1051,13 @@ class TestFunctionalController(TrackerTestController):
 
     def test_milestone_rename(self):
         self.new_ticket(summary='test milestone rename')
-        self.app.post('/bugs/1/update_ticket',{
-            'summary':'test milestone rename',
-            'description':'',
-            'status':'',
-            '_milestone':'1.0',
-            'assigned_to':'',
-            'labels':'',
+        self.app.post('/bugs/1/update_ticket', {
+            'summary': 'test milestone rename',
+            'description': '',
+            'status': '',
+            '_milestone': '1.0',
+            'assigned_to': '',
+            'labels': '',
             'comment': ''
         })
         ThreadLocalORMSession.flush_all()
@@ -1036,13 +1067,13 @@ class TestFunctionalController(TrackerTestController):
         assert 'Milestone' in ticket_view
         assert '1.0' in ticket_view
         assert 'zzzé' not in ticket_view
-        r = self.app.post('/bugs/update_milestones',{
-            'field_name':'_milestone',
-            'milestones-0.old_name':'1.0',
-            'milestones-0.new_name':'zzzé',
-            'milestones-0.description':'',
-            'milestones-0.complete':'Open',
-            'milestones-0.due_date':''
+        r = self.app.post('/bugs/update_milestones', {
+            'field_name': '_milestone',
+            'milestones-0.old_name': '1.0',
+            'milestones-0.new_name': 'zzzé',
+            'milestones-0.description': '',
+            'milestones-0.complete': 'Open',
+            'milestones-0.due_date': ''
         })
         ticket_view = self.app.get('/p/test/bugs/1/')
         assert '1.0' not in ticket_view
@@ -1052,13 +1083,13 @@ class TestFunctionalController(TrackerTestController):
         self.new_ticket(summary='test milestone close')
         r = self.app.get('/bugs/milestones')
         assert 'view closed' not in r
-        r = self.app.post('/bugs/update_milestones',{
-            'field_name':'_milestone',
-            'milestones-0.old_name':'1.0',
-            'milestones-0.new_name':'1.0',
-            'milestones-0.description':'',
-            'milestones-0.complete':'Closed',
-            'milestones-0.due_date':''
+        r = self.app.post('/bugs/update_milestones', {
+            'field_name': '_milestone',
+            'milestones-0.old_name': '1.0',
+            'milestones-0.new_name': '1.0',
+            'milestones-0.description': '',
+            'milestones-0.complete': 'Closed',
+            'milestones-0.due_date': ''
         })
         r = self.app.get('/bugs/milestones')
         assert 'view closed' in r
@@ -1080,7 +1111,7 @@ class TestFunctionalController(TrackerTestController):
                      options='')],
             open_status_names='aa bb',
             closed_status_names='cc',
-            )
+        )
         self.app.post(
             '/admin/bugs/set_custom_fields', params=variable_encode(params))
         # Test new ticket form
@@ -1089,40 +1120,48 @@ class TestFunctionalController(TrackerTestController):
         form['ticket_form.custom_fields._priority'] = 'urgent'
         form['ticket_form.custom_fields._category'] = 'bugs'
         error_form = form.submit()
-        assert_equal(error_form.forms[1]['ticket_form.custom_fields._priority'].value, 'urgent')
-        assert_equal(error_form.forms[1]['ticket_form.custom_fields._category'].value, 'bugs')
+        assert_equal(
+            error_form.forms[1]['ticket_form.custom_fields._priority'].value, 'urgent')
+        assert_equal(
+            error_form.forms[1]['ticket_form.custom_fields._category'].value, 'bugs')
         # Test edit ticket form
         self.new_ticket(summary='Test ticket')
         response = self.app.get('/bugs/1/')
         form = response.forms[1]
-        assert_equal(form['ticket_form.custom_fields._priority'].value, 'normal')
+        assert_equal(
+            form['ticket_form.custom_fields._priority'].value, 'normal')
         assert_equal(form['ticket_form.custom_fields._category'].value, '')
         form['ticket_form.summary'] = ''
         form['ticket_form.custom_fields._priority'] = 'urgent'
         form['ticket_form.custom_fields._category'] = 'bugs'
         error_form = form.submit()
-        assert_equal(error_form.forms[1]['ticket_form.custom_fields._priority'].value, 'urgent')
-        assert_equal(error_form.forms[1]['ticket_form.custom_fields._category'].value, 'bugs')
+        assert_equal(
+            error_form.forms[1]['ticket_form.custom_fields._priority'].value, 'urgent')
+        assert_equal(
+            error_form.forms[1]['ticket_form.custom_fields._category'].value, 'bugs')
 
     def test_new_ticket_validation(self):
         summary = 'ticket summary'
         response = self.app.get('/bugs/new/')
-        assert not response.html.find('div', {'class':'error'})
+        assert not response.html.find('div', {'class': 'error'})
         form = response.forms[1]
         form['ticket_form.labels'] = 'foo'
         # try submitting with no summary set and check for error message
         error_form = form.submit()
         assert error_form.forms[1]['ticket_form.labels'].value == 'foo'
-        error_message = error_form.html.find('div', {'class':'error'})
+        error_message = error_form.html.find('div', {'class': 'error'})
         assert error_message
-        assert (error_message.string == 'You must provide a Title' or \
+        assert (error_message.string == 'You must provide a Title' or
                 error_message.string == 'Missing value')
-        assert error_message.findPreviousSibling('input').get('name') == 'ticket_form.summary'
+        assert error_message.findPreviousSibling(
+            'input').get('name') == 'ticket_form.summary'
         # set a summary, submit, and check for success
         error_form.forms[1]['ticket_form.summary'] = summary
         success = error_form.forms[1].submit().follow().html
-        assert success.findAll('form')[1].get('action') == '/p/test/bugs/1/update_ticket_from_widget'
-        assert success.find('input', {'name':'ticket_form.summary'})['value'] == summary
+        assert success.findAll('form')[1].get(
+            'action') == '/p/test/bugs/1/update_ticket_from_widget'
+        assert success.find('input', {'name': 'ticket_form.summary'})[
+            'value'] == summary
 
     def test_edit_ticket_validation(self):
         old_summary = 'edit ticket test'
@@ -1130,23 +1169,27 @@ class TestFunctionalController(TrackerTestController):
         self.new_ticket(summary=old_summary)
         response = self.app.get('/bugs/1/')
         # check that existing form is valid
-        assert response.html.find('input', {'name':'ticket_form.summary'})['value'] == old_summary
-        assert not response.html.find('div', {'class':'error'})
+        assert response.html.find(
+            'input', {'name': 'ticket_form.summary'})['value'] == old_summary
+        assert not response.html.find('div', {'class': 'error'})
         form = response.forms[1]
         # try submitting with no summary set and check for error message
         form['ticket_form.summary'] = ""
         error_form = form.submit()
-        error_message = error_form.html.find('div', {'class':'error'})
+        error_message = error_form.html.find('div', {'class': 'error'})
         assert error_message
         assert error_message.string == 'You must provide a Title'
-        assert error_message.findPreviousSibling('input').get('name') == 'ticket_form.summary'
+        assert error_message.findPreviousSibling(
+            'input').get('name') == 'ticket_form.summary'
         # set a summary, submit, and check for success
         error_form.forms[1]['ticket_form.summary'] = new_summary
         r = error_form.forms[1].submit()
         assert r.status_int == 302, r.showbrowser()
         success = r.follow().html
-        assert success.findAll('form')[1].get('action') == '/p/test/bugs/1/update_ticket_from_widget'
-        assert success.find('input', {'name':'ticket_form.summary'})['value'] == new_summary
+        assert success.findAll('form')[1].get(
+            'action') == '/p/test/bugs/1/update_ticket_from_widget'
+        assert success.find('input', {'name': 'ticket_form.summary'})[
+            'value'] == new_summary
 
     def test_home(self):
         self.new_ticket(summary='test first ticket')
@@ -1170,12 +1213,13 @@ class TestFunctionalController(TrackerTestController):
         assert 'test third ticket' in response, response.showbrowser()
 
     def test_search_with_strange_chars(self):
-        r = self.app.get('/p/test/bugs/search/?' + urllib.urlencode({'q': 'tést'}))
+        r = self.app.get('/p/test/bugs/search/?' +
+                         urllib.urlencode({'q': 'tést'}))
         assert 'Search bugs: tést' in r
 
     def test_saved_search_with_strange_chars(self):
         '''Sidebar must be visible even with a strange characters in saved search terms'''
-        r = self.app.post('/admin/bugs/bins/save_bin',{
+        r = self.app.post('/admin/bugs/bins/save_bin', {
             'summary': 'Strange chars in terms here',
             'terms': 'labels:tést',
             'old_summary': '',
@@ -1190,7 +1234,7 @@ class TestFunctionalController(TrackerTestController):
         ThreadLocalORMSession.flush_all()
         for ext in ['', '.rss', '.atom']:
             assert '<title>test first ticket</title>' in \
-                    self.app.get('/p/test/bugs/search_feed%s?q=test' % ext)
+                self.app.get('/p/test/bugs/search_feed%s?q=test' % ext)
 
     def test_search_current_user(self):
         self.new_ticket(summary='test first ticket')
@@ -1240,7 +1284,7 @@ class TestFunctionalController(TrackerTestController):
     def test_save_invalid_search(self, search_artifact):
         err = 'Error running search query: [Reason: undefined field label]'
         search_artifact.side_effect = SearchError(err)
-        r = self.app.post('/admin/bugs/bins/save_bin',{
+        r = self.app.post('/admin/bugs/bins/save_bin', {
             'summary': 'This is not too long.',
             'terms': 'label:foo',
             'old_summary': '',
@@ -1254,20 +1298,21 @@ class TestFunctionalController(TrackerTestController):
         assert err in r
 
     def test_saved_search_labels_truncated(self):
-        r = self.app.post('/admin/bugs/bins/save_bin',{
+        r = self.app.post('/admin/bugs/bins/save_bin', {
             'summary': 'This is not too long.',
             'terms': 'aaa',
             'old_summary': '',
             'sort': ''}).follow()
         r = self.app.get('/bugs/')
         assert sidebar_contains(r, 'This is not too long.')
-        r = self.app.post('/admin/bugs/bins/save_bin',{
+        r = self.app.post('/admin/bugs/bins/save_bin', {
             'summary': 'This will be truncated because it is too long to show in the sidebar without being ridiculous.',
             'terms': 'aaa',
             'old_summary': '',
             'sort': ''}).follow()
         r = self.app.get('/bugs/')
-        assert sidebar_contains(r, 'This will be truncated because it is too long to show in the sidebar ...')
+        assert sidebar_contains(
+            r, 'This will be truncated because it is too long to show in the sidebar ...')
 
     def test_edit_saved_search(self):
         r = self.app.get('/admin/bugs/bins/')
@@ -1297,13 +1342,15 @@ class TestFunctionalController(TrackerTestController):
         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']] = post_content
         r = self.app.post(f['action'].encode('utf-8'), params=params,
                           headers={'Referer': '/bugs/1/'.encode("utf-8")})
         r = self.app.get('/bugs/1/', dict(page=1))
         assert_true(post_content in r)
-        assert_true(len(r.html.findAll(attrs={'class': 'discussion-post'})) == 1)
+        assert_true(
+            len(r.html.findAll(attrs={'class': 'discussion-post'})) == 1)
 
         new_summary = 'old ticket'
         for f in ticket_view.html.findAll('form'):
@@ -1313,13 +1360,15 @@ class TestFunctionalController(TrackerTestController):
         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['ticket_form.summary'] = new_summary
         r = self.app.post(f['action'].encode('utf-8'), params=params,
                           headers={'Referer': '/bugs/1/'.encode("utf-8")})
         r = self.app.get('/bugs/1/', dict(page=1))
-        assert_true(summary+' --&gt; '+new_summary in r)
-        assert_true(len(r.html.findAll(attrs={'class': 'discussion-post'})) == 2)
+        assert_true(summary + ' --&gt; ' + new_summary in r)
+        assert_true(
+            len(r.html.findAll(attrs={'class': 'discussion-post'})) == 2)
 
     def test_discussion_paging(self):
         summary = 'test discussion paging'
@@ -1332,7 +1381,8 @@ class TestFunctionalController(TrackerTestController):
         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']] = post_content
         r = self.app.post(f['action'].encode('utf-8'), params=params,
                           headers={'Referer': '/bugs/1/'.encode("utf-8")})
@@ -1345,7 +1395,7 @@ class TestFunctionalController(TrackerTestController):
         # add some more posts and check for pager
         for i in range(2):
             r = self.app.post(f['action'].encode('utf-8'), params=params,
-                  headers={'Referer': '/bugs/1/'.encode("utf-8")})
+                              headers={'Referer': '/bugs/1/'.encode("utf-8")})
         r = self.app.get('/bugs/1/', dict(page=1, limit=2))
         assert_true('Page 2 of 2' in r)
 
@@ -1360,25 +1410,28 @@ class TestFunctionalController(TrackerTestController):
         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']] = post_content
         self.app.post(f['action'].encode('utf-8'), params=params,
-            headers={'Referer': '/bugs/1/'.encode("utf-8")})
+                      headers={'Referer': '/bugs/1/'.encode("utf-8")})
         r = self.app.get('/bugs/feed.rss')
         post = M.Post.query.find().first()
         assert '/p/test/bugs/1/?limit=50#' + post.slug in r
         r = self.app.get('/bugs/1/')
-        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_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")})
+                          params=params,
+                          headers={'Referer': post_link.encode("utf-8")})
         r = self.app.get('/bugs/feed.rss')
         assert 'Tis a reply' in r
         assert 'ticket discussion post content' in r
@@ -1394,34 +1447,40 @@ class TestFunctionalController(TrackerTestController):
         M.MonQTask.run_ready()
         ThreadLocalORMSession.flush_all()
         response = self.app.get('/p/test/bugs/?sort=summary+asc')
-        ticket_rows = response.html.find('table', {'class':'ticket-list'}).find('tbody')
+        ticket_rows = response.html.find(
+            'table', {'class': 'ticket-list'}).find('tbody')
         assert_in('test first ticket', str(ticket_rows))
         assert_in('test second ticket', str(ticket_rows))
-        edit_link = response.html.find('a',{'title':'Bulk Edit'})
+        edit_link = response.html.find('a', {'title': 'Bulk Edit'})
         expected_link = "/p/test/bugs/edit/?q=%21status%3Awont-fix+%26%26+%21status%3Aclosed&sort=snippet_s+asc&limit=25&page=0"
         assert_equal(expected_link, edit_link['href'])
         response = self.app.get(edit_link['href'])
-        ticket_rows = response.html.find('tbody', {'class':'ticket-list'})
+        ticket_rows = response.html.find('tbody', {'class': 'ticket-list'})
         assert_in('test first ticket', str(ticket_rows))
         assert_in('test second ticket', str(ticket_rows))
 
     def test_bulk_edit_milestone(self):
-        self.new_ticket(summary='test first ticket', status='open', _milestone='1.0')
-        self.new_ticket(summary='test second ticket', status='accepted', _milestone='1.0')
-        self.new_ticket(summary='test third ticket', status='closed', _milestone='1.0')
+        self.new_ticket(summary='test first ticket',
+                        status='open', _milestone='1.0')
+        self.new_ticket(summary='test second ticket',
+                        status='accepted', _milestone='1.0')
+        self.new_ticket(summary='test third ticket',
+                        status='closed', _milestone='1.0')
         ThreadLocalORMSession.flush_all()
         M.MonQTask.run_ready()
         ThreadLocalORMSession.flush_all()
-        response = self.app.get('/p/test/bugs/milestone/1.0/?sort=ticket_num+asc')
-        ticket_rows = response.html.find('table', {'class':'ticket-list'}).find('tbody')
+        response = self.app.get(
+            '/p/test/bugs/milestone/1.0/?sort=ticket_num+asc')
+        ticket_rows = response.html.find(
+            'table', {'class': 'ticket-list'}).find('tbody')
         assert_in('test first ticket', str(ticket_rows))
         assert_in('test second ticket', str(ticket_rows))
         assert_in('test third ticket', str(ticket_rows))
-        edit_link = response.html.find('a',{'title':'Bulk Edit'})
+        edit_link = response.html.find('a', {'title': 'Bulk Edit'})
         expected_link = "/p/test/bugs/edit/?q=_milestone%3A1.0&sort=ticket_num_i+asc&limit=25&page=0"
         assert_equal(expected_link, edit_link['href'])
         response = self.app.get(edit_link['href'])
-        ticket_rows = response.html.find('tbody', {'class':'ticket-list'})
+        ticket_rows = response.html.find('tbody', {'class': 'ticket-list'})
         assert_in('test first ticket', str(ticket_rows))
         assert_in('test second ticket', str(ticket_rows))
         assert_in('test third ticket', str(ticket_rows))
@@ -1429,27 +1488,31 @@ class TestFunctionalController(TrackerTestController):
     def test_bulk_edit_search(self):
         self.new_ticket(summary='test first ticket', status='open')
         self.new_ticket(summary='test second ticket', status='open')
-        self.new_ticket(summary='test third ticket', status='closed', _milestone='1.0')
+        self.new_ticket(summary='test third ticket',
+                        status='closed', _milestone='1.0')
         ThreadLocalORMSession.flush_all()
         M.MonQTask.run_ready()
         ThreadLocalORMSession.flush_all()
         response = self.app.get('/p/test/bugs/search/?q=status%3Aopen')
-        ticket_rows = response.html.find('table', {'class':'ticket-list'}).find('tbody')
+        ticket_rows = response.html.find(
+            'table', {'class': 'ticket-list'}).find('tbody')
         assert_in('test first ticket', str(ticket_rows))
         assert_in('test second ticket', str(ticket_rows))
         assert_false('test third ticket' in str(ticket_rows))
-        edit_link = response.html.find('a',{'title':'Bulk Edit'})
+        edit_link = response.html.find('a', {'title': 'Bulk Edit'})
         expected_link = "/p/test/bugs/edit/?q=status%3Aopen&limit=25&page=0"
         assert_equal(expected_link, edit_link['href'])
         response = self.app.get(edit_link['href'])
-        ticket_rows = response.html.find('tbody', {'class':'ticket-list'})
+        ticket_rows = response.html.find('tbody', {'class': 'ticket-list'})
         assert_in('test first ticket', str(ticket_rows))
         assert_in('test second ticket', str(ticket_rows))
         assert_false('test third ticket' in str(ticket_rows))
 
     def test_bulk_edit_notifications(self):
-        self.new_ticket(summary='test first ticket', status='open', _milestone='2.0')
-        self.new_ticket(summary='test second ticket', status='accepted', _milestone='1.0')
+        self.new_ticket(summary='test first ticket',
+                        status='open', _milestone='2.0')
+        self.new_ticket(summary='test second ticket',
+                        status='accepted', _milestone='1.0')
         self.new_ticket(summary='test third ticket', status='unread')
         ThreadLocalORMSession.flush_all()
         M.MonQTask.run_ready()
@@ -1474,10 +1537,12 @@ class TestFunctionalController(TrackerTestController):
                       'assigned_to': 'test-admin'})
         M.MonQTask.run_ready()
 
-        emails = M.MonQTask.query.find(dict(task_name='allura.tasks.mail_tasks.sendmail')).all()
+        emails = M.MonQTask.query.find(
+            dict(task_name='allura.tasks.mail_tasks.sendmail')).all()
         assert_equal(len(emails), 3)
         for email in emails:
-            assert_equal(email.kwargs.subject, '[test:bugs] Mass edit changes by Test Admin')
+            assert_equal(email.kwargs.subject,
+                         '[test:bugs] Mass edit changes by Test Admin')
         first_user_email = M.MonQTask.query.find({
             'task_name': 'allura.tasks.mail_tasks.sendmail',
             'kwargs.destinations': str(first_user._id)
@@ -1535,7 +1600,8 @@ class TestFunctionalController(TrackerTestController):
             'TicketMonitoringEmail': 'monitoring@email.com',
             'TicketMonitoringType': 'AllTicketChanges',
         })
-        self.new_ticket(summary='test first ticket', status='open', _milestone='2.0', private=True)
+        self.new_ticket(summary='test first ticket',
+                        status='open', _milestone='2.0', private=True)
         ThreadLocalORMSession.flush_all()
         M.MonQTask.run_ready()
         ThreadLocalORMSession.flush_all()
@@ -1546,10 +1612,13 @@ class TestFunctionalController(TrackerTestController):
                       '__ticket_ids': [ticket._id],
                       'status': 'accepted'})
         M.MonQTask.run_ready()
-        emails = M.MonQTask.query.find(dict(task_name='allura.tasks.mail_tasks.sendmail')).all()
-        assert_equal(len(emails), 2)  # one for admin and one for monitoring email
+        emails = M.MonQTask.query.find(
+            dict(task_name='allura.tasks.mail_tasks.sendmail')).all()
+        # one for admin and one for monitoring email
+        assert_equal(len(emails), 2)
         for email in emails:
-            assert_equal(email.kwargs.subject, '[test:bugs] Mass edit changes by Test Admin')
+            assert_equal(email.kwargs.subject,
+                         '[test:bugs] Mass edit changes by Test Admin')
         admin = M.User.by_username('test-admin')
         admin_email = M.MonQTask.query.find({
             'task_name': 'allura.tasks.mail_tasks.sendmail',
@@ -1573,8 +1642,10 @@ class TestFunctionalController(TrackerTestController):
             'TicketMonitoringEmail': 'monitoring@email.com',
             'TicketMonitoringType': 'AllPublicTicketChanges',
         })
-        self.new_ticket(summary='test first ticket', status='open', _milestone='2.0')
-        self.new_ticket(summary='test second ticket', status='open', private=True)
+        self.new_ticket(summary='test first ticket',
+                        status='open', _milestone='2.0')
+        self.new_ticket(summary='test second ticket',
+                        status='open', private=True)
         ThreadLocalORMSession.flush_all()
         M.MonQTask.run_ready()
         ThreadLocalORMSession.flush_all()
@@ -1585,10 +1656,13 @@ class TestFunctionalController(TrackerTestController):
                       '__ticket_ids': [t._id for t in tickets],
                       'status': 'accepted'})
         M.MonQTask.run_ready()
-        emails = M.MonQTask.query.find(dict(task_name='allura.tasks.mail_tasks.sendmail')).all()
-        assert_equal(len(emails), 2)  # one for admin and one for monitoring email
+        emails = M.MonQTask.query.find(
+            dict(task_name='allura.tasks.mail_tasks.sendmail')).all()
+        # one for admin and one for monitoring email
+        assert_equal(len(emails), 2)
         for email in emails:
-            assert_equal(email.kwargs.subject, '[test:bugs] Mass edit changes by Test Admin')
+            assert_equal(email.kwargs.subject,
+                         '[test:bugs] Mass edit changes by Test Admin')
         admin = M.User.by_username('test-admin')
         admin_email = M.MonQTask.query.find({
             'task_name': 'allura.tasks.mail_tasks.sendmail',
@@ -1613,8 +1687,10 @@ class TestFunctionalController(TrackerTestController):
             'TicketMonitoringEmail': 'monitoring@email.com',
             'TicketMonitoringType': 'AllPublicTicketChanges',
         })
-        self.new_ticket(summary='test first ticket', status='open', private=True)
-        self.new_ticket(summary='test second ticket', status='open', private=True)
+        self.new_ticket(summary='test first ticket',
+                        status='open', private=True)
+        self.new_ticket(summary='test second ticket',
+                        status='open', private=True)
         ThreadLocalORMSession.flush_all()
         M.MonQTask.run_ready()
         ThreadLocalORMSession.flush_all()
@@ -1625,10 +1701,12 @@ class TestFunctionalController(TrackerTestController):
                       '__ticket_ids': [t._id for t in tickets],
                       'status': 'accepted'})
         M.MonQTask.run_ready()
-        emails = M.MonQTask.query.find(dict(task_name='allura.tasks.mail_tasks.sendmail')).all()
+        emails = M.MonQTask.query.find(
+            dict(task_name='allura.tasks.mail_tasks.sendmail')).all()
         assert_equal(len(emails), 1)  # only admin email sent
         for email in emails:
-            assert_equal(email.kwargs.subject, '[test:bugs] Mass edit changes by Test Admin')
+            assert_equal(email.kwargs.subject,
+                         '[test:bugs] Mass edit changes by Test Admin')
         admin = M.User.by_username('test-admin')
         admin_email = M.MonQTask.query.find({
             'task_name': 'allura.tasks.mail_tasks.sendmail',
@@ -1675,7 +1753,8 @@ class TestFunctionalController(TrackerTestController):
         }
         filtered_changes = c.app.globals.filtered_by_subscription(changes)
         filtered_users = [uid for uid, data in filtered_changes.iteritems()]
-        assert_equal(sorted(filtered_users), sorted([u._id for u in users[:-1] + [admin]]))
+        assert_equal(sorted(filtered_users),
+                     sorted([u._id for u in users[:-1] + [admin]]))
         ticket_ids = [t._id for t in tickets]
         assert_equal(filtered_changes[users[0]._id], set(ticket_ids[0:1]))
         assert_equal(filtered_changes[users[1]._id], set(ticket_ids[:-1]))
@@ -1730,9 +1809,8 @@ class TestFunctionalController(TrackerTestController):
         r = self.app.get('/bugs/')
         assert "Votes" not in r
 
-
     @td.with_tool('test', 'Tickets', 'tracker',
-            post_install_hook=post_install_create_ticket_permission)
+                  post_install_hook=post_install_create_ticket_permission)
     def test_create_permission(self):
         """Test that user with `create` permission can create ticket,
         but can't edit it without `update` permission.
@@ -1747,11 +1825,11 @@ class TestFunctionalController(TrackerTestController):
         ticket_url = response.headers['Location']
         response = self.app.get(ticket_url,
                                 extra_environ=dict(username='test-user-0'))
-        assert not response.html.find('div',{'class': 'error'})
+        assert not response.html.find('div', {'class': 'error'})
         assert not response.html.find('a', {'class': 'edit_ticket'})
 
     @td.with_tool('test', 'Tickets', 'tracker',
-            post_install_hook=post_install_update_ticket_permission)
+                  post_install_hook=post_install_update_ticket_permission)
     def test_update_permission(self):
         r = self.app.get('/p/test/tracker/',
                          extra_environ=dict(username='*anonymous'))
@@ -1787,7 +1865,8 @@ class TestFunctionalController(TrackerTestController):
         assert 'Private ticket title' in r
         assert '<label class="simple">Private:</label> Yes' in r, 'Ticket is not private'
         # ... and can't see 'Edit' link
-        assert r.html.find('a', {'class': 'edit_ticket'}) is None, "Found 'Edit' link"
+        assert r.html.find('a', {'class': 'edit_ticket'}
+                           ) is None, "Found 'Edit' link"
         # ... and can't actually edit it
         self.app.post('/bugs/1/update_ticket', {'summary': 'should fail'},
                       extra_environ=env, status=403)
@@ -1818,11 +1897,13 @@ class TestFunctionalController(TrackerTestController):
 
     def test_ticket_delete_without_permission(self):
         self.new_ticket(summary='Test ticket')
-        self.app.post('/bugs/1/delete', extra_environ=dict(username='*anonymous'))
+        self.app.post('/bugs/1/delete',
+                      extra_environ=dict(username='*anonymous'))
         r = self.app.get('/bugs/')
         assert '<a href="/p/test/bugs/1/">Test ticket</a>' in r
         self.app.post('/bugs/1/delete')
-        self.app.post('/bugs/1/undelete', extra_environ=dict(username='*anonymous'))
+        self.app.post('/bugs/1/undelete',
+                      extra_environ=dict(username='*anonymous'))
         r = self.app.get('/bugs/')
         assert 'No open tickets found.' in r
 
@@ -1831,12 +1912,15 @@ class TestFunctionalController(TrackerTestController):
         self.app.post('/bugs/1/delete')
         r = self.app.get('/p/test/bugs/1/')
         assert '#1 test' in r
-        self.app.get('/p/test/bugs/1/', extra_environ=dict(username='*anonymous'), status=404)
-        r = self.app.get('/p/test/bugs/',params=dict(q='test',deleted='True'))
+        self.app.get('/p/test/bugs/1/',
+                     extra_environ=dict(username='*anonymous'), status=404)
+        r = self.app.get('/p/test/bugs/',
+                         params=dict(q='test', deleted='True'))
         assert '<td><a href="/p/test/bugs/1/">test' in r
         assert '<tr class=" deleted">' in r
-        r = self.app.get('/p/test/bugs/',params=dict(q='test',deleted='True'),
-                         extra_environ=dict(username='*anonymous'))
+        r = self.app.get(
+            '/p/test/bugs/', params=dict(q='test', deleted='True'),
+            extra_environ=dict(username='*anonymous'))
         assert 'No open tickets found.' in r
 
     def test_show_hide_deleted_tickets(self):
@@ -1859,15 +1943,17 @@ class TestFunctionalController(TrackerTestController):
         r = self.app.get('/p/test/bugs/1/move')
         trackers = r.html.find('select', {'name': 'tracker'}).findAll('option')
         trackers = set([t.text for t in trackers])
-        expected = set(['test/bugs', 'test/bugs2', 'test2/bugs', 'test2/bugs2'])
+        expected = set(
+            ['test/bugs', 'test/bugs2', 'test2/bugs', 'test2/bugs2'])
         assert trackers == expected, trackers
 
         p = M.Project.query.get(shortname='test2')
         tracker = p.app_instance('bugs2')
         r = self.app.post('/p/test/bugs/1/move/',
-                params={'tracker': str(tracker.config._id)}).follow()
+                          params={'tracker': str(tracker.config._id)}).follow()
         assert_equal(r.request.path, '/p/test2/bugs2/1/')
-        summary = r.html.findAll('h2', {'class': 'dark title'})[0].contents[0].strip()
+        summary = r.html.findAll(
+            'h2', {'class': 'dark title'})[0].contents[0].strip()
         assert_equal(summary, '#1 test')
         ac_id = tracker.config._id
         ticket = tm.Ticket.query.find({
@@ -1885,7 +1971,7 @@ class TestFunctionalController(TrackerTestController):
         p = M.Project.query.get(shortname='test2')
         ac_id = p.app_instance('bugs2').config._id
         r = self.app.post('/p/test/bugs/1/move/',
-                params={'tracker': str(ac_id)}).follow()
+                          params={'tracker': str(ac_id)}).follow()
 
         ticket = tm.Ticket.query.find({
             'app_config_id': ac_id,
@@ -1913,7 +1999,8 @@ class TestFunctionalController(TrackerTestController):
         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']] = post_content
         r = self.app.post(f['action'].encode('utf-8'), params=params,
                           headers={'Referer': '/p/test2/bugs2/1/'.encode("utf-8")})
@@ -1937,22 +2024,22 @@ class TestFunctionalController(TrackerTestController):
         r = self.app.post('/p/test/bugs/1/move').follow()  # empty POST
         assert 'Select valid tracker' in r, r
         r = self.app.post('/p/test/bugs/1/move',
-                params={'tracker': 'invalid tracker id'}).follow()
-        assert 'Select valid tracker' in r,r
+                          params={'tracker': 'invalid tracker id'}).follow()
+        assert 'Select valid tracker' in r, r
         p = M.Project.query.get(shortname='test')
         tracker = p.app_instance('bugs')
         r = self.app.post('/p/test/bugs/1/move',
-                params={'tracker': str(tracker.config._id)}).follow()
+                          params={'tracker': str(tracker.config._id)}).follow()
         assert 'Ticket already in a selected tracker' in r, r
 
     def test_move_ticket_access(self):
         self.new_ticket(summary='test')
         self.app.get('/p/test/bugs/1/move',
-                extra_environ={'username': 'test-user'},
-                status=403)
+                     extra_environ={'username': 'test-user'},
+                     status=403)
         self.app.post('/p/test/bugs/1/move',
-                extra_environ={'username': 'test-user'},
-                status=403)
+                      extra_environ={'username': 'test-user'},
+                      status=403)
 
     @td.with_tool('test', 'Tickets', 'dummy')
     def test_move_ticket_redirect(self):
@@ -1963,7 +2050,7 @@ class TestFunctionalController(TrackerTestController):
         p = M.Project.query.get(shortname='test')
         dummy_tracker = p.app_instance('dummy')
         r = self.app.post('/p/test/bugs/1/move',
-                params={'tracker': str(dummy_tracker.config._id)}).follow()
+                          params={'tracker': str(dummy_tracker.config._id)}).follow()
         assert_equal(r.request.path, '/p/test/dummy/1/')
 
         # test that old url redirects to moved ticket
@@ -1983,7 +2070,7 @@ class TestFunctionalController(TrackerTestController):
         p = M.Project.query.get(shortname='test')
         dummy_tracker = p.app_instance('dummy')
         r = self.app.post('/p/test/bugs/1/move',
-                params={'tracker': str(dummy_tracker.config._id)}).follow()
+                          params={'tracker': str(dummy_tracker.config._id)}).follow()
         assert_equal(r.request.path, '/p/test/dummy/1/')
 
         # delete 'dummy' tracker
@@ -1991,7 +2078,8 @@ class TestFunctionalController(TrackerTestController):
 
         # remaining tickets in 'bugs' tracker should still be viewable
         self.app.get('/p/test/bugs/2/', status=200)  # shouldn't fail
-        r = self.app.get('/p/test/bugs/1/', status=301)  # ticket counts as moved
+        # ticket counts as moved
+        r = self.app.get('/p/test/bugs/1/', status=301)
         r.follow(status=404)  # and not found 'cause already deleted
 
     @td.with_tool('test', 'Tickets', 'dummy')
@@ -2007,7 +2095,7 @@ class TestFunctionalController(TrackerTestController):
         p = M.Project.query.get(shortname='test')
         dummy_tracker = p.app_instance('dummy')
         r = self.app.post('/p/test/bugs/1/move',
-                params={'tracker': str(dummy_tracker.config._id)}).follow()
+                          params={'tracker': str(dummy_tracker.config._id)}).follow()
         assert_equal(r.request.path, '/p/test/dummy/1/')
 
         # comment ticket 2
@@ -2021,7 +2109,8 @@ class TestFunctionalController(TrackerTestController):
         r.forms[2].fields[field_name][0].value = 'Hi there'
         r.forms[2].submit()
 
-        # notification for ticket 2 should reference [test:bugs], not [test:dummy]
+        # notification for ticket 2 should reference [test:bugs], not
+        # [test:dummy]
         n = M.Notification.query.find().all()[0]
         assert_in('[test:bugs]', n.subject)
         assert_in('[test:bugs]', n.reply_to_address)
@@ -2029,18 +2118,20 @@ class TestFunctionalController(TrackerTestController):
     @td.with_tool('test2', 'Tickets', 'bugs2')
     def test_move_attachment(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 = ('attachment', file_name, file_data)
         self.new_ticket(summary='test move attachment')
 
         # attach an image to the ticket
         self.app.post('/bugs/1/update_ticket',
-                      {'summary':'test'},
+                      {'summary': 'test'},
                       upload_files=[upload])
         # attach a txt file to the comment
         r = self.app.get('/p/test/bugs/1/')
-        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.post(post_link + 'attach',
                           upload_files=[('file_info', 'test.txt', 'test')])
         # move ticket
@@ -2052,10 +2143,14 @@ class TestFunctionalController(TrackerTestController):
         attachs = r.html.findAll('div', attrs={'class': 'attachment_thumb'})
         ta = str(attachs[1])  # ticket's attachments
         ca = str(attachs[2])  # comment's attachments
-        assert_in('<a href="/p/test2/bugs2/1/attachment/neo-icon-set-454545-256x350.png"', ta)
-        assert_in('<img src="/p/test2/bugs2/1/attachment/neo-icon-set-454545-256x350.png/thumb"', ta)
+        assert_in(
+            '<a href="/p/test2/bugs2/1/attachment/neo-icon-set-454545-256x350.png"', ta)
+        assert_in(
+            '<img src="/p/test2/bugs2/1/attachment/neo-icon-set-454545-256x350.png/thumb"', ta)
         p = M.Post.query.find().sort('timestamp', 1).first()
-        assert_in('<a href="/p/test2/bugs2/_discuss/thread/%s/%s/attachment/test.txt"' % (p.thread_id, p.slug), ca)
+        assert_in(
+            '<a href="/p/test2/bugs2/_discuss/thread/%s/%s/attachment/test.txt"' %
+            (p.thread_id, p.slug), ca)
         for attach in M.BaseAttachment.query.find():
             assert_equal(attach.app_config_id, bugs2.config._id)
             if attach.attachment_type == 'DiscussionAttachment':
@@ -2079,7 +2174,7 @@ class TestFunctionalController(TrackerTestController):
         p = M.Project.query.get(shortname='test')
         dummy_tracker = p.app_instance('dummy')
         r = self.app.post('/p/test/bugs/1/move',
-                params={'tracker': str(dummy_tracker.config._id)}).follow()
+                          params={'tracker': str(dummy_tracker.config._id)}).follow()
         assert_equal(r.request.path, '/p/test/dummy/1/')
         assert_in('I am comment', r)
 
@@ -2089,7 +2184,8 @@ class TestFunctionalController(TrackerTestController):
         self.new_ticket(summary='a', labels='tag1,tag2')
         self.new_ticket(summary='b', labels='tag2')
         self.new_ticket(summary='c', labels='42cc,test')
-        # Testing only empty 'term', because mim doesn't support aggregation calls
+        # Testing only empty 'term', because mim doesn't support aggregation
+        # calls
         r = self.app.get('/p/test/bugs/tags')
         assert_equal(json.loads(r.body), [])
         r = self.app.get('/p/test/bugs/tags?term=')
@@ -2104,47 +2200,57 @@ class TestFunctionalController(TrackerTestController):
         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 comment'
         self.app.post(f['action'].encode('utf-8'), params=params,
-                          headers={'Referer': '/bugs/1/'.encode("utf-8")})
+                      headers={'Referer': '/bugs/1/'.encode("utf-8")})
         r = self.app.get('/bugs/1/', dict(page=1))
-        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'])
         self.app.post(post_link + 'attach',
-                          upload_files=[('file_info', 'test.txt', 'test attach')])
+                      upload_files=[('file_info', 'test.txt', 'test attach')])
         r = self.app.get('/p/test/bugs/1/')
         discussion_url = r.html.findAll('form')[-1]['action'][:-4]
         r = self.app.get('/rest/p/test/bugs/1/')
         r = json.loads(r.body)
-        assert_equal(r['ticket']['discussion_thread_url'],'http://localhost/rest%s' % discussion_url)
+        assert_equal(r['ticket']['discussion_thread_url'],
+                     'http://localhost/rest%s' % discussion_url)
         slug = r['ticket']['discussion_thread']['posts'][0]['slug']
-        assert_equal(r['ticket']['discussion_thread']['posts'][0]['attachments'][0]['url'],
-                     'http://localhost%s%s/attachment/test.txt' % (discussion_url, slug))
-        assert_equal(r['ticket']['discussion_thread']['posts'][0]['attachments'][0]['bytes'], 11)
+        assert_equal(
+            r['ticket']['discussion_thread'][
+                'posts'][0]['attachments'][0]['url'],
+            'http://localhost%s%s/attachment/test.txt' % (discussion_url, slug))
+        assert_equal(r['ticket']['discussion_thread']['posts']
+                     [0]['attachments'][0]['bytes'], 11)
 
         file_name = 'test_root.py'
         file_data = file(__file__).read()
         upload = ('attachment', file_name, file_data)
-        r = self.app.post('/bugs/1/update_ticket',{
-            'summary':'test rest attach'
+        r = self.app.post('/bugs/1/update_ticket', {
+            'summary': 'test rest attach'
         }, upload_files=[upload]).follow()
         r = self.app.get('/rest/p/test/bugs/1/')
         r = json.loads(r.body)
-        assert_equal(r['ticket']['attachments'][0]['url'], 'http://localhost/p/test/bugs/1/attachment/test_root.py')
+        assert_equal(r['ticket']['attachments'][0]['url'],
+                     'http://localhost/p/test/bugs/1/attachment/test_root.py')
 
     def test_html_escaping(self):
         with mock.patch.object(mail_tasks.smtp_client, '_client') as _client:
-            self.new_ticket(summary='test <h2> ticket', status='open', _milestone='2.0')
+            self.new_ticket(summary='test <h2> ticket',
+                            status='open', _milestone='2.0')
             ThreadLocalORMSession.flush_all()
             M.MonQTask.run_ready()
             ThreadLocalORMSession.flush_all()
-            email = M.MonQTask.query.find(dict(task_name='allura.tasks.mail_tasks.sendmail')).first()
-            assert_equal(email.kwargs.subject, '[test:bugs] #1 test <h2> ticket')
+            email = M.MonQTask.query.find(
+                dict(task_name='allura.tasks.mail_tasks.sendmail')).first()
+            assert_equal(email.kwargs.subject,
+                         '[test:bugs] #1 test <h2> ticket')
             text = email.kwargs.text
             assert '** [bugs:#1] test &lt;h2&gt; ticket**' in text
             mail_tasks.sendmail(
                 fromaddr=str(c.user._id),
-                destinations=[ str(c.user._id) ],
+                destinations=[str(c.user._id)],
                 text=text,
                 reply_to=u'noreply@sf.net',
                 subject=email.kwargs.subject,
@@ -2156,8 +2262,8 @@ class TestFunctionalController(TrackerTestController):
             assert '<p><strong> <a class="alink" href="http://localhost/p/test/bugs/1/">[bugs:#1]</a> test &lt;h2&gt; ticket</strong></p>' in body
 
 
-
 class TestMilestoneAdmin(TrackerTestController):
+
     def _post(self, params, **kw):
         params['open_status_names'] = 'aa bb'
         params['closed_status_names'] = 'cc'
@@ -2171,7 +2277,7 @@ class TestMilestoneAdmin(TrackerTestController):
                  show_in_search='on',
                  type='milestone',
                  milestones=[
-                    dict((k, v) for k, v in d.iteritems()) for d in mf['milestones']])
+                     dict((k, v) for k, v in d.iteritems()) for d in mf['milestones']])
             for mf in milestones]}
         return self._post(params)
 
@@ -2187,7 +2293,7 @@ class TestMilestoneAdmin(TrackerTestController):
             dict(label='releases', milestones=[dict(name='1.0/beta')])
         ])
         self.new_ticket(summary='test new milestone',
-                        **{'custom_fields._releases':'1.0-beta'})
+                        **{'custom_fields._releases': '1.0-beta'})
         assert tm.Ticket.query.find({
             'custom_fields._releases': '1.0-beta'}).count() == 1
         r = self._post_milestones([])
@@ -2201,7 +2307,7 @@ class TestMilestoneAdmin(TrackerTestController):
             dict(label='releases', milestones=[dict(name='1.0/beta')])
         ])
         self.new_ticket(summary='test new milestone',
-                        **{'custom_fields._releases':'1.0-beta'})
+                        **{'custom_fields._releases': '1.0-beta'})
         r = self._post_milestones([
             dict(label='versions', milestones=[dict(name='1.0/beta')])
         ])
@@ -2210,7 +2316,7 @@ class TestMilestoneAdmin(TrackerTestController):
         assert '1.0-beta' in r
         # TODO: This doesn't work - need to make milestone custom fields
         #       renameable.
-        #assert tm.Ticket.query.find({
+        # assert tm.Ticket.query.find({
         #    'custom_fields._versions': '1.0-beta'}).count() == 1
 
     def test_create_milestone(self):
@@ -2229,7 +2335,7 @@ class TestMilestoneAdmin(TrackerTestController):
             dict(label='releases', milestones=[dict(name='1.0/beta')])
         ])
         self.new_ticket(summary='test new milestone',
-                        **{'custom_fields._releases':'1.0-beta'})
+                        **{'custom_fields._releases': '1.0-beta'})
         assert tm.Ticket.query.find({
             'custom_fields._releases': '1.0-beta'}).count() == 1
         r = self._post_milestones([
@@ -2245,7 +2351,7 @@ class TestMilestoneAdmin(TrackerTestController):
             dict(label='releases', milestones=[dict(name='1.0')])
         ])
         self.new_ticket(summary='test new milestone',
-                        **{'custom_fields._releases':'1.0'})
+                        **{'custom_fields._releases': '1.0'})
         r = self._post_milestones([
             dict(label='releases', milestones=[
                 dict(name='1.1', old_name='1.0')])
@@ -2258,13 +2364,16 @@ class TestMilestoneAdmin(TrackerTestController):
         assert tm.Ticket.query.find({
             'custom_fields._releases': '1.1'}).count() == 1
 
+
 def post_install_hook(app):
     role_anon = M.ProjectRole.by_name('*anonymous')._id
     app.config.acl.append(M.ACE.allow(role_anon, 'post'))
     app.config.acl.append(M.ACE.allow(role_anon, 'create'))
     app.config.acl.append(M.ACE.allow(role_anon, 'update'))
 
+
 class TestEmailMonitoring(TrackerTestController):
+
     def __init__(self):
         super(TestEmailMonitoring, self).__init__()
         self.test_email = 'mailinglist@example.com'
@@ -2273,7 +2382,7 @@ class TestEmailMonitoring(TrackerTestController):
         r = self.app.post('/admin/bugs/set_options', params={
             'TicketMonitoringEmail': self.test_email,
             'TicketMonitoringType': monitoring_type,
-            })
+        })
         return r
 
     def test_set_options(self):
@@ -2290,11 +2399,12 @@ class TestEmailMonitoring(TrackerTestController):
     def test_notifications_moderators(self, is_spam, send_direct):
         is_spam.return_value = True
         self.new_ticket(summary='test moderation', mount_point='/doc-bugs/')
-        self.app.post('/doc-bugs/1/update_ticket',{
-            'summary':'test moderation',
-            'comment':'test unmoderated post'
+        self.app.post('/doc-bugs/1/update_ticket', {
+            'summary': 'test moderation',
+            'comment': 'test unmoderated post'
         }, extra_environ=dict(username='*anonymous'))
-        send_direct.assert_called_with(str(M.User.query.get(username='test-admin')._id))
+        send_direct.assert_called_with(
+            str(M.User.query.get(username='test-admin')._id))
 
     @patch('forgetracker.model.ticket.Notification.send_simple')
     def test_notifications_new(self, send_simple):
@@ -2347,14 +2457,14 @@ class TestEmailMonitoring(TrackerTestController):
         send_simple.assert_called_once_with(self.test_email)
         send_simple.reset_mock()
         self.app.post('/bugs/1/update_ticket', {
-                'summary': 'test',
-                'description': 'update 1'})
+            'summary': 'test',
+            'description': 'update 1'})
         send_simple.assert_called_once_with(self.test_email)
         send_simple.reset_mock()
         self.app.post('/bugs/1/update_ticket', {
-                'summary': 'test',
-                'description': 'update 2',
-                'private': '1'})
+            'summary': 'test',
+            'description': 'update 2',
+            'private': '1'})
         assert not send_simple.called
 
     @patch('forgetracker.tracker_main.M.Notification.send_simple')
@@ -2366,7 +2476,8 @@ class TestEmailMonitoring(TrackerTestController):
         p.notifications_disabled = True
         self._set_options()
         with patch.object(M.Project.query, 'get') as get:
-            get.side_effect = lambda *a,**k: None if 'bugs' in k.get('shortname', '') else p
+            get.side_effect = lambda * \
+                a, **k: None if 'bugs' in k.get('shortname', '') else p
             self.new_ticket(summary='test')
         assert send_simple.call_count == 0, send_simple.call_count
 
@@ -2376,11 +2487,16 @@ class TestEmailMonitoring(TrackerTestController):
         self.new_ticket(summary='test')
         ThreadLocalORMSession.flush_all()
         M.MonQTask.run_ready()
-        email_tasks = M.MonQTask.query.find(dict(task_name='allura.tasks.mail_tasks.sendsimplemail')).all()
-        assert 'Sent from sourceforge.net because mailinglist@example.com is subscribed to http://localhost/p/test/bugs/' in email_tasks[0].kwargs['text']
-        assert 'a project admin can change settings at http://localhost/p/test/admin/bugs/options' in email_tasks[0].kwargs['text']
+        email_tasks = M.MonQTask.query.find(
+            dict(task_name='allura.tasks.mail_tasks.sendsimplemail')).all()
+        assert 'Sent from sourceforge.net because mailinglist@example.com is subscribed to http://localhost/p/test/bugs/' in email_tasks[
+            0].kwargs['text']
+        assert 'a project admin can change settings at http://localhost/p/test/admin/bugs/options' in email_tasks[
+            0].kwargs['text']
+
 
 class TestCustomUserField(TrackerTestController):
+
     def setUp(self):
         super(TestCustomUserField, self).setUp()
         params = dict(
@@ -2389,20 +2505,21 @@ class TestCustomUserField(TrackerTestController):
                      show_in_search='on')],
             open_status_names='aa bb',
             closed_status_names='cc',
-            )
+        )
         self.app.post(
             '/admin/bugs/set_custom_fields',
             params=variable_encode(params))
 
     def test_blank_user(self):
         kw = {'custom_fields._code_review': ''}
-        ticket_view = self.new_ticket(summary='test custom fields', **kw).follow()
+        ticket_view = self.new_ticket(
+            summary='test custom fields', **kw).follow()
         # summary header shows 'nobody'
         assert ticket_view.html.findAll('label', '

<TRUNCATED>

Mime
View raw message