incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [17/32] PEP8 cleanup
Date Fri, 10 Jan 2014 18:19:41 GMT
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/Allura/allura/tests/model/test_discussion.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_discussion.py b/Allura/allura/tests/model/test_discussion.py
index 51a13ee..6a7878f 100644
--- a/Allura/allura/tests/model/test_discussion.py
+++ b/Allura/allura/tests/model/test_discussion.py
@@ -41,6 +41,7 @@ from allura.lib import helpers as h
 from allura.tests import TestController
 from alluratest.controller import setup_global_objects
 
+
 def setUp():
     controller = TestController()
     controller.setUp()
@@ -55,6 +56,7 @@ def setUp():
 def tearDown():
     ThreadLocalORMSession.close_all()
 
+
 @with_setup(setUp, tearDown)
 def test_discussion_methods():
     d = M.Discussion(shortname='test', name='test')
@@ -75,6 +77,7 @@ def test_discussion_methods():
     ThreadLocalORMSession.flush_all()
     ThreadLocalORMSession.close_all()
 
+
 @with_setup(setUp, tearDown)
 def test_thread_methods():
     d = M.Discussion(shortname='test', name='test')
@@ -120,6 +123,7 @@ def test_thread_methods():
     assert len(t.find_posts()) == 0
     t.delete()
 
+
 @with_setup(setUp, tearDown)
 def test_thread_new():
     with mock.patch('allura.model.discuss.h.nonce') as nonce:
@@ -137,6 +141,7 @@ def test_thread_new():
         assert_equals(t1_2.subject, 'Test Thread One')
         assert_equals(t2_2.subject, 'Test Thread Two')
 
+
 @with_setup(setUp, tearDown)
 def test_post_methods():
     d = M.Discussion(shortname='test', name='test')
@@ -170,20 +175,21 @@ def test_post_methods():
     p.delete()
     assert t.num_replies == 0
 
+
 @with_setup(setUp, tearDown)
 def test_attachment_methods():
     d = M.Discussion(shortname='test', name='test')
     t = M.Thread.new(discussion_id=d._id, subject='Test Thread')
     p = t.post('This is a post')
     p_att = p.attach('foo.text', StringIO('Hello, world!'),
-                discussion_id=d._id,
-                thread_id=t._id,
-                post_id=p._id)
+                     discussion_id=d._id,
+                     thread_id=t._id,
+                     post_id=p._id)
     t_att = p.attach('foo2.text', StringIO('Hello, thread!'),
-                discussion_id=d._id,
-                thread_id=t._id)
+                     discussion_id=d._id,
+                     thread_id=t._id)
     d_att = p.attach('foo3.text', StringIO('Hello, discussion!'),
-                discussion_id=d._id)
+                     discussion_id=d._id)
 
     ThreadLocalORMSession.flush_all()
     assert p_att.post == p
@@ -196,27 +202,29 @@ def test_attachment_methods():
     # Test notification in mail
     t = M.Thread.new(discussion_id=d._id, subject='Test comment notification')
     fs = FieldStorage()
-    fs.name='file_info'
-    fs.filename='fake.txt'
+    fs.name = 'file_info'
+    fs.filename = 'fake.txt'
     fs.type = 'text/plain'
-    fs.file=StringIO('this is the content of the fake file\n')
-    p = t.post(text=u'test message', forum= None, subject= '', file_info=fs)
+    fs.file = StringIO('this is the content of the fake file\n')
+    p = t.post(text=u'test message', forum=None, subject='', file_info=fs)
     ThreadLocalORMSession.flush_all()
-    n = M.Notification.query.get(subject=u'[test:wiki] Test comment notification')
+    n = M.Notification.query.get(
+        subject=u'[test:wiki] Test comment notification')
     assert '\nAttachment: fake.txt (37 Bytes; text/plain)' in n.text
 
+
 @with_setup(setUp, tearDown())
 def test_multiple_attachments():
     test_file1 = FieldStorage()
     test_file1.name = 'file_info'
     test_file1.filename = 'test1.txt'
     test_file1.type = 'text/plain'
-    test_file1.file=StringIO('test file1\n')
+    test_file1.file = StringIO('test file1\n')
     test_file2 = FieldStorage()
     test_file2.name = 'file_info'
     test_file2.filename = 'test2.txt'
     test_file2.type = 'text/plain'
-    test_file2.file=StringIO('test file2\n')
+    test_file2.file = StringIO('test file2\n')
     d = M.Discussion(shortname='test', name='test')
     t = M.Thread.new(discussion_id=d._id, subject='Test Thread')
     test_post = t.post('test post')
@@ -227,13 +235,14 @@ def test_multiple_attachments():
     assert 'test1.txt' in [attaches[0].filename, attaches[1].filename]
     assert 'test2.txt' in [attaches[0].filename, attaches[1].filename]
 
+
 @with_setup(setUp, tearDown)
 def test_add_attachment():
     test_file = FieldStorage()
     test_file.name = 'file_info'
     test_file.filename = 'test.txt'
     test_file.type = 'text/plain'
-    test_file.file=StringIO('test file\n')
+    test_file.file = StringIO('test file\n')
     d = M.Discussion(shortname='test', name='test')
     t = M.Thread.new(discussion_id=d._id, subject='Test Thread')
     test_post = t.post('test post')
@@ -244,6 +253,7 @@ def test_add_attachment():
     assert attach.filename == 'test.txt', attach.filename
     assert attach.content_type == 'text/plain', attach.content_type
 
+
 def test_notification_two_attaches():
     d = M.Discussion(shortname='test', name='test')
     t = M.Thread.new(discussion_id=d._id, subject='Test comment notification')
@@ -259,18 +269,20 @@ def test_notification_two_attaches():
     fs2.file = StringIO('this is the content of the fake file\n')
     t.post(text=u'test message', forum=None, subject='', file_info=[fs1, fs2])
     ThreadLocalORMSession.flush_all()
-    n = M.Notification.query.get(subject=u'[test:wiki] Test comment notification')
+    n = M.Notification.query.get(
+        subject=u'[test:wiki] Test comment notification')
     assert '\nAttachment: fake.txt (37 Bytes; text/plain)  fake2.txt (37 Bytes; text/plain)' in n.text
 
+
 @with_setup(setUp, tearDown)
 def test_discussion_delete():
     d = M.Discussion(shortname='test', name='test')
     t = M.Thread.new(discussion_id=d._id, subject='Test Thread')
     p = t.post('This is a post')
     p.attach('foo.text', StringIO(''),
-                discussion_id=d._id,
-                thread_id=t._id,
-                post_id=p._id)
+             discussion_id=d._id,
+             thread_id=t._id,
+             post_id=p._id)
     r = M.ArtifactReference.from_artifact(d)
     rid = d.index_id()
     ThreadLocalORMSession.flush_all()
@@ -278,30 +290,33 @@ def test_discussion_delete():
     ThreadLocalORMSession.flush_all()
     assert_equals(M.ArtifactReference.query.find(dict(_id=rid)).count(), 0)
 
+
 @with_setup(setUp, tearDown)
 def test_thread_delete():
     d = M.Discussion(shortname='test', name='test')
     t = M.Thread.new(discussion_id=d._id, subject='Test Thread')
     p = t.post('This is a post')
     p.attach('foo.text', StringIO(''),
-                discussion_id=d._id,
-                thread_id=t._id,
-                post_id=p._id)
+             discussion_id=d._id,
+             thread_id=t._id,
+             post_id=p._id)
     ThreadLocalORMSession.flush_all()
     t.delete()
 
+
 @with_setup(setUp, tearDown)
 def test_post_delete():
     d = M.Discussion(shortname='test', name='test')
     t = M.Thread.new(discussion_id=d._id, subject='Test Thread')
     p = t.post('This is a post')
     p.attach('foo.text', StringIO(''),
-                discussion_id=d._id,
-                thread_id=t._id,
-                post_id=p._id)
+             discussion_id=d._id,
+             thread_id=t._id,
+             post_id=p._id)
     ThreadLocalORMSession.flush_all()
     p.delete()
 
+
 @with_setup(setUp, tearDown)
 def test_post_permission_check():
     d = M.Discussion(shortname='test', name='test')
@@ -397,16 +412,18 @@ def test_post_notify():
         else:
             assert False, 'send_simple must not be called'
 
+
 @with_setup(setUp, tearDown)
 @patch('allura.model.discuss.c.project.users_with_role')
 def test_is_spam_for_admin(users):
-    users.return_value = [c.user,]
+    users.return_value = [c.user, ]
     d = M.Discussion(shortname='test', name='test')
     t = M.Thread(discussion_id=d._id, subject='Test Thread')
     t.post('This is a post')
     post = M.Post.query.get(text='This is a post')
     assert not t.is_spam(post), t.is_spam(post)
 
+
 @with_setup(setUp, tearDown)
 @patch('allura.model.discuss.c.project.users_with_role')
 def test_is_spam(role):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/Allura/allura/tests/model/test_filesystem.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_filesystem.py b/Allura/allura/tests/model/test_filesystem.py
index 3b625f7..312807f 100644
--- a/Allura/allura/tests/model/test_filesystem.py
+++ b/Allura/allura/tests/model/test_filesystem.py
@@ -33,10 +33,12 @@ from alluratest.controller import setup_unit_test
 
 
 class File(M.File):
+
     class __mongometa__:
         session = M.session.main_orm_session
 Mapper.compile_all()
 
+
 class TestFile(TestCase):
 
     def setUp(self):
@@ -128,8 +130,8 @@ class TestFile(TestCase):
                 patch('allura.lib.utils.etag_cache') as etag_cache:
             response_body = list(f.serve())
             etag_cache.assert_called_once_with(u'{}?{}'.format(f.filename,
-                f._id.generation_time).encode('utf-8'))
-            assert_equal([ 'test1' ], response_body)
+                                                               f._id.generation_time).encode('utf-8'))
+            assert_equal(['test1'], response_body)
             assert_equal(response.content_type, f.content_type)
             assert 'Content-Disposition' not in response.headers
 
@@ -141,11 +143,11 @@ class TestFile(TestCase):
                 patch('allura.lib.utils.etag_cache') as etag_cache:
             response_body = list(f.serve(embed=False))
             etag_cache.assert_called_once_with(u'{}?{}'.format(f.filename,
-                f._id.generation_time).encode('utf-8'))
-            assert_equal([ 'test1' ], response_body)
+                                                               f._id.generation_time).encode('utf-8'))
+            assert_equal(['test1'], response_body)
             assert_equal(response.content_type, f.content_type)
             assert_equal(response.headers['Content-Disposition'],
-                'attachment;filename="te s\xe0\xad\xae1.txt"')
+                         'attachment;filename="te s\xe0\xad\xae1.txt"')
 
     def test_image(self):
         path = os.path.join(
@@ -154,7 +156,7 @@ class TestFile(TestCase):
             f, t = File.save_image(
                 'user.png',
                 fp,
-                thumbnail_size=(16,16),
+                thumbnail_size=(16, 16),
                 square=True,
                 save_original=True)
         self.session.flush()
@@ -171,7 +173,7 @@ class TestFile(TestCase):
         f, t = File.save_image(
             'file.txt',
             StringIO('blah'),
-            thumbnail_size=(16,16),
+            thumbnail_size=(16, 16),
             square=True,
             save_original=True)
         assert f == None
@@ -181,14 +183,15 @@ class TestFile(TestCase):
         f, t = File.save_image(
             'bogus.png',
             StringIO('bogus data here!'),
-            thumbnail_size=(16,16),
+            thumbnail_size=(16, 16),
             square=True,
             save_original=True)
         assert f == None
         assert t == None
 
     def test_partial_image_as_attachment(self):
-        path = os.path.join(os.path.dirname(__file__), '..', 'data', 'user.png')
+        path = os.path.join(os.path.dirname(__file__),
+                            '..', 'data', 'user.png')
         fp = BytesIO(open(path, 'rb').read(500))
         c.app.config._id = None
         attachment = M.BaseAttachment.save_attachment('user.png', fp,
@@ -198,11 +201,13 @@ class TestFile(TestCase):
         assert_equal(attachment.filename, 'user.png')
 
     def test_attachment_name_encoding(self):
-        path = os.path.join(os.path.dirname(__file__), '..', 'data', 'user.png')
+        path = os.path.join(os.path.dirname(__file__),
+                            '..', 'data', 'user.png')
         fp = open(path, 'rb')
         c.app.config._id = None
-        attachment = M.BaseAttachment.save_attachment(b'Strukturpr\xfcfung.dvi', fp,
-                                                      save_original=True)
+        attachment = M.BaseAttachment.save_attachment(
+            b'Strukturpr\xfcfung.dvi', fp,
+            save_original=True)
         assert type(attachment) != tuple   # tuple is for (img, thumb) pairs
         assert_equal(attachment.filename, u'Strukturpr\xfcfung.dvi')
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/Allura/allura/tests/model/test_monq.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_monq.py b/Allura/allura/tests/model/test_monq.py
index 217fbd4..4ba2f0b 100644
--- a/Allura/allura/tests/model/test_monq.py
+++ b/Allura/allura/tests/model/test_monq.py
@@ -23,15 +23,17 @@ from ming.orm import ThreadLocalORMSession
 from alluratest.controller import setup_basic_test, setup_global_objects
 from allura import model as M
 
+
 def setUp():
     setup_basic_test()
     ThreadLocalORMSession.close_all()
     setup_global_objects()
     M.MonQTask.query.remove({})
 
+
 @with_setup(setUp)
 def test_basic_task():
-    task = M.MonQTask.post(pprint.pformat, ([5,6],))
+    task = M.MonQTask.post(pprint.pformat, ([5, 6],))
     ThreadLocalORMSession.flush_all()
     ThreadLocalORMSession.close_all()
     task = M.MonQTask.get()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/Allura/allura/tests/model/test_neighborhood.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_neighborhood.py b/Allura/allura/tests/model/test_neighborhood.py
index 0f77bcc..afc53c6 100644
--- a/Allura/allura/tests/model/test_neighborhood.py
+++ b/Allura/allura/tests/model/test_neighborhood.py
@@ -34,10 +34,12 @@ def setUp():
     setup_basic_test()
     setup_with_tools()
 
+
 @td.with_wiki
 def setup_with_tools():
     setup_global_objects()
 
+
 @with_setup(setUp)
 def test_neighborhood():
     neighborhood = M.Neighborhood.query.get(name='Projects')
@@ -75,7 +77,8 @@ def test_neighborhood():
     for style in styles_list:
         assert test_css_dict[style['name']] == style['value']
         if style['name'] == 'titlebarcolor':
-            assert '<option value="dark" selected="selected">' in style['additional']
+            assert '<option value="dark" selected="selected">' in style[
+                'additional']
 
     # Check neighborhood custom css showing
     neighborhood.features['css'] = 'none'

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/Allura/allura/tests/model/test_notification.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_notification.py b/Allura/allura/tests/model/test_notification.py
index 78993ae..d5f0a14 100644
--- a/Allura/allura/tests/model/test_notification.py
+++ b/Allura/allura/tests/model/test_notification.py
@@ -32,6 +32,7 @@ from allura.lib import helpers as h
 from allura.tests import decorators as td
 from forgewiki import model as WM
 
+
 class TestNotification(unittest.TestCase):
 
     def setUp(self):
@@ -45,7 +46,7 @@ class TestNotification(unittest.TestCase):
         _clear_notifications()
         ThreadLocalORMSession.flush_all()
         ThreadLocalORMSession.close_all()
-        M.notification.MAILBOX_QUIESCENT=None # disable message combining
+        M.notification.MAILBOX_QUIESCENT = None  # disable message combining
 
     def test_subscribe_unsubscribe(self):
         M.Mailbox.subscribe(type='direct')
@@ -56,7 +57,7 @@ class TestNotification(unittest.TestCase):
             app_config_id=c.app.config._id,
             user_id=c.user._id)).all()
         assert len(subscriptions) == 1
-        assert subscriptions[0].type=='direct'
+        assert subscriptions[0].type == 'direct'
         assert M.Mailbox.query.find().count() == 1
         M.Mailbox.unsubscribe()
         ThreadLocalORMSession.flush_all()
@@ -74,28 +75,28 @@ class TestNotification(unittest.TestCase):
         wiki = c.project.app_instance('wiki')
         page = WM.Page.query.get(app_config_id=wiki.config._id)
         notification = M.Notification(
-                _id='_id',
-                ref=page.ref,
-                from_address='from_address',
-                reply_to_address='reply_to_address',
-                in_reply_to='in_reply_to',
-                references=['a'],
-                subject='subject',
-                text='text',
-            )
+            _id='_id',
+            ref=page.ref,
+            from_address='from_address',
+            reply_to_address='reply_to_address',
+            in_reply_to='in_reply_to',
+            references=['a'],
+            subject='subject',
+            text='text',
+        )
         notification.footer = lambda: ' footer'
         notification.send_direct(c.user._id)
         sendmail.post.assert_called_once_with(
-                destinations=[str(c.user._id)],
-                fromaddr='from_address',
-                reply_to='reply_to_address',
-                subject='subject',
-                message_id='_id',
-                in_reply_to='in_reply_to',
-                references=['a'],
-                sender='wiki@test.p.in.sf.net',
-                text='text footer',
-            )
+            destinations=[str(c.user._id)],
+            fromaddr='from_address',
+            reply_to='reply_to_address',
+            subject='subject',
+            message_id='_id',
+            in_reply_to='in_reply_to',
+            references=['a'],
+            sender='wiki@test.p.in.sf.net',
+            text='text footer',
+        )
 
     @mock.patch('allura.tasks.mail_tasks.sendmail')
     def test_send_direct_no_access(self, sendmail):
@@ -106,14 +107,14 @@ class TestNotification(unittest.TestCase):
         ThreadLocalORMSession.flush_all()
         ThreadLocalORMSession.close_all()
         notification = M.Notification(
-                _id='_id',
-                ref=page.ref,
-                from_address='from_address',
-                reply_to_address='reply_to_address',
-                in_reply_to='in_reply_to',
-                subject='subject',
-                text='text',
-            )
+            _id='_id',
+            ref=page.ref,
+            from_address='from_address',
+            reply_to_address='reply_to_address',
+            in_reply_to='in_reply_to',
+            subject='subject',
+            text='text',
+        )
         notification.footer = lambda: ' footer'
         notification.send_direct(c.user._id)
         assert_equal(sendmail.post.call_count, 0)
@@ -136,29 +137,30 @@ class TestNotification(unittest.TestCase):
         wiki = project1.app_instance('wiki')
         page = WM.Page.query.get(app_config_id=wiki.config._id)
         notification = M.Notification(
-                _id='_id',
-                ref=page.ref,
-                from_address='from_address',
-                reply_to_address='reply_to_address',
-                in_reply_to='in_reply_to',
-                references=['a'],
-                subject='subject',
-                text='text',
-            )
+            _id='_id',
+            ref=page.ref,
+            from_address='from_address',
+            reply_to_address='reply_to_address',
+            in_reply_to='in_reply_to',
+            references=['a'],
+            subject='subject',
+            text='text',
+        )
         notification.footer = lambda: ' footer'
         c.project = project2
         notification.send_direct(c.user._id)
         sendmail.post.assert_called_once_with(
-                destinations=[str(c.user._id)],
-                fromaddr='from_address',
-                reply_to='reply_to_address',
-                subject='subject',
-                message_id='_id',
-                in_reply_to='in_reply_to',
-                references=['a'],
-                sender='wiki@test.p.in.sf.net',
-                text='text footer',
-            )
+            destinations=[str(c.user._id)],
+            fromaddr='from_address',
+            reply_to='reply_to_address',
+            subject='subject',
+            message_id='_id',
+            in_reply_to='in_reply_to',
+            references=['a'],
+            sender='wiki@test.p.in.sf.net',
+            text='text footer',
+        )
+
 
 class TestPostNotifications(unittest.TestCase):
 
@@ -175,7 +177,7 @@ class TestPostNotifications(unittest.TestCase):
         ThreadLocalORMSession.flush_all()
         ThreadLocalORMSession.close_all()
         self.pg = WM.Page.query.get(app_config_id=c.app.config._id)
-        M.notification.MAILBOX_QUIESCENT=None # disable message combining
+        M.notification.MAILBOX_QUIESCENT = None  # disable message combining
         while M.MonQTask.run_ready('setup'):
             ThreadLocalORMSession.flush_all()
 
@@ -206,7 +208,7 @@ class TestPostNotifications(unittest.TestCase):
         ThreadLocalORMSession.flush_all()
         M.MonQTask.run_ready()
         ThreadLocalORMSession.flush_all()
-        assert M.Mailbox.query.find().count()==1
+        assert M.Mailbox.query.find().count() == 1
         mbox = M.Mailbox.query.get()
         assert len(mbox.queue) == 1
         assert not mbox.queue_empty
@@ -218,10 +220,13 @@ class TestPostNotifications(unittest.TestCase):
         self._post_notification()
         ThreadLocalORMSession.flush_all()
 
-        assert_equal(M.Notification.query.get()['from_address'], '"Test Admin" <test-admin@users.localhost>')
+        assert_equal(M.Notification.query.get()
+                     ['from_address'], '"Test Admin" <test-admin@users.localhost>')
         assert_equal(M.Mailbox.query.find().count(), 2)
 
-        M.MonQTask.run_ready()  # sends the notification out into "mailboxes", and from mailboxes into email tasks
+        # sends the notification out into "mailboxes", and from mailboxes into
+        # email tasks
+        M.MonQTask.run_ready()
         mboxes = M.Mailbox.query.find().all()
         assert_equal(len(mboxes), 2)
         assert_equal(len(mboxes[0].queue), 1)
@@ -230,16 +235,20 @@ class TestPostNotifications(unittest.TestCase):
         assert not mboxes[1].queue_empty
 
         email_tasks = M.MonQTask.query.find({'state': 'ready'}).all()
-        assert_equal(len(email_tasks), 2)  # make sure both subscribers will get an email
+        # make sure both subscribers will get an email
+        assert_equal(len(email_tasks), 2)
 
         first_destinations = [e.kwargs['destinations'][0] for e in email_tasks]
         assert_in(str(c.user._id), first_destinations)
         assert_in(str(user2._id), first_destinations)
-        assert_equal(email_tasks[0].kwargs['fromaddr'], '"Test Admin" <test-admin@users.localhost>')
-        assert_equal(email_tasks[1].kwargs['fromaddr'], '"Test Admin" <test-admin@users.localhost>')
+        assert_equal(email_tasks[0].kwargs['fromaddr'],
+                     '"Test Admin" <test-admin@users.localhost>')
+        assert_equal(email_tasks[1].kwargs['fromaddr'],
+                     '"Test Admin" <test-admin@users.localhost>')
         assert_equal(email_tasks[0].kwargs['sender'], 'wiki@test.p.in.sf.net')
         assert_equal(email_tasks[1].kwargs['sender'], 'wiki@test.p.in.sf.net')
-        assert email_tasks[0].kwargs['text'].startswith('Home modified by Test Admin')
+        assert email_tasks[0].kwargs['text'].startswith(
+            'Home modified by Test Admin')
         assert 'you indicated interest in ' in email_tasks[0].kwargs['text']
 
     def test_permissions(self):
@@ -249,6 +258,7 @@ class TestPostNotifications(unittest.TestCase):
         u = M.User.query.get(username='test-admin')
         self._subscribe(user=u)
         # Simulate a permission check failure.
+
         def patched_has_access(*args, **kw):
             def predicate(*args, **kw):
                 return False
@@ -272,15 +282,14 @@ class TestPostNotifications(unittest.TestCase):
 
     def test_footer(self):
         footer = MailFooter.monitored(
-                'test@mail.com',
-                'http://test1.com',
-                'http://test2.com')
+            'test@mail.com',
+            'http://test1.com',
+            'http://test2.com')
         assert 'test@mail.com is subscribed to http://test1.com' in footer
         assert 'admin can change settings at http://test2.com' in footer
         footer = MailFooter.standard(M.Notification())
         assert 'Sent from sourceforge.net because you indicated interest in' in footer
 
-
     def _subscribe(self, **kw):
         self.pg.subscribe(type='direct', **kw)
         ThreadLocalORMSession.flush_all()
@@ -289,6 +298,7 @@ class TestPostNotifications(unittest.TestCase):
     def _post_notification(self):
         return M.Notification.post(self.pg, 'metadata')
 
+
 class TestSubscriptionTypes(unittest.TestCase):
 
     def setUp(self):
@@ -304,7 +314,7 @@ class TestSubscriptionTypes(unittest.TestCase):
         ThreadLocalORMSession.flush_all()
         ThreadLocalORMSession.close_all()
         self.pg = WM.Page.query.get(app_config_id=c.app.config._id)
-        M.notification.MAILBOX_QUIESCENT=None # disable message combining
+        M.notification.MAILBOX_QUIESCENT = None  # disable message combining
 
     def test_direct_sub(self):
         self._subscribe()
@@ -316,13 +326,13 @@ class TestSubscriptionTypes(unittest.TestCase):
 
     def test_digest_sub(self):
         self._subscribe(type='digest')
-        self._post_notification(text='x'*1024)
+        self._post_notification(text='x' * 1024)
         self._post_notification()
         M.Mailbox.fire_ready()
 
     def test_summary_sub(self):
         self._subscribe(type='summary')
-        self._post_notification(text='x'*1024)
+        self._post_notification(text='x' * 1024)
         self._post_notification()
         M.Mailbox.fire_ready()
 
@@ -333,8 +343,9 @@ class TestSubscriptionTypes(unittest.TestCase):
         self._test_message()
 
         self.setUp()
-        M.notification.MAILBOX_QUIESCENT=timedelta(minutes=1)
-        # will raise "assert msg is not None" since the new message is not 1 min old:
+        M.notification.MAILBOX_QUIESCENT = timedelta(minutes=1)
+        # will raise "assert msg is not None" since the new message is not 1
+        # min old:
         self.assertRaises(AssertionError, self._test_message)
 
     def _test_message(self):
@@ -347,8 +358,8 @@ class TestSubscriptionTypes(unittest.TestCase):
         ThreadLocalORMSession.flush_all()
         ThreadLocalORMSession.close_all()
         msg = M.MonQTask.query.get(
-                task_name='allura.tasks.mail_tasks.sendmail',
-                state='ready')
+            task_name='allura.tasks.mail_tasks.sendmail',
+            state='ready')
         assert msg is not None
         assert 'Home@wiki.test.p' in msg.kwargs['reply_to']
         u = M.User.by_username('test-admin')
@@ -371,6 +382,7 @@ class TestSubscriptionTypes(unittest.TestCase):
     @mock.patch('allura.model.notification.Notification')
     def test_direct_accumulation(self, mocked_notification, mocked_defaultdict):
         class OrderedDefaultDict(collections.OrderedDict):
+
             def __init__(self, factory=list, *a, **kw):
                 self._factory = factory
                 super(OrderedDefaultDict, self).__init__(*a, **kw)
@@ -383,24 +395,35 @@ class TestSubscriptionTypes(unittest.TestCase):
                 return value
 
         notifications = mocked_notification.query.find.return_value.all.return_value = [
-                mock.Mock(_id='n0', topic='metadata', subject='s1', from_address='f1', reply_to_address='rt1', author_id='a1'),
-                mock.Mock(_id='n1', topic='metadata', subject='s2', from_address='f2', reply_to_address='rt2', author_id='a2'),
-                mock.Mock(_id='n2', topic='metadata', subject='s2', from_address='f2', reply_to_address='rt2', author_id='a2'),
-                mock.Mock(_id='n3', topic='message', subject='s3', from_address='f3', reply_to_address='rt3', author_id='a3'),
-                mock.Mock(_id='n4', topic='message', subject='s3', from_address='f3', reply_to_address='rt3', author_id='a3'),
-            ]
+            mock.Mock(_id='n0', topic='metadata', subject='s1',
+                      from_address='f1', reply_to_address='rt1', author_id='a1'),
+            mock.Mock(_id='n1', topic='metadata', subject='s2',
+                      from_address='f2', reply_to_address='rt2', author_id='a2'),
+            mock.Mock(_id='n2', topic='metadata', subject='s2',
+                      from_address='f2', reply_to_address='rt2', author_id='a2'),
+            mock.Mock(_id='n3', topic='message', subject='s3',
+                      from_address='f3', reply_to_address='rt3', author_id='a3'),
+            mock.Mock(_id='n4', topic='message', subject='s3',
+                      from_address='f3', reply_to_address='rt3', author_id='a3'),
+        ]
         mocked_defaultdict.side_effect = OrderedDefaultDict
 
         u0 = bson.ObjectId()
-        mbox = M.Mailbox(type='direct', user_id=u0, queue=['n0', 'n1', 'n2', 'n3', 'n4'])
+        mbox = M.Mailbox(type='direct', user_id=u0,
+                         queue=['n0', 'n1', 'n2', 'n3', 'n4'])
         mbox.fire('now')
 
-        mocked_notification.query.find.assert_called_once_with({'_id': {'$in': ['n0', 'n1', 'n2', 'n3', 'n4']}})
-        # first notification should be sent direct, as its key values are unique
+        mocked_notification.query.find.assert_called_once_with(
+            {'_id': {'$in': ['n0', 'n1', 'n2', 'n3', 'n4']}})
+        # first notification should be sent direct, as its key values are
+        # unique
         notifications[0].send_direct.assert_called_once_with(u0)
-        # next two notifications should be sent as a digest as they have matching key values
-        mocked_notification.send_digest.assert_called_once_with(u0, 'f2', 's2', [notifications[1], notifications[2]], 'rt2')
-        # final two should be sent direct even though they matching keys, as they are messages
+        # next two notifications should be sent as a digest as they have
+        # matching key values
+        mocked_notification.send_digest.assert_called_once_with(
+            u0, 'f2', 's2', [notifications[1], notifications[2]], 'rt2')
+        # final two should be sent direct even though they matching keys, as
+        # they are messages
         notifications[3].send_direct.assert_called_once_with(u0)
         notifications[4].send_direct.assert_called_once_with(u0)
 
@@ -433,21 +456,25 @@ class TestSubscriptionTypes(unittest.TestCase):
         user = M.User.by_username('test-admin')
         user.disabled = True
         ThreadLocalORMSession.flush_all()
-        M.Notification.send_digest(user._id, 'test@mail.com', 'subject', [notification])
+        M.Notification.send_digest(
+            user._id, 'test@mail.com', 'subject', [notification])
         count = M.MonQTask.query.find(dict(
             task_name='allura.tasks.mail_tasks.sendmail',
             state='ready')).count()
         assert_equal(count, 0)
         user.disabled = False
         ThreadLocalORMSession.flush_all()
-        M.Notification.send_digest(user._id, 'test@mail.com', 'subject', [notification])
+        M.Notification.send_digest(
+            user._id, 'test@mail.com', 'subject', [notification])
         count = M.MonQTask.query.find(dict(
             task_name='allura.tasks.mail_tasks.sendmail',
             state='ready')).count()
         assert_equal(count, 1)
 
+
 def _clear_subscriptions():
         M.Mailbox.query.remove({})
 
+
 def _clear_notifications():
         M.Notification.query.remove({})

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/Allura/allura/tests/model/test_openid.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_openid.py b/Allura/allura/tests/model/test_openid.py
index 48abe62..056f030 100644
--- a/Allura/allura/tests/model/test_openid.py
+++ b/Allura/allura/tests/model/test_openid.py
@@ -34,6 +34,7 @@ from allura.lib.app_globals import Globals
 from allura import model as M
 from allura.lib import helpers as h
 
+
 def setUp():
     g._push_object(Globals())
     c._push_object(mock.Mock())
@@ -44,14 +45,15 @@ def setUp():
     M.OpenIdAssociation.query.remove({})
     #conn = M.main_doc_session.bind.conn
 
+
 def test_oid_model():
     oid = M.OpenIdAssociation(_id='http://example.com')
     assoc = mock.Mock()
     assoc.handle = 'foo'
-    assoc.serialize = lambda:'bar'
-    assoc.getExpiresIn = lambda:0
+    assoc.serialize = lambda: 'bar'
+    assoc.getExpiresIn = lambda: 0
     with h.push_config(Association,
-                       deserialize=staticmethod(lambda v:assoc)):
+                       deserialize=staticmethod(lambda v: assoc)):
         oid.set_assoc(assoc)
         assert assoc == oid.get_assoc('foo')
         oid.set_assoc(assoc)
@@ -62,14 +64,15 @@ def test_oid_model():
         oid.cleanup_assocs()
         assert oid.get_assoc('foo') is None
 
+
 def test_oid_store():
     assoc = mock.Mock()
     assoc.handle = 'foo'
-    assoc.serialize = lambda:'bar'
-    assoc.getExpiresIn = lambda:0
+    assoc.serialize = lambda: 'bar'
+    assoc.getExpiresIn = lambda: 0
     store = M.OpenIdStore()
     with h.push_config(Association,
-                       deserialize=staticmethod(lambda v:assoc)):
+                       deserialize=staticmethod(lambda v: assoc)):
         store.storeAssociation('http://example.com', assoc)
         assert assoc == store.getAssociation('http://example.com', 'foo')
         assert assoc == store.getAssociation('http://example.com')
@@ -78,6 +81,6 @@ def test_oid_store():
         assert store.useNonce('http://www.example.com', t0, 'abcd')
         ThreadLocalORMSession.flush_all()
         assert not store.useNonce('http://www.example.com', t0, 'abcd')
-        assert not store.useNonce('http://www.example.com', t0-1e9, 'abcd')
+        assert not store.useNonce('http://www.example.com', t0 - 1e9, 'abcd')
         assert store.getAssociation('http://example.com') is None
         store.cleanupNonces()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/Allura/allura/tests/model/test_project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_project.py b/Allura/allura/tests/model/test_project.py
index 1005ba8..855432a 100644
--- a/Allura/allura/tests/model/test_project.py
+++ b/Allura/allura/tests/model/test_project.py
@@ -36,10 +36,12 @@ def setUp():
     setup_basic_test()
     setup_with_tools()
 
+
 @td.with_wiki
 def setup_with_tools():
     setup_global_objects()
 
+
 def test_project():
     assert_equals(type(c.project.sidebar_menu()), list)
     assert_in(c.project.script_name, c.project.url())
@@ -51,8 +53,10 @@ def test_project():
     assert_in(old_proj, list(c.project.parent_iter()))
     h.set_context('test', 'wiki', neighborhood='Projects')
     adobe_nbhd = M.Neighborhood.query.get(name='Adobe')
-    p = M.Project.query.get(shortname='adobe-1', neighborhood_id=adobe_nbhd._id)
-    # assert 'http' in p.url() # We moved adobe into /adobe/, not http://adobe....
+    p = M.Project.query.get(
+        shortname='adobe-1', neighborhood_id=adobe_nbhd._id)
+    # assert 'http' in p.url() # We moved adobe into /adobe/, not
+    # http://adobe....
     assert_in(p.script_name, p.url())
     assert_equals(c.project.shortname, 'test')
     assert_in('<p>', c.project.description_html)
@@ -90,11 +94,13 @@ def test_project():
     c.project.breadcrumbs()
     c.app.config.breadcrumbs()
 
+
 def test_subproject():
     project = M.Project.query.get(shortname='test')
     with td.raises(ToolError):
         with patch('allura.lib.plugin.ProjectRegistrationProvider') as Provider:
-            Provider.get().shortname_validator.to_python.side_effect = Invalid('name', 'value', {})
+            Provider.get().shortname_validator.to_python.side_effect = Invalid(
+                'name', 'value', {})
             # name doesn't validate
             sp = project.new_subproject('test-proj-nose')
     sp = project.new_subproject('test-proj-nose')
@@ -103,6 +109,7 @@ def test_subproject():
     sp.delete()
     ThreadLocalORMSession.flush_all()
 
+
 @td.with_wiki
 def test_anchored_tools():
     c.project.neighborhood.anchored_tools = 'wiki:Wiki, tickets:Ticket'
@@ -119,6 +126,7 @@ def test_set_ordinal_to_admin_tool():
         sm = c.project.sitemap()
         assert_equals(sm[-1].tool_name, 'admin')
 
+
 def test_users_and_roles():
     p = M.Project.query.get(shortname='test')
     sub = p.direct_subprojects[0]
@@ -127,6 +135,7 @@ def test_users_and_roles():
     assert p.users_with_role('Admin') == sub.users_with_role('Admin')
     assert p.users_with_role('Admin') == p.admins()
 
+
 def test_project_disabled_users():
     p = M.Project.query.get(shortname='test')
     users = p.users()
@@ -136,5 +145,3 @@ def test_project_disabled_users():
     ThreadLocalORMSession.flush_all()
     users = p.users()
     assert users == []
-
-

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/Allura/allura/tests/model/test_repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_repo.py b/Allura/allura/tests/model/test_repo.py
index f0bf936..24ab25d 100644
--- a/Allura/allura/tests/model/test_repo.py
+++ b/Allura/allura/tests/model/test_repo.py
@@ -30,6 +30,7 @@ from alluratest.controller import setup_basic_test, setup_global_objects
 from allura import model as M
 from allura.lib import helpers as h
 
+
 class TestGitLikeTree(object):
 
     def test_set_blob(self):
@@ -38,7 +39,8 @@ class TestGitLikeTree(object):
 
         assert_equal(tree.blobs, {})
         assert_equal(tree.get_tree('dir').blobs, {})
-        assert_equal(tree.get_tree('dir').get_tree('dir2').blobs, {'file': 'file-oid'})
+        assert_equal(tree.get_tree('dir').get_tree('dir2')
+                     .blobs, {'file': 'file-oid'})
 
     def test_hex(self):
         tree = M.GitLikeTree()
@@ -46,8 +48,10 @@ class TestGitLikeTree(object):
         hex = tree.hex()
 
         # check the reprs. In case hex (below) fails, this'll be useful
-        assert_equal(repr(tree.get_tree('dir').get_tree('dir2')), 'b file-oid file')
-        assert_equal(repr(tree), 't 96af1772ecce1e6044e6925e595d9373ffcd2615 dir')
+        assert_equal(repr(tree.get_tree('dir').get_tree('dir2')),
+                     'b file-oid file')
+        assert_equal(repr(tree),
+                     't 96af1772ecce1e6044e6925e595d9373ffcd2615 dir')
         # the hex() value shouldn't change, it's an important key
         assert_equal(hex, '4abba29a43411b9b7cecc1a74f0b27920554350d')
 
@@ -96,6 +100,7 @@ class RepoImplTestBase(object):
 
 
 class RepoTestBase(unittest.TestCase):
+
     def setUp(self):
         setup_basic_test()
 
@@ -126,10 +131,12 @@ class RepoTestBase(unittest.TestCase):
 
 
 class TestLastCommit(unittest.TestCase):
+
     def setUp(self):
         setup_basic_test()
         setup_global_objects()
-        self.repo = mock.Mock('repo', _commits=OrderedDict(), _last_commit=None)
+        self.repo = mock.Mock(
+            'repo', _commits=OrderedDict(), _last_commit=None)
         self.repo.shorthand_for_commit = lambda _id: _id[:6]
         self.repo.rev_to_commit_id = lambda rev: rev
         self.repo.log = self._log
@@ -145,44 +152,47 @@ class TestLastCommit(unittest.TestCase):
         tree_nodes = []
         blob_nodes = []
         sub_paths = defaultdict(list)
+
         def n(p):
             m = mock.Mock()
             m.name = p
             return m
         for p in tree_paths:
             if '/' in p:
-                node, sub = p.split('/',1)
+                node, sub = p.split('/', 1)
                 if node not in sub_paths:
                     tree_nodes.append(n(node))
                 sub_paths[node].append(sub)
             else:
                 blob_nodes.append(n(p))
         tree = mock.Mock(
-                commit=commit,
-                path=mock.Mock(return_value=path),
-                tree_ids=tree_nodes,
-                blob_ids=blob_nodes,
-                other_ids=[],
-                repo=self.repo,
-            )
-        tree.get_obj_by_path = lambda p: self._build_tree(commit, p, sub_paths[p])
-        tree.__getitem__ = lambda s, p: self._build_tree(commit, p, sub_paths[p])
+            commit=commit,
+            path=mock.Mock(return_value=path),
+            tree_ids=tree_nodes,
+            blob_ids=blob_nodes,
+            other_ids=[],
+            repo=self.repo,
+        )
+        tree.get_obj_by_path = lambda p: self._build_tree(
+            commit, p, sub_paths[p])
+        tree.__getitem__ = lambda s, p: self._build_tree(
+            commit, p, sub_paths[p])
         return tree
 
     def _add_commit(self, msg, tree_paths, diff_paths=None, parents=[]):
         suser = dict(
-                name='test',
-                email='test@example.com',
-                date=datetime(2013, 1, 1 + len(self.repo._commits)),
-            )
+            name='test',
+            email='test@example.com',
+            date=datetime(2013, 1, 1 + len(self.repo._commits)),
+        )
         commit = M.repo.Commit(
-                _id=str(ObjectId()),
-                message=msg,
-                parent_ids=[parent._id for parent in parents],
-                commited=suser,
-                authored=suser,
-                repo=self.repo,
-            )
+            _id=str(ObjectId()),
+            message=msg,
+            parent_ids=[parent._id for parent in parents],
+            commited=suser,
+            authored=suser,
+            repo=self.repo,
+        )
         commit.tree = self._build_tree(commit, '/', tree_paths)
         commit.get_tree = lambda c: commit.tree
         self._changes[commit._id].extend(diff_paths or tree_paths)
@@ -197,11 +207,12 @@ class TestLastCommit(unittest.TestCase):
 
     def test_single_commit(self):
         commit1 = self._add_commit('Commit 1', [
-                'file1',
-                'dir1/file2',
-            ])
+            'file1',
+            'dir1/file2',
+        ])
         lcd = M.repo.LastCommit.get(commit1.tree)
-        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit1.message)
+        self.assertEqual(
+            self.repo._commits[lcd.commit_id].message, commit1.message)
         self.assertEqual(lcd.path, '')
         self.assertEqual(len(lcd.entries), 2)
         self.assertEqual(lcd.by_name['file1'], commit1._id)
@@ -209,10 +220,13 @@ class TestLastCommit(unittest.TestCase):
 
     def test_multiple_commits_no_overlap(self):
         commit1 = self._add_commit('Commit 1', ['file1'])
-        commit2 = self._add_commit('Commit 2', ['file1', 'dir1/file1'], ['dir1/file1'], [commit1])
-        commit3 = self._add_commit('Commit 3', ['file1', 'dir1/file1', 'file2'], ['file2'], [commit2])
+        commit2 = self._add_commit(
+            'Commit 2', ['file1', 'dir1/file1'], ['dir1/file1'], [commit1])
+        commit3 = self._add_commit(
+            'Commit 3', ['file1', 'dir1/file1', 'file2'], ['file2'], [commit2])
         lcd = M.repo.LastCommit.get(commit3.tree)
-        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit3.message)
+        self.assertEqual(
+            self.repo._commits[lcd.commit_id].message, commit3.message)
         self.assertEqual(lcd.commit_id, commit3._id)
         self.assertEqual(lcd.path, '')
         self.assertEqual(len(lcd.entries), 3)
@@ -222,10 +236,13 @@ class TestLastCommit(unittest.TestCase):
 
     def test_multiple_commits_with_overlap(self):
         commit1 = self._add_commit('Commit 1', ['file1'])
-        commit2 = self._add_commit('Commit 2', ['file1', 'dir1/file1'], ['dir1/file1'], [commit1])
-        commit3 = self._add_commit('Commit 3', ['file1', 'dir1/file1', 'file2'], ['file1', 'file2'], [commit2])
+        commit2 = self._add_commit(
+            'Commit 2', ['file1', 'dir1/file1'], ['dir1/file1'], [commit1])
+        commit3 = self._add_commit(
+            'Commit 3', ['file1', 'dir1/file1', 'file2'], ['file1', 'file2'], [commit2])
         lcd = M.repo.LastCommit.get(commit3.tree)
-        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit3.message)
+        self.assertEqual(
+            self.repo._commits[lcd.commit_id].message, commit3.message)
         self.assertEqual(lcd.path, '')
         self.assertEqual(len(lcd.entries), 3)
         self.assertEqual(lcd.by_name['file1'], commit3._id)
@@ -234,10 +251,13 @@ class TestLastCommit(unittest.TestCase):
 
     def test_multiple_commits_subdir_change(self):
         commit1 = self._add_commit('Commit 1', ['file1', 'dir1/file1'])
-        commit2 = self._add_commit('Commit 2', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file2'], [commit1])
-        commit3 = self._add_commit('Commit 3', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file1'], [commit2])
+        commit2 = self._add_commit(
+            'Commit 2', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file2'], [commit1])
+        commit3 = self._add_commit(
+            'Commit 3', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file1'], [commit2])
         lcd = M.repo.LastCommit.get(commit3.tree)
-        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit3.message)
+        self.assertEqual(
+            self.repo._commits[lcd.commit_id].message, commit3.message)
         self.assertEqual(lcd.path, '')
         self.assertEqual(len(lcd.entries), 2)
         self.assertEqual(lcd.by_name['file1'], commit1._id)
@@ -245,11 +265,14 @@ class TestLastCommit(unittest.TestCase):
 
     def test_subdir_lcd(self):
         commit1 = self._add_commit('Commit 1', ['file1', 'dir1/file1'])
-        commit2 = self._add_commit('Commit 2', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file2'], [commit1])
-        commit3 = self._add_commit('Commit 3', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file1'], [commit2])
+        commit2 = self._add_commit(
+            'Commit 2', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file2'], [commit1])
+        commit3 = self._add_commit(
+            'Commit 3', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file1'], [commit2])
         tree = self._build_tree(commit3, '/dir1', ['file1', 'file2'])
         lcd = M.repo.LastCommit.get(tree)
-        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit3.message)
+        self.assertEqual(
+            self.repo._commits[lcd.commit_id].message, commit3.message)
         self.assertEqual(lcd.path, 'dir1')
         self.assertEqual(len(lcd.entries), 2)
         self.assertEqual(lcd.by_name['file1'], commit3._id)
@@ -257,12 +280,16 @@ class TestLastCommit(unittest.TestCase):
 
     def test_subdir_lcd_prev_commit(self):
         commit1 = self._add_commit('Commit 1', ['file1', 'dir1/file1'])
-        commit2 = self._add_commit('Commit 2', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file2'], [commit1])
-        commit3 = self._add_commit('Commit 3', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file1'], [commit2])
-        commit4 = self._add_commit('Commit 4', ['file1', 'dir1/file1', 'dir1/file2', 'file2'], ['file2'], [commit3])
+        commit2 = self._add_commit(
+            'Commit 2', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file2'], [commit1])
+        commit3 = self._add_commit(
+            'Commit 3', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file1'], [commit2])
+        commit4 = self._add_commit(
+            'Commit 4', ['file1', 'dir1/file1', 'dir1/file2', 'file2'], ['file2'], [commit3])
         tree = self._build_tree(commit4, '/dir1', ['file1', 'file2'])
         lcd = M.repo.LastCommit.get(tree)
-        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit3.message)
+        self.assertEqual(
+            self.repo._commits[lcd.commit_id].message, commit3.message)
         self.assertEqual(lcd.path, 'dir1')
         self.assertEqual(len(lcd.entries), 2)
         self.assertEqual(lcd.by_name['file1'], commit3._id)
@@ -270,69 +297,80 @@ class TestLastCommit(unittest.TestCase):
 
     def test_subdir_lcd_always_empty(self):
         commit1 = self._add_commit('Commit 1', ['file1', 'dir1'])
-        commit2 = self._add_commit('Commit 2', ['file1', 'file2'], ['file2'], [commit1])
+        commit2 = self._add_commit(
+            'Commit 2', ['file1', 'file2'], ['file2'], [commit1])
         tree = self._build_tree(commit2, '/dir1', [])
         lcd = M.repo.LastCommit.get(tree)
-        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit1.message)
+        self.assertEqual(
+            self.repo._commits[lcd.commit_id].message, commit1.message)
         self.assertEqual(lcd.path, 'dir1')
         self.assertEqual(lcd.entries, [])
 
     def test_subdir_lcd_emptied(self):
         commit1 = self._add_commit('Commit 1', ['file1', 'dir1/file1'])
-        commit2 = self._add_commit('Commit 2', ['file1'], ['dir1/file1'], [commit1])
+        commit2 = self._add_commit(
+            'Commit 2', ['file1'], ['dir1/file1'], [commit1])
         tree = self._build_tree(commit2, '/dir1', [])
         lcd = M.repo.LastCommit.get(tree)
-        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit2.message)
+        self.assertEqual(
+            self.repo._commits[lcd.commit_id].message, commit2.message)
         self.assertEqual(lcd.path, 'dir1')
         self.assertEqual(lcd.entries, [])
 
     def test_existing_lcd_unchained(self):
         commit1 = self._add_commit('Commit 1', ['file1', 'dir1/file1'])
-        commit2 = self._add_commit('Commit 2', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file2'], [commit1])
-        commit3 = self._add_commit('Commit 3', ['file1', 'dir1/file1', 'dir1/file2'], ['file1'], [commit2])
+        commit2 = self._add_commit(
+            'Commit 2', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file2'], [commit1])
+        commit3 = self._add_commit(
+            'Commit 3', ['file1', 'dir1/file1', 'dir1/file2'], ['file1'], [commit2])
         prev_lcd = M.repo.LastCommit(
-                path='dir1',
-                commit_id=commit2._id,
-                entries=[
-                    dict(
-                        name='file1',
-                        commit_id=commit1._id),
-                    dict(
-                        name='file2',
-                        commit_id=commit2._id),
-                ],
-            )
+            path='dir1',
+            commit_id=commit2._id,
+            entries=[
+                dict(
+                    name='file1',
+                    commit_id=commit1._id),
+                dict(
+                    name='file2',
+                    commit_id=commit2._id),
+            ],
+        )
         session(prev_lcd).flush()
         tree = self._build_tree(commit3, '/dir1', ['file1', 'file2'])
         lcd = M.repo.LastCommit.get(tree)
         self.assertEqual(lcd._id, prev_lcd._id)
-        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit2.message)
+        self.assertEqual(
+            self.repo._commits[lcd.commit_id].message, commit2.message)
         self.assertEqual(lcd.path, 'dir1')
         self.assertEqual(lcd.entries, prev_lcd.entries)
 
     def test_existing_lcd_partial(self):
         commit1 = self._add_commit('Commit 1', ['file1'])
-        commit2 = self._add_commit('Commit 2', ['file1', 'file2'], ['file2'], [commit1])
-        commit3 = self._add_commit('Commit 3', ['file1', 'file2', 'file3'], ['file3'], [commit2])
-        commit4 = self._add_commit('Commit 4', ['file1', 'file2', 'file3', 'file4'], ['file2', 'file4'], [commit3])
+        commit2 = self._add_commit(
+            'Commit 2', ['file1', 'file2'], ['file2'], [commit1])
+        commit3 = self._add_commit(
+            'Commit 3', ['file1', 'file2', 'file3'], ['file3'], [commit2])
+        commit4 = self._add_commit(
+            'Commit 4', ['file1', 'file2', 'file3', 'file4'], ['file2', 'file4'], [commit3])
         prev_lcd = M.repo.LastCommit(
-                path='',
-                commit_id=commit3._id,
-                entries=[
-                    dict(
-                        name='file1',
-                        commit_id=commit1._id),
-                    dict(
-                        name='file2',
-                        commit_id=commit2._id),
-                    dict(
-                        name='file3',
-                        commit_id=commit3._id),
-                ],
-            )
+            path='',
+            commit_id=commit3._id,
+            entries=[
+                dict(
+                    name='file1',
+                    commit_id=commit1._id),
+                dict(
+                    name='file2',
+                    commit_id=commit2._id),
+                dict(
+                    name='file3',
+                    commit_id=commit3._id),
+            ],
+        )
         session(prev_lcd).flush()
         lcd = M.repo.LastCommit.get(commit4.tree)
-        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit4.message)
+        self.assertEqual(
+            self.repo._commits[lcd.commit_id].message, commit4.message)
         self.assertEqual(lcd.path, '')
         self.assertEqual(len(lcd.entries), 4)
         self.assertEqual(lcd.by_name['file1'], commit1._id)
@@ -355,11 +393,14 @@ class TestLastCommit(unittest.TestCase):
 
     def test_timeout(self):
         commit1 = self._add_commit('Commit 1', ['file1'])
-        commit2 = self._add_commit('Commit 2', ['file1', 'dir1/file1'], ['dir1/file1'], [commit1])
-        commit3 = self._add_commit('Commit 3', ['file1', 'dir1/file1', 'file2'], ['file2'], [commit2])
+        commit2 = self._add_commit(
+            'Commit 2', ['file1', 'dir1/file1'], ['dir1/file1'], [commit1])
+        commit3 = self._add_commit(
+            'Commit 3', ['file1', 'dir1/file1', 'file2'], ['file2'], [commit2])
         with h.push_config(config, lcd_timeout=-1000):
             lcd = M.repo.LastCommit.get(commit3.tree)
-        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit3.message)
+        self.assertEqual(
+            self.repo._commits[lcd.commit_id].message, commit3.message)
         self.assertEqual(lcd.commit_id, commit3._id)
         self.assertEqual(lcd.path, '')
         self.assertEqual(len(lcd.entries), 1)
@@ -367,12 +408,15 @@ class TestLastCommit(unittest.TestCase):
 
     def test_loop(self):
         commit1 = self._add_commit('Commit 1', ['file1'])
-        commit2 = self._add_commit('Commit 2', ['file1', 'dir1/file1'], ['dir1/file1'], [commit1])
-        commit3 = self._add_commit('Commit 3', ['file1', 'dir1/file1', 'file2'], ['file2'], [commit2])
+        commit2 = self._add_commit(
+            'Commit 2', ['file1', 'dir1/file1'], ['dir1/file1'], [commit1])
+        commit3 = self._add_commit(
+            'Commit 3', ['file1', 'dir1/file1', 'file2'], ['file2'], [commit2])
         commit2.parent_ids = [commit3._id]
         session(commit2).flush(commit2)
         lcd = M.repo.LastCommit.get(commit3.tree)
-        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit3.message)
+        self.assertEqual(
+            self.repo._commits[lcd.commit_id].message, commit3.message)
         self.assertEqual(lcd.commit_id, commit3._id)
         self.assertEqual(lcd.path, '')
         self.assertEqual(len(lcd.entries), 3)
@@ -381,11 +425,13 @@ class TestLastCommit(unittest.TestCase):
 
 
 class TestModelCache(unittest.TestCase):
+
     def setUp(self):
         self.cache = M.repo.ModelCache()
 
     def test_normalize_query(self):
-        self.assertEqual(self.cache._normalize_query({'foo': 1, 'bar': 2}), (('bar', 2), ('foo', 1)))
+        self.assertEqual(self.cache._normalize_query(
+            {'foo': 1, 'bar': 2}), (('bar', 2), ('foo', 1)))
 
     def test_model_query(self):
         q = mock.Mock(spec_set=['query'], query='foo')
@@ -398,8 +444,10 @@ class TestModelCache(unittest.TestCase):
     @mock.patch.object(M.repo.Tree.query, 'get')
     @mock.patch.object(M.repo.LastCommit.query, 'get')
     def test_get(self, lc_get, tr_get):
-        tree = tr_get.return_value = mock.Mock(spec=['_id', 'val'], _id='foo', val='bar')
-        lcd = lc_get.return_value = mock.Mock(spec=['_id', 'val'], _id='foo', val='qux')
+        tree = tr_get.return_value = mock.Mock(
+            spec=['_id', 'val'], _id='foo', val='bar')
+        lcd = lc_get.return_value = mock.Mock(
+            spec=['_id', 'val'], _id='foo', val='qux')
 
         val = self.cache.get(M.repo.Tree, {'_id': 'foo'})
         tr_get.assert_called_with(_id='foo')
@@ -411,7 +459,8 @@ class TestModelCache(unittest.TestCase):
 
     @mock.patch.object(M.repo.Tree.query, 'get')
     def test_get_no_query(self, tr_get):
-        tree1 = tr_get.return_value = mock.Mock(spec=['_id', 'val'], _id='foo', val='bar')
+        tree1 = tr_get.return_value = mock.Mock(
+            spec=['_id', 'val'], _id='foo', val='bar')
         val = self.cache.get(M.repo.Tree, {'_id': 'foo'})
         tr_get.assert_called_once_with(_id='foo')
         self.assertEqual(val, tree1)
@@ -423,7 +472,8 @@ class TestModelCache(unittest.TestCase):
 
     @mock.patch.object(M.repo.TreesDoc.m, 'get')
     def test_get_doc(self, tr_get):
-        trees = tr_get.return_value = mock.Mock(spec=['_id', 'val'], _id='foo', val='bar')
+        trees = tr_get.return_value = mock.Mock(
+            spec=['_id', 'val'], _id='foo', val='bar')
         val = self.cache.get(M.repo.TreesDoc, {'_id': 'foo'})
         tr_get.assert_called_once_with(_id='foo')
         self.assertEqual(val, trees)
@@ -431,8 +481,10 @@ class TestModelCache(unittest.TestCase):
     def test_set(self):
         tree = mock.Mock(spec=['_id', 'test_set'], _id='foo', val='test_set')
         self.cache.set(M.repo.Tree, {'val': 'test_set'}, tree)
-        self.assertEqual(self.cache._query_cache, {M.repo.Tree: {(('val', 'test_set'),): 'foo'}})
-        self.assertEqual(self.cache._instance_cache, {M.repo.Tree: {'foo': tree}})
+        self.assertEqual(self.cache._query_cache,
+                         {M.repo.Tree: {(('val', 'test_set'),): 'foo'}})
+        self.assertEqual(self.cache._instance_cache,
+                         {M.repo.Tree: {'foo': tree}})
 
     @mock.patch('bson.ObjectId')
     def test_set_none_id(self, obj_id):
@@ -441,16 +493,21 @@ class TestModelCache(unittest.TestCase):
         self.cache.set(M.repo.Tree, {'val1': 'test_set1'}, tree)
         self.cache.set(M.repo.Tree, {'val2': 'test_set2'}, tree)
         self.assertEqual(dict(self.cache._query_cache[M.repo.Tree]), {
-                (('val1', 'test_set1'),): 'OBJID',
-                (('val2', 'test_set2'),): 'OBJID',
-            })
-        self.assertEqual(self.cache._instance_cache, {M.repo.Tree: {'OBJID': tree}})
+            (('val1', 'test_set1'),): 'OBJID',
+            (('val2', 'test_set2'),): 'OBJID',
+        })
+        self.assertEqual(self.cache._instance_cache,
+                         {M.repo.Tree: {'OBJID': tree}})
         tree._id = '_id'
-        self.assertEqual(self.cache.get(M.repo.Tree, {'val1': 'test_set1'}), tree)
-        self.assertEqual(self.cache.get(M.repo.Tree, {'val2': 'test_set2'}), tree)
+        self.assertEqual(
+            self.cache.get(M.repo.Tree, {'val1': 'test_set1'}), tree)
+        self.assertEqual(
+            self.cache.get(M.repo.Tree, {'val2': 'test_set2'}), tree)
         self.cache.set(M.repo.Tree, {'val1': 'test_set2'}, tree)
-        self.assertEqual(self.cache.get(M.repo.Tree, {'val1': 'test_set1'}), tree)
-        self.assertEqual(self.cache.get(M.repo.Tree, {'val2': 'test_set2'}), tree)
+        self.assertEqual(
+            self.cache.get(M.repo.Tree, {'val1': 'test_set1'}), tree)
+        self.assertEqual(
+            self.cache.get(M.repo.Tree, {'val2': 'test_set2'}), tree)
 
     @mock.patch('bson.ObjectId')
     def test_set_none_val(self, obj_id):
@@ -458,29 +515,31 @@ class TestModelCache(unittest.TestCase):
         self.cache.set(M.repo.Tree, {'val1': 'test_set1'}, None)
         self.cache.set(M.repo.Tree, {'val2': 'test_set2'}, None)
         self.assertEqual(dict(self.cache._query_cache[M.repo.Tree]), {
-                (('val1', 'test_set1'),): None,
-                (('val2', 'test_set2'),): None,
-            })
+            (('val1', 'test_set1'),): None,
+            (('val2', 'test_set2'),): None,
+        })
         self.assertEqual(dict(self.cache._instance_cache[M.repo.Tree]), {})
         tree1 = mock.Mock(spec=['_id', 'val'], _id='tree1', val='test_set')
-        tree2 = mock.Mock(spec=['_model_cache_id', '_id', 'val'], _model_cache_id='tree2', _id='tree1', val='test_set2')
+        tree2 = mock.Mock(spec=['_model_cache_id', '_id', 'val'],
+                          _model_cache_id='tree2', _id='tree1', val='test_set2')
         self.cache.set(M.repo.Tree, {'val1': 'test_set1'}, tree1)
         self.cache.set(M.repo.Tree, {'val2': 'test_set2'}, tree2)
         self.assertEqual(dict(self.cache._query_cache[M.repo.Tree]), {
-                (('val1', 'test_set1'),): 'tree1',
-                (('val2', 'test_set2'),): 'tree2',
-            })
+            (('val1', 'test_set1'),): 'tree1',
+            (('val2', 'test_set2'),): 'tree2',
+        })
         self.assertEqual(dict(self.cache._instance_cache[M.repo.Tree]), {
-                'tree1': tree1,
-                'tree2': tree2,
-            })
+            'tree1': tree1,
+            'tree2': tree2,
+        })
 
     def test_instance_ids(self):
         tree1 = mock.Mock(spec=['_id', 'val'], _id='id1', val='tree1')
         tree2 = mock.Mock(spec=['_id', 'val'], _id='id2', val='tree2')
         self.cache.set(M.repo.Tree, {'val': 'tree1'}, tree1)
         self.cache.set(M.repo.Tree, {'val': 'tree2'}, tree2)
-        self.assertEqual(set(self.cache.instance_ids(M.repo.Tree)), set(['id1', 'id2']))
+        self.assertEqual(set(self.cache.instance_ids(M.repo.Tree)),
+                         set(['id1', 'id2']))
         self.assertEqual(self.cache.instance_ids(M.repo.LastCommit), [])
 
     @mock.patch.object(M.repo.Tree.query, 'find')
@@ -493,13 +552,13 @@ class TestModelCache(unittest.TestCase):
         self.cache.batch_load(M.repo.Tree, {'foo': {'$in': 'bar'}})
         tr_find.assert_called_with({'foo': {'$in': 'bar'}})
         self.assertEqual(self.cache._query_cache[M.repo.Tree], {
-                (('foo', 1),): 'id1',
-                (('foo', 2),): 'id2',
-            })
+            (('foo', 1),): 'id1',
+            (('foo', 2),): 'id2',
+        })
         self.assertEqual(self.cache._instance_cache[M.repo.Tree], {
-                'id1': m1,
-                'id2': m2,
-            })
+            'id1': m1,
+            'id2': m2,
+        })
 
     @mock.patch.object(M.repo.Tree.query, 'find')
     def test_batch_load_attrs(self, tr_find):
@@ -511,13 +570,13 @@ class TestModelCache(unittest.TestCase):
         self.cache.batch_load(M.repo.Tree, {'foo': {'$in': 'bar'}}, ['qux'])
         tr_find.assert_called_with({'foo': {'$in': 'bar'}})
         self.assertEqual(self.cache._query_cache[M.repo.Tree], {
-                (('qux', 3),): 'id1',
-                (('qux', 5),): 'id2',
-            })
+            (('qux', 3),): 'id1',
+            (('qux', 5),): 'id2',
+        })
         self.assertEqual(self.cache._instance_cache[M.repo.Tree], {
-                'id1': m1,
-                'id2': m2,
-            })
+            'id1': m1,
+            'id2': m2,
+        })
 
     def test_pruning(self):
         cache = M.repo.ModelCache(max_queries=3, max_instances=2)
@@ -533,18 +592,18 @@ class TestModelCache(unittest.TestCase):
         cache.get(M.repo.Tree, {'_id': 'f00'})
         cache.set(M.repo.Tree, {'val': 'b4r'}, tree3)
         self.assertEqual(cache._query_cache, {
-                M.repo.Tree: {
-                    (('_id', 'foo'),): 'foo',
-                    (('_id', 'f00'),): 'f00',
-                    (('val', 'b4r'),): 'f00',
-                },
-            })
+            M.repo.Tree: {
+                (('_id', 'foo'),): 'foo',
+                (('_id', 'f00'),): 'f00',
+                (('val', 'b4r'),): 'f00',
+            },
+        })
         self.assertEqual(cache._instance_cache, {
-                M.repo.Tree: {
-                    'f00': tree3,
-                    'foo': tree4,
-                },
-            })
+            M.repo.Tree: {
+                'f00': tree3,
+                'foo': tree4,
+            },
+        })
 
     def test_pruning_query_vs_instance(self):
         cache = M.repo.ModelCache(max_queries=3, max_instances=2)
@@ -555,17 +614,19 @@ class TestModelCache(unittest.TestCase):
         tree4 = mock.Mock(spec=['_id', '_val'], _id='tree4', val='zaz')
         cache.set(M.repo.Tree, {'keep_query_1': 'bar'}, tree1)
         cache.set(M.repo.Tree, {'drop_query_1': 'bar'}, tree2)
-        cache.set(M.repo.Tree, {'keep_query_2': 'bar'}, tree1)  # should refresh tree1 in _instance_cache
-        cache.set(M.repo.Tree, {'drop_query_2': 'bar'}, tree3)  # should drop tree2, not tree1, from _instance_cache
+        # should refresh tree1 in _instance_cache
+        cache.set(M.repo.Tree, {'keep_query_2': 'bar'}, tree1)
+        # should drop tree2, not tree1, from _instance_cache
+        cache.set(M.repo.Tree, {'drop_query_2': 'bar'}, tree3)
         self.assertEqual(cache._query_cache[M.repo.Tree], {
-                (('drop_query_1', 'bar'),): 'tree2',
-                (('keep_query_2', 'bar'),): 'keep',
-                (('drop_query_2', 'bar'),): 'tree3',
-            })
+            (('drop_query_1', 'bar'),): 'tree2',
+            (('keep_query_2', 'bar'),): 'keep',
+            (('drop_query_2', 'bar'),): 'tree3',
+        })
         self.assertEqual(cache._instance_cache[M.repo.Tree], {
-                'keep': tree1,
-                'tree3': tree3,
-            })
+            'keep': tree1,
+            'tree3': tree3,
+        })
 
     @mock.patch('bson.ObjectId')
     def test_pruning_no_id(self, obj_id):
@@ -577,13 +638,13 @@ class TestModelCache(unittest.TestCase):
         cache.set(M.repo.Tree, {'query_2': 'bar'}, tree1)
         cache.set(M.repo.Tree, {'query_3': 'bar'}, tree1)
         self.assertEqual(cache._instance_cache[M.repo.Tree], {
-                'id1': tree1,
-            })
+            'id1': tree1,
+        })
         self.assertEqual(cache._query_cache[M.repo.Tree], {
-                (('query_1', 'bar'),): 'id1',
-                (('query_2', 'bar'),): 'id1',
-                (('query_3', 'bar'),): 'id1',
-            })
+            (('query_1', 'bar'),): 'id1',
+            (('query_2', 'bar'),): 'id1',
+            (('query_3', 'bar'),): 'id1',
+        })
 
     @mock.patch('bson.ObjectId')
     def test_pruning_none(self, obj_id):
@@ -595,18 +656,20 @@ class TestModelCache(unittest.TestCase):
         cache.set(M.repo.Tree, {'query_3': 'bar'}, None)
         self.assertEqual(cache._instance_cache[M.repo.Tree], {})
         self.assertEqual(cache._query_cache[M.repo.Tree], {
-                (('query_1', 'bar'),): None,
-                (('query_2', 'bar'),): None,
-                (('query_3', 'bar'),): None,
-            })
+            (('query_1', 'bar'),): None,
+            (('query_2', 'bar'),): None,
+            (('query_3', 'bar'),): None,
+        })
 
     @mock.patch('allura.model.repo.session')
     @mock.patch.object(M.repo.Tree.query, 'get')
     def test_pruning_query_flush(self, tr_get, session):
         cache = M.repo.ModelCache(max_queries=3, max_instances=2)
         # ensure cache doesn't store None instances
-        tree1 = mock.Mock(name='tree1', spec=['_id', '_val'], _id='tree1', val='bar')
-        tree2 = mock.Mock(name='tree2', spec=['_id', '_val'], _id='tree2', val='fuz')
+        tree1 = mock.Mock(name='tree1',
+                          spec=['_id', '_val'], _id='tree1', val='bar')
+        tree2 = mock.Mock(name='tree2',
+                          spec=['_id', '_val'], _id='tree2', val='fuz')
         tr_get.return_value = tree2
         cache.set(M.repo.Tree, {'_id': 'tree1'}, tree1)
         cache.set(M.repo.Tree, {'_id': 'tree2'}, tree2)
@@ -614,16 +677,18 @@ class TestModelCache(unittest.TestCase):
         cache.get(M.repo.Tree, {'query_2': 'tree2'})
         cache.get(M.repo.Tree, {'query_3': 'tree2'})
         self.assertEqual(cache._query_cache[M.repo.Tree], {
-                (('query_1', 'tree2'),): 'tree2',
-                (('query_2', 'tree2'),): 'tree2',
-                (('query_3', 'tree2'),): 'tree2',
-            })
+            (('query_1', 'tree2'),): 'tree2',
+            (('query_2', 'tree2'),): 'tree2',
+            (('query_3', 'tree2'),): 'tree2',
+        })
         self.assertEqual(cache._instance_cache[M.repo.Tree], {
-                'tree1': tree1,
-                'tree2': tree2,
-            })
-        self.assertEqual(session.call_args_list, [mock.call(tree1), mock.call(tree2)])
-        self.assertEqual(session.return_value.flush.call_args_list, [mock.call(tree1), mock.call(tree2)])
+            'tree1': tree1,
+            'tree2': tree2,
+        })
+        self.assertEqual(session.call_args_list,
+                         [mock.call(tree1), mock.call(tree2)])
+        self.assertEqual(session.return_value.flush.call_args_list,
+                         [mock.call(tree1), mock.call(tree2)])
         assert not session.return_value.expunge.called
 
     @mock.patch('allura.model.repo.session')
@@ -637,14 +702,14 @@ class TestModelCache(unittest.TestCase):
         cache.set(M.repo.Tree, {'_id': 'tree2'}, tree2)
         cache.set(M.repo.Tree, {'_id': 'tree3'}, tree3)
         self.assertEqual(cache._query_cache[M.repo.Tree], {
-                (('_id', 'tree1'),): 'tree1',
-                (('_id', 'tree2'),): 'tree2',
-                (('_id', 'tree3'),): 'tree3',
-            })
+            (('_id', 'tree1'),): 'tree1',
+            (('_id', 'tree2'),): 'tree2',
+            (('_id', 'tree3'),): 'tree3',
+        })
         self.assertEqual(cache._instance_cache[M.repo.Tree], {
-                'tree2': tree2,
-                'tree3': tree3,
-            })
+            'tree2': tree2,
+            'tree3': tree3,
+        })
         session.assert_called_once_with(tree1)
         session.return_value.flush.assert_called_once_with(tree1)
         session.return_value.expunge.assert_called_once_with(tree1)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/Allura/allura/tests/test_app.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_app.py b/Allura/allura/tests/test_app.py
index 30c85c0..9389238 100644
--- a/Allura/allura/tests/test_app.py
+++ b/Allura/allura/tests/test_app.py
@@ -26,6 +26,7 @@ from allura import app
 from allura.lib.app_globals import Globals
 from allura import model as M
 
+
 def setUp():
     g._push_object(Globals())
     c._push_object(mock.Mock())
@@ -39,14 +40,15 @@ def setUp():
     app_config._id = None
     app_config.project_id = 'testproject/'
     app_config.tool_name = 'tool'
-    app_config.options = Object(mount_point = 'foo')
+    app_config.options = Object(mount_point='foo')
     c.app = mock.Mock()
     c.app.config = app_config
-    c.app.config.script_name = lambda:'/testproject/test_application/'
-    c.app.config.url = lambda:'http://testproject/test_application/'
+    c.app.config.script_name = lambda: '/testproject/test_application/'
+    c.app.config.url = lambda: 'http://testproject/test_application/'
     c.app.url = c.app.config.url()
     c.app.__version__ = '0.0'
 
+
 def test_config_options():
     options = [
         app.ConfigOption('test1', str, 'MyTestValue'),
@@ -54,6 +56,7 @@ def test_config_options():
     assert options[0].default == 'MyTestValue'
     assert options[1].default == 'MyTestValue'
 
+
 def test_sitemap():
     sm = app.SitemapEntry('test', '')[
         app.SitemapEntry('a', 'a/'),
@@ -61,9 +64,9 @@ def test_sitemap():
     sm[app.SitemapEntry(lambda app:app.config.script_name(), 'c/')]
     bound_sm = sm.bind_app(c.app)
     assert bound_sm.url == 'http://testproject/test_application/', bound_sm.url
-    assert bound_sm.children[-1].label == '/testproject/test_application/', bound_sm.children[-1].label
+    assert bound_sm.children[
+        -1].label == '/testproject/test_application/', bound_sm.children[-1].label
     assert len(sm.children) == 3
     sm.extend([app.SitemapEntry('a', 'a/')[
-                app.SitemapEntry('d', 'd/')]])
+        app.SitemapEntry('d', 'd/')]])
     assert len(sm.children) == 3
-

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/Allura/allura/tests/test_commands.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_commands.py b/Allura/allura/tests/test_commands.py
index 5187d14..4dda1be 100644
--- a/Allura/allura/tests/test_commands.py
+++ b/Allura/allura/tests/test_commands.py
@@ -24,32 +24,40 @@ import pkg_resources
 
 from alluratest.controller import setup_basic_test, setup_global_objects
 from allura.command import base, script, set_neighborhood_features, \
-                           create_neighborhood, show_models, taskd_cleanup
+    create_neighborhood, show_models, taskd_cleanup
 from allura import model as M
 from forgeblog import model as BM
 from allura.lib.exceptions import InvalidNBFeatureValueError
 from allura.tests import decorators as td
 
-test_config = pkg_resources.resource_filename('allura', '../test.ini') + '#main'
+test_config = pkg_resources.resource_filename(
+    'allura', '../test.ini') + '#main'
 
 
-class EmptyClass(object): pass
+class EmptyClass(object):
+    pass
+
 
 def setUp(self):
     """Method called by nose before running each test"""
-    #setup_basic_test(app_name='main_with_amqp')
+    # setup_basic_test(app_name='main_with_amqp')
     setup_basic_test()
     setup_global_objects()
 
+
 def test_script():
     cmd = script.ScriptCommand('script')
-    cmd.run([test_config, pkg_resources.resource_filename('allura', 'tests/tscript.py') ])
-    assert_raises(ValueError, cmd.run, [test_config, pkg_resources.resource_filename('allura','tests/tscript_error.py') ])
+    cmd.run(
+        [test_config, pkg_resources.resource_filename('allura', 'tests/tscript.py')])
+    assert_raises(ValueError, cmd.run,
+                  [test_config, pkg_resources.resource_filename('allura', 'tests/tscript_error.py')])
+
 
 def test_set_neighborhood_max_projects():
     neighborhood = M.Neighborhood.query.find().first()
     n_id = neighborhood._id
-    cmd = set_neighborhood_features.SetNeighborhoodFeaturesCommand('setnbfeatures')
+    cmd = set_neighborhood_features.SetNeighborhoodFeaturesCommand(
+        'setnbfeatures')
 
     # a valid number
     cmd.run([test_config, str(n_id), 'max_projects', '50'])
@@ -62,13 +70,17 @@ def test_set_neighborhood_max_projects():
     assert neighborhood.features['max_projects'] == None
 
     # check validation
-    assert_raises(InvalidNBFeatureValueError, cmd.run, [test_config, str(n_id), 'max_projects', 'string'])
-    assert_raises(InvalidNBFeatureValueError, cmd.run, [test_config, str(n_id), 'max_projects', '2.8'])
+    assert_raises(InvalidNBFeatureValueError, cmd.run,
+                  [test_config, str(n_id), 'max_projects', 'string'])
+    assert_raises(InvalidNBFeatureValueError, cmd.run,
+                  [test_config, str(n_id), 'max_projects', '2.8'])
+
 
 def test_set_neighborhood_private():
     neighborhood = M.Neighborhood.query.find().first()
     n_id = neighborhood._id
-    cmd = set_neighborhood_features.SetNeighborhoodFeaturesCommand('setnbfeatures')
+    cmd = set_neighborhood_features.SetNeighborhoodFeaturesCommand(
+        'setnbfeatures')
 
     # allow private projects
     cmd.run([test_config, str(n_id), 'private_projects', 'True'])
@@ -81,14 +93,19 @@ def test_set_neighborhood_private():
     assert not neighborhood.features['private_projects']
 
     # check validation
-    assert_raises(InvalidNBFeatureValueError, cmd.run, [test_config, str(n_id), 'private_projects', 'string'])
-    assert_raises(InvalidNBFeatureValueError, cmd.run, [test_config, str(n_id), 'private_projects', '1'])
-    assert_raises(InvalidNBFeatureValueError, cmd.run, [test_config, str(n_id), 'private_projects', '2.8'])
+    assert_raises(InvalidNBFeatureValueError, cmd.run,
+                  [test_config, str(n_id), 'private_projects', 'string'])
+    assert_raises(InvalidNBFeatureValueError, cmd.run,
+                  [test_config, str(n_id), 'private_projects', '1'])
+    assert_raises(InvalidNBFeatureValueError, cmd.run,
+                  [test_config, str(n_id), 'private_projects', '2.8'])
+
 
 def test_set_neighborhood_google_analytics():
     neighborhood = M.Neighborhood.query.find().first()
     n_id = neighborhood._id
-    cmd = set_neighborhood_features.SetNeighborhoodFeaturesCommand('setnbfeatures')
+    cmd = set_neighborhood_features.SetNeighborhoodFeaturesCommand(
+        'setnbfeatures')
 
     # allow private projects
     cmd.run([test_config, str(n_id), 'google_analytics', 'True'])
@@ -101,14 +118,19 @@ def test_set_neighborhood_google_analytics():
     assert not neighborhood.features['google_analytics']
 
     # check validation
-    assert_raises(InvalidNBFeatureValueError, cmd.run, [test_config, str(n_id), 'google_analytics', 'string'])
-    assert_raises(InvalidNBFeatureValueError, cmd.run, [test_config, str(n_id), 'google_analytics', '1'])
-    assert_raises(InvalidNBFeatureValueError, cmd.run, [test_config, str(n_id), 'google_analytics', '2.8'])
+    assert_raises(InvalidNBFeatureValueError, cmd.run,
+                  [test_config, str(n_id), 'google_analytics', 'string'])
+    assert_raises(InvalidNBFeatureValueError, cmd.run,
+                  [test_config, str(n_id), 'google_analytics', '1'])
+    assert_raises(InvalidNBFeatureValueError, cmd.run,
+                  [test_config, str(n_id), 'google_analytics', '2.8'])
+
 
 def test_set_neighborhood_css():
     neighborhood = M.Neighborhood.query.find().first()
     n_id = neighborhood._id
-    cmd = set_neighborhood_features.SetNeighborhoodFeaturesCommand('setnbfeatures')
+    cmd = set_neighborhood_features.SetNeighborhoodFeaturesCommand(
+        'setnbfeatures')
 
     # none
     cmd.run([test_config, str(n_id), 'css', 'none'])
@@ -126,22 +148,30 @@ def test_set_neighborhood_css():
     assert neighborhood.features['css'] == 'custom'
 
     # check validation
-    assert_raises(InvalidNBFeatureValueError, cmd.run, [test_config, str(n_id), 'css', 'string'])
-    assert_raises(InvalidNBFeatureValueError, cmd.run, [test_config, str(n_id), 'css', '1'])
-    assert_raises(InvalidNBFeatureValueError, cmd.run, [test_config, str(n_id), 'css', '2.8'])
-    assert_raises(InvalidNBFeatureValueError, cmd.run, [test_config, str(n_id), 'css', 'None'])
-    assert_raises(InvalidNBFeatureValueError, cmd.run, [test_config, str(n_id), 'css', 'True'])
+    assert_raises(InvalidNBFeatureValueError, cmd.run,
+                  [test_config, str(n_id), 'css', 'string'])
+    assert_raises(InvalidNBFeatureValueError, cmd.run,
+                  [test_config, str(n_id), 'css', '1'])
+    assert_raises(InvalidNBFeatureValueError, cmd.run,
+                  [test_config, str(n_id), 'css', '2.8'])
+    assert_raises(InvalidNBFeatureValueError, cmd.run,
+                  [test_config, str(n_id), 'css', 'None'])
+    assert_raises(InvalidNBFeatureValueError, cmd.run,
+                  [test_config, str(n_id), 'css', 'True'])
+
 
 def test_update_neighborhood():
     cmd = create_neighborhood.UpdateNeighborhoodCommand('update-neighborhood')
     cmd.run([test_config, 'Projects', 'True'])
-    ThreadLocalORMSession.close_all() # make sure the app_configs get freshly queried
+    # make sure the app_configs get freshly queried
+    ThreadLocalORMSession.close_all()
     nb = M.Neighborhood.query.get(name='Projects')
     assert nb.has_home_tool == True
 
     cmd = create_neighborhood.UpdateNeighborhoodCommand('update-neighborhood')
     cmd.run([test_config, 'Projects', 'False'])
-    ThreadLocalORMSession.close_all() # make sure the app_configs get freshly queried
+    # make sure the app_configs get freshly queried
+    ThreadLocalORMSession.close_all()
     nb = M.Neighborhood.query.get(name='Projects')
     assert nb.has_home_tool == False
 
@@ -155,12 +185,12 @@ class TestEnsureIndexCommand(object):
     def test_update_indexes_order(self):
         collection = Mock(name='collection')
         collection.index_information.return_value = {
-                '_id_': {'key': '_id'},
-                '_foo_bar': {'key': [('foo', 1), ('bar', 1)]},
-                }
+            '_id_': {'key': '_id'},
+            '_foo_bar': {'key': [('foo', 1), ('bar', 1)]},
+        }
         indexes = [
-                Mock(unique=False, index_spec=[('foo', 1)]),
-                ]
+            Mock(unique=False, index_spec=[('foo', 1)]),
+        ]
         cmd = show_models.EnsureIndexCommand('ensure_index')
         cmd._update_indexes(collection, indexes)
 
@@ -168,39 +198,43 @@ class TestEnsureIndexCommand(object):
         for i, call in enumerate(collection.mock_calls):
             method_name = call[0]
             collection_call_order[method_name] = i
-        assert collection_call_order['ensure_index'] < collection_call_order['drop_index'], collection.mock_calls
+        assert collection_call_order['ensure_index'] < collection_call_order[
+            'drop_index'], collection.mock_calls
 
     def test_update_indexes_unique_changes(self):
         collection = Mock(name='collection')
         # expecting these ensure_index calls, we'll make their return values normal
         # for easier assertions later
-        collection.ensure_index.side_effect = ['_foo_bar_temporary_extra_field_for_indexing',
-                                               '_foo_bar',
-                                               '_foo_baz_temporary_extra_field_for_indexing',
-                                               '_foo_baz',
-                                               '_foo_baz',
-                                               '_foo_bar',
-                                               ]
+        collection.ensure_index.side_effect = [
+            '_foo_bar_temporary_extra_field_for_indexing',
+            '_foo_bar',
+            '_foo_baz_temporary_extra_field_for_indexing',
+            '_foo_baz',
+            '_foo_baz',
+            '_foo_bar',
+        ]
         collection.index_information.return_value = {
-                '_id_': {'key': '_id'},
-                '_foo_bar': {'key': [('foo', 1), ('bar', 1)], 'unique': True},
-                '_foo_baz': {'key': [('foo', 1), ('baz', 1)]},
-                }
+            '_id_': {'key': '_id'},
+            '_foo_bar': {'key': [('foo', 1), ('bar', 1)], 'unique': True},
+            '_foo_baz': {'key': [('foo', 1), ('baz', 1)]},
+        }
         indexes = [
-                Mock(index_spec=[('foo', 1), ('bar', 1)], unique=False, ),
-                Mock(index_spec=[('foo', 1), ('baz', 1)], unique=True, ),
-                ]
+            Mock(index_spec=[('foo', 1), ('bar', 1)], unique=False, ),
+            Mock(index_spec=[('foo', 1), ('baz', 1)], unique=True, ),
+        ]
 
         cmd = show_models.EnsureIndexCommand('ensure_index')
         cmd._update_indexes(collection, indexes)
 
         assert_equal(collection.mock_calls, [
             call.index_information(),
-            call.ensure_index([('foo', 1), ('bar', 1), ('temporary_extra_field_for_indexing', 1)]),
+            call.ensure_index(
+                [('foo', 1), ('bar', 1), ('temporary_extra_field_for_indexing', 1)]),
             call.drop_index('_foo_bar'),
             call.ensure_index([('foo', 1), ('bar', 1)], unique=False),
             call.drop_index('_foo_bar_temporary_extra_field_for_indexing'),
-            call.ensure_index([('foo', 1), ('baz', 1), ('temporary_extra_field_for_indexing', 1)]),
+            call.ensure_index(
+                [('foo', 1), ('baz', 1), ('temporary_extra_field_for_indexing', 1)]),
             call.drop_index('_foo_baz'),
             call.ensure_index([('foo', 1), ('baz', 1)], unique=True),
             call.drop_index('_foo_baz_temporary_extra_field_for_indexing'),
@@ -292,7 +326,8 @@ class TestTaskdCleanupCommand(object):
         assert task1.result == 'Forsaken task'
 
         # task1 seems lost, but it just moved quickly
-        task1 = Mock(state='complete', process='host pid 1111', result='', _id=1)
+        task1 = Mock(state='complete',
+                     process='host pid 1111', result='', _id=1)
         task2 = Mock(state='busy', process='host pid 1111', result='', _id=2)
         self.cmd_class._complete_suspicious_tasks = lambda x: [1]
         self.cmd_class._busy_tasks = lambda x: [task1, task2]
@@ -341,7 +376,8 @@ class TestBackgroundCommand(object):
     def test_run_command(self, command):
         command.__name__ = 'ReindexCommand'
         base.run_command(self.cmd, 'dev.ini -p "project 3"')
-        command(command.__name__).run.assert_called_with(['dev.ini', '-p', 'project 3'])
+        command(command.__name__).run.assert_called_with(
+            ['dev.ini', '-p', 'project 3'])
 
     def test_invalid_args(self):
         M.MonQTask.query.remove()
@@ -377,9 +413,11 @@ class TestReindexCommand(object):
             '-p', 'test', '--solr', '--solr-hosts=http://blah.com/solr/forge,https://other.net/solr/forge'])
         cmd._chunked_add_artifacts(list(range(10)))
         # check constructors of first and second Solr() instantiations
-        assert_equal(set([Solr.call_args_list[0][0][0], Solr.call_args_list[1][0][0]]),
-                     set(['http://blah.com/solr/forge', 'https://other.net/solr/forge'])
-                     )
+        assert_equal(
+            set([Solr.call_args_list[0][0][0], Solr.call_args_list[1][0][0]]),
+            set(['http://blah.com/solr/forge',
+                 'https://other.net/solr/forge'])
+        )
 
     @patch('allura.command.show_models.utils')
     def test_project_regex(self, utils):
@@ -391,12 +429,14 @@ class TestReindexCommand(object):
     @patch('allura.command.show_models.add_artifacts')
     def test_chunked_add_artifacts(self, add_artifacts):
         cmd = show_models.ReindexCommand('reindex')
-        cmd.options = Mock(tasks=True, max_chunk=10*1000, ming_config=None)
+        cmd.options = Mock(tasks=True, max_chunk=10 * 1000, ming_config=None)
         ref_ids = list(range(10 * 1000 * 2 + 20))
         cmd._chunked_add_artifacts(ref_ids)
         assert_equal(len(add_artifacts.post.call_args_list), 3)
-        assert_equal(len(add_artifacts.post.call_args_list[0][0][0]), 10 * 1000)
-        assert_equal(len(add_artifacts.post.call_args_list[1][0][0]), 10 * 1000)
+        assert_equal(
+            len(add_artifacts.post.call_args_list[0][0][0]), 10 * 1000)
+        assert_equal(
+            len(add_artifacts.post.call_args_list[1][0][0]), 10 * 1000)
         assert_equal(len(add_artifacts.post.call_args_list[2][0][0]), 20)
 
     @patch('allura.command.show_models.add_artifacts')
@@ -404,7 +444,7 @@ class TestReindexCommand(object):
         def on_post(chunk, **kw):
             if len(chunk) > 1:
                 raise pymongo.errors.InvalidDocument(
-                        "BSON document too large (16906035 bytes) - the connected server supports BSON document sizes up to 16777216 bytes.")
+                    "BSON document too large (16906035 bytes) - the connected server supports BSON document sizes up to 16777216 bytes.")
         add_artifacts.post.side_effect = on_post
         cmd = show_models.ReindexCommand('reindex')
         cmd.options, args = cmd.parser.parse_args([])

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/Allura/allura/tests/test_decorators.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_decorators.py b/Allura/allura/tests/test_decorators.py
index d4b70a5..0d1d338 100644
--- a/Allura/allura/tests/test_decorators.py
+++ b/Allura/allura/tests/test_decorators.py
@@ -42,6 +42,7 @@ class TestTask(TestCase):
         @task(disable_notifications=True)
         def func(s, foo=None, **kw):
             pass
+
         def mock_post(f, args, kw, delay=None):
             self.assertTrue(c.project.notifications_disabled)
             self.assertFalse('delay' in kw)


Mime
View raw message