You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2020/04/13 17:43:33 UTC

[allura] 41/50: [#7935] Formatted code so it matches pep8 code style guidelines

This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit a79a37b06ed76fa85f7660306c088c6dcaad9c8c
Author: Fahri Korkmaz <f....@codesys.com>
AuthorDate: Sat Mar 14 00:50:01 2020 +0100

    [#7935] Formatted code so it matches pep8 code style guidelines
---
 .../forgeimporters/forge/alluraImporter.py         |  10 +-
 ForgeImporters/forgeimporters/forge/discussion.py  |  47 +++--
 .../forgeimporters/tests/forge/test_discussion.py  | 211 ++++++++++++---------
 3 files changed, 163 insertions(+), 105 deletions(-)

diff --git a/ForgeImporters/forgeimporters/forge/alluraImporter.py b/ForgeImporters/forgeimporters/forge/alluraImporter.py
index a0a8670..477b4ef 100644
--- a/ForgeImporters/forgeimporters/forge/alluraImporter.py
+++ b/ForgeImporters/forgeimporters/forge/alluraImporter.py
@@ -5,6 +5,7 @@ from allura import model as M
 
 class AlluraImporter(ToolImporter):
 
+
     def get_user(self, username):
         if username is None:
             return M.User.anonymous()
@@ -14,10 +15,17 @@ class AlluraImporter(ToolImporter):
         return user
 
     def annotate(self, text, user, username, label=''):
-        if username != "" and username != None and user != None and user.is_anonymous() and username != 'nobody' and username != '*anonymous':
+        if  username != "" \
+            and username != None \
+            and user != None \
+            and user.is_anonymous() \
+            and username != 'nobody' \
+            and username != '*anonymous':
             return '*Originally%s by:* %s\n\n%s' % (label, username, text)
 
         if text == None:
             text = ""
 
         return text
+
+
diff --git a/ForgeImporters/forgeimporters/forge/discussion.py b/ForgeImporters/forgeimporters/forge/discussion.py
index fdcabff..a06b65f 100644
--- a/ForgeImporters/forgeimporters/forge/discussion.py
+++ b/ForgeImporters/forgeimporters/forge/discussion.py
@@ -53,6 +53,7 @@ from forgediscussion import model as DM
 
 from alluraImporter import AlluraImporter
 
+
 class ForgeDiscussionImportForm(ToolImportForm):
     discussions_json = v.JsonFile(not_empty=True)
 
@@ -70,35 +71,42 @@ class ForgeDiscussionImportController(ToolImportController):
     @require_post()
     def create(self, discussions_json, mount_point, mount_label, **kw):
         if self.importer.enforce_limit(c.project):
-            save_importer_upload(c.project, 'discussions.json', json.dumps(discussions_json))
+            save_importer_upload(
+                            c.project,
+                            'discussions.json',
+                            json.dumps(discussions_json)
+                           )
             self.importer.post(mount_point=mount_point, mount_label=mount_label)
-            flash('Discussion import has begun. Your new discussion will be available when the import is complete')
-            
+            flash('Discussion import has begun. ' \
+                   + 'Your new discussion will be available ' \
+                   + 'when the import is complete'
+                 )
         else:
-            flash('There are too many imports pending at this time. Please wait and try again.', 'error')
-
+            flash('There are too many imports pending at this time. ' \
+                  + 'Please wait and try again.', 
+                  'error'
+                 )
         redirect(c.project.url() + 'admin/')
 
 
 class ForgeDiscussionImporter(AlluraImporter):
+
+
     source = 'Allura'
     target_app_ep_names = 'discussion'
     controller = ForgeDiscussionImportController
     tool_label = 'Discussion'
     tool_description = 'Import an allura discussion.'
 
-
     def __init__(self, *args, **kwargs):
         super(ForgeDiscussionImporter, self).__init__(*args, **kwargs)
 
-
     def _load_json(self, project):
         upload_path = get_importer_upload_path(project)
         full_path = os.path.join(upload_path, 'discussions.json')
         with open(full_path) as fp:
             return json.load(fp)
 
-
     def import_tool(self, project, user, mount_point=None,
                      mount_label=None, **kw):
         discussion_json = self._load_json(project)
@@ -140,7 +148,10 @@ class ForgeDiscussionImporter(AlluraImporter):
 
                     for thread_json in forum_json["threads"]:
                         thread = forum.get_discussion_thread(dict(
-                                            headers=dict(Subject=thread_json['subject'])))[0]
+                                            headers=dict(
+                                                Subject=thread_json['subject']
+                                            )
+                                        ))[0]
 
                         if "import_id" in thread_json:
                             thread.import_id = thread_json["import_id"]
@@ -150,7 +161,6 @@ class ForgeDiscussionImporter(AlluraImporter):
                     session(forum).flush(forum)
                     session(forum).expunge(forum)
 
-
                 M.AuditLog.log(
                     "import tool %s from exported Allura JSON" % (
                         app.config.options.mount_point,
@@ -169,19 +179,16 @@ class ForgeDiscussionImporter(AlluraImporter):
             finally:
                 M.session.artifact_orm_session._get().skip_mod_date = False
                                      
-
     def _clear_forums(self, app):
       forums = app.forums
       for forum in forums:
           forum.delete()
 
-
     def annotate_text(self, text, user, username):
         label = " created"
         
         return self.annotate(text, user, username, label)
 
-
     def add_posts(self, thread, posts, app):
         created_posts = []
 
@@ -209,16 +216,24 @@ class ForgeDiscussionImporter(AlluraImporter):
 
                 p = thread.add_post(
                         subject=post_json['subject'],
-                        text=self.annotate_text(post_json['text'], user, username),
+                        text=self.annotate_text(post_json['text'],
+                                                user,
+                                                username
+                                               ),
                         timestamp=timestamp,
                         ignore_security=True,
                         parent_id=parent_id
                 )
 
-                if "last_edited" in post_json and post_json["last_edited"] != None:
+                if ("last_edited" in post_json) \
+                    and (post_json["last_edited"] != None):
                     p.last_edit_date = parse(post_json["last_edited"])
 
-                p.add_multiple_attachments([File(a["url"]) for a in post_json["attachments"]])
+                p.add_multiple_attachments(
+                        [File(a["url"]) for a in post_json["attachments"]]
+                )
 
                 if slug != '': 
                     created_posts.append({ slug: p })
+
+
diff --git a/ForgeImporters/forgeimporters/tests/forge/test_discussion.py b/ForgeImporters/forgeimporters/tests/forge/test_discussion.py
index 5db983b..c37112d 100644
--- a/ForgeImporters/forgeimporters/tests/forge/test_discussion.py
+++ b/ForgeImporters/forgeimporters/tests/forge/test_discussion.py
@@ -16,7 +16,6 @@
 #       under the License.
 
 from unittest import TestCase
-
 import mock
 
 from dateutil.parser import parse
@@ -42,12 +41,10 @@ class TestDiscussionImporter(TestCase):
         self.patcher_g = mock.patch('forgeimporters.base.g', mock.MagicMock())
         self.patcher_g.start()
 
-
     def tearDown(self):
         super(TestDiscussionImporter, self).tearDown()
         self.patcher_g.stop()
 
-
     @mock.patch.object(discussion, 'c')
     @mock.patch.object(discussion, 'g')
     @mock.patch.object(discussion, 'M')
@@ -55,7 +52,10 @@ class TestDiscussionImporter(TestCase):
     @mock.patch.object(discussion, 'h')
     @mock.patch.object(discussion, 'ThreadLocalORMSession')
     def test_import_tool_with_general_discussion(self, tlos, h, session, m, g, c):
-        """ This test creates a general discussion forum with one thread and one post from admin """
+        """ This test creates a general discussion forum with
+             one thread and one post from admin 
+        """
+
         importer = discussion.ForgeDiscussionImporter()
         _json = { 
             'forums': [{
@@ -75,7 +75,7 @@ class TestDiscussionImporter(TestCase):
                                 'attachments': [],
                                 'author': 'admin1',
                                 'timestamp': '2020-01-29 22:30:42.497000',
-                                'author_icon_url': 'https://secure.gravatar.com/avatar/2ba5bfa33e6faca31f7dd150960ce926?r=pg&d=https%3A%2F%2F4.xb.sf.net%2Fnf%2F0%2F_ew_%2Ftheme%2Fsftheme%2Fimages%2Fsandiego%2Ficons%2Fdefault-avatar.png',
+                                'author_icon_url': 'bla',
                                 'text': 'hi',
                                 'last_edited': None,
                                 'slug': '00aa',
@@ -107,7 +107,10 @@ class TestDiscussionImporter(TestCase):
         g.post_event = mock.Mock()
         m.AuditLog.log = mock.Mock()
 
-        importer.import_tool(project, user, mount_point='mount_point', mount_label='mount_label')
+        importer.import_tool(project, user, 
+                             mount_point='mount_point', 
+                             mount_label='mount_label'
+                            )
 
         project.install_app.assert_called_once_with(
             'discussion', 'mount_point', 'mount_label',
@@ -120,13 +123,25 @@ class TestDiscussionImporter(TestCase):
         new_forum = self.__get_forum_dict(app, forum_json)
 
         utils.create_forum.assert_called_once_with(app, new_forum=new_forum)
-        forum.get_discussion_thread(dict(headers=dict(Subject=_json["forums"][0]["threads"][0]["subject"])))
-        importer.add_posts.assert_called_once_with(thread1, _json["forums"][0]["threads"][0]["posts"], app)
+        forum.get_discussion_thread(
+              dict(
+                   headers=dict(
+                        Subject=_json["forums"][0]["threads"][0]["subject"]
+                  )))
+        importer.add_posts.assert_called_once_with(
+                                    thread1, 
+                                    _json["forums"][0]["threads"][0]["posts"],
+                                    app
+        )
 
-        m.AuditLog.log.assert_called_once_with("import tool mount_point from exported Allura JSON", project=project, user=user, url='foo')
+        m.AuditLog.log.assert_called_once_with(
+                        "import tool mount_point from exported Allura JSON",
+                        project=project,
+                        user=user,
+                        url='foo'
+                    )
         g.post_event.assert_called_once_with("project_updated")
 
-
     @mock.patch.object(discussion, 'c')
     @mock.patch.object(discussion, 'g')
     @mock.patch.object(discussion, 'M')
@@ -134,7 +149,9 @@ class TestDiscussionImporter(TestCase):
     @mock.patch.object(discussion, 'h')
     @mock.patch.object(discussion, 'ThreadLocalORMSession')
     def test_import_tool_unicode(self, tlos, h, session, m, g, c):
-        """ This method tests if the import tool method supports unicode characters """
+        """ This method tests if the import tool method 
+            supports unicode characters 
+        """
         
         importer = discussion.ForgeDiscussionImporter()
 
@@ -154,7 +171,7 @@ class TestDiscussionImporter(TestCase):
                               "attachments": [],
                               "author": "admin1",
                               "timestamp": "2020-01-29 22:32:00.584000",
-                              "author_icon_url": "https://secure.gravatar.com/avatar/2ba5bfa33e6faca31f7dd150960ce926?r=pg&d=https%3A%2F%2F4.xb.sf.net%2Fnf%2F0%2F_ew_%2Ftheme%2Fsftheme%2Fimages%2Fsandiego%2Ficons%2Fdefault-avatar.png",
+                              "author_icon_url": "bla",
                               "text": "test with un\u00ef\u00e7\u00f8\u2202\u00e9 text",
                               "last_edited": None,
                               "slug": "0e0e",
@@ -190,7 +207,11 @@ class TestDiscussionImporter(TestCase):
         importer.get_user = mock.Mock(return_value=admin)
         importer.annotate_text = mock.Mock(return_value='aa')
 
-        importer.import_tool(project, user, mount_point='mount_point', mount_label='mount_label')
+        importer.import_tool(project,
+                             user,
+                             mount_point='mount_point',
+                             mount_label='mount_label'
+                            )
 
         project.install_app.assert_called_once_with(
             'discussion', 'mount_point', 'mount_label',
@@ -201,7 +222,11 @@ class TestDiscussionImporter(TestCase):
         new_forum = self.__get_forum_dict(app, forum_json)
 
         utils.create_forum.assert_called_once_with(app, new_forum=new_forum)
-        forum.get_discussion_thread.assert_called_once_with(dict(headers=dict(Subject=_json["forums"][0]["threads"][0]["subject"])))
+        forum.get_discussion_thread.assert_called_once_with(
+                    dict(
+                        headers=dict(
+                            Subject=_json["forums"][0]["threads"][0]["subject"]
+            )))
         
         importer.get_user.assert_called_once_with('admin1')
     
@@ -218,12 +243,15 @@ class TestDiscussionImporter(TestCase):
             ignore_security=True,
             parent_id=None
         )
-        importer.annotate_text.assert_called_once_with(post["text"], admin, post["author"])
+        importer.annotate_text.assert_called_once_with(
+                post["text"],
+                admin,
+                post["author"]
+        )
         p.add_multiple_attachments.assert_called_once_with([])
 
         g.post_event.assert_called_once_with('project_updated')
 
-
     @mock.patch.object(discussion, 'c')
     @mock.patch.object(discussion, 'g')
     @mock.patch.object(discussion, 'M')
@@ -231,7 +259,9 @@ class TestDiscussionImporter(TestCase):
     @mock.patch.object(discussion, 'h')
     @mock.patch.object(discussion, 'ThreadLocalORMSession')
     def test_import_tool_multiple_forums(self, tlos, h, session, m, g, c):
-        """ This test tests if it is possible to create a discussion with multiple forums """
+        """ This test tests if it is possible to create 
+            a discussion with multiple forums 
+        """
 
         importer = discussion.ForgeDiscussionImporter()
 
@@ -263,7 +293,6 @@ class TestDiscussionImporter(TestCase):
                 }
             ]
         }
-
         
         importer._load_json = mock.Mock(return_value=_json)
         importer.add_posts = mock.Mock()        
@@ -307,7 +336,6 @@ class TestDiscussionImporter(TestCase):
         m.AuditLog.log.assert_called_once()
         g.post_event.assert_called_once()
 
-
     @mock.patch.object(discussion, 'c')
     @mock.patch.object(discussion, 'g')
     @mock.patch.object(discussion, 'M')
@@ -354,7 +382,6 @@ class TestDiscussionImporter(TestCase):
                 ]
             }
 
-            
         importer._load_json = mock.Mock(return_value=_json)
         importer.add_posts = mock.Mock()        
         importer._clear_forums = mock.Mock()
@@ -378,7 +405,12 @@ class TestDiscussionImporter(TestCase):
 
         importer.import_tool(project, user, 'mount_point', 'mount_label')
 
-        project.install_app.assert_called_once_with('discussion', 'mount_point', 'mount_label', import_id={'source': 'Allura'})
+        project.install_app.assert_called_once_with(
+                'discussion',
+                'mount_point',
+                'mount_label',
+                import_id={'source': 'Allura'}
+        )
         h.push_config.assert_called_once_with(c, app=app)
 
         utils.create_forum.assert_called_once()
@@ -406,7 +438,6 @@ class TestDiscussionImporter(TestCase):
         m.AuditLog.log.assert_called_once()
         g.post_event.assert_called_once()
 
-
     @mock.patch.object(discussion, 'c')
     @mock.patch.object(discussion, 'g')
     @mock.patch.object(discussion, 'M')
@@ -422,7 +453,7 @@ class TestDiscussionImporter(TestCase):
         import_id = "qwert258"
         _json = {
             "forums": [ {
-                "description": "Forum about anything you want to talk about.", 
+                "description": "Forum about anything you want to talk about.",
                 "shortname": "general", 
                 "name": "General Discussion",
                 "import_id": import_id,
@@ -454,7 +485,6 @@ class TestDiscussionImporter(TestCase):
         importer.import_tool(project, user, 'mount_point', 'mount_label')
         
         self.assertEqual(import_id, forum.import_id)
-        
 
         # Test without import id
         _json = {
@@ -475,7 +505,6 @@ class TestDiscussionImporter(TestCase):
 
         self.assertEqual('', forum.import_id)
 
-
     @mock.patch.object(discussion, 'c')
     @mock.patch.object(discussion, 'g')
     @mock.patch.object(discussion, 'M')
@@ -533,7 +562,7 @@ class TestDiscussionImporter(TestCase):
         _json = {
             "forums": [ {
                 "description": "Forum about anything you want to talk about.", 
-                "shortname": "general", 
+                "shortname": "general",
                 "name": "General Discussion",
                 "threads": [{
                         "limit": None,
@@ -553,7 +582,6 @@ class TestDiscussionImporter(TestCase):
 
         self.assertEqual('', thread.import_id)
 
-
     @mock.patch.object(discussion, 'c')
     @mock.patch.object(discussion, 'g')
     @mock.patch.object(discussion, 'M')
@@ -563,10 +591,10 @@ class TestDiscussionImporter(TestCase):
     def test_import_tool_missing_keys(self, tlos, h, session, m, g, c):
         """ This method tests if missing keys are handled correctly """
 
-        # Check if shortname missing
+        # Check when shortname missing
         _json = {
             "forums": [ {
-                "description": "Forum about anything you want to talk about.", 
+                "description": "Forum about anything you want to talk about.",
                 "name": "General Discussion",
                 "threads": []
             }]
@@ -597,9 +625,8 @@ class TestDiscussionImporter(TestCase):
         m.AuditLog.log= mock.Mock()
 
         self.__check_missing(project, user, importer, h, g, utils) 
-
         
-        # Check if description is missing
+        # Check when description is missing
         _json = {
             "forums": [ {
                 "shortname": "general",
@@ -612,8 +639,7 @@ class TestDiscussionImporter(TestCase):
         self.__check_missing(project, user, importer, h, g, utils)
         utils.create_forum.assert_not_called()
 
-
-        # Check if name is missing
+        # Check when name is missing
         _json = {
             "forums": [ {
                 "shortname": "general",
@@ -625,9 +651,8 @@ class TestDiscussionImporter(TestCase):
         importer._load_json = mock.Mock(return_value=_json)
         self.__check_missing(project, user, importer, h, g, utils)
         utils.create_forum.assert_not_called()
-
         
-        # Check if threads are missing
+        # Check when threads are missing
         _json = {
             "forums": [ {
                 "shortname": "general",
@@ -639,8 +664,7 @@ class TestDiscussionImporter(TestCase):
         importer._load_json = mock.Mock(return_value=_json)
         self.__check_missing(project, user, importer, h, g, utils)
 
-        
-        # Check if subject of threads are missing
+        # Check when subject of threads are missing
         _json = {
             "forums": [ {
                 "shortname": "general",
@@ -656,7 +680,7 @@ class TestDiscussionImporter(TestCase):
         self.__check_missing(project, user, importer, h, g, utils)
 
 
-        # Check if posts of threads are missing
+        # Check when posts of threads are missing
         _json = {
             "forums": [ {
                 "shortname": "general",
@@ -673,7 +697,6 @@ class TestDiscussionImporter(TestCase):
         
         self.assertEqual(h.make_app_admin_only.call_count, 6)
 
-
     @mock.patch.object(discussion, 'c')
     @mock.patch.object(discussion, 'h')
     def test_add_posts(self, h, c):
@@ -701,12 +724,13 @@ class TestDiscussionImporter(TestCase):
                 parent_id=None
         )
         post.add_multiple_attachments.assert_called_once_with([])
-        
     
     @mock.patch.object(discussion, 'c')
     @mock.patch.object(discussion, 'h')
     def test_add_posts_with_many_posts(self, h, c):
-        """ This methods tests if many posts of a thread are added to this thread """
+        """ This methods tests if many posts of 
+            a thread are added to this thread 
+        """
 
         importer, app, thread, user, post = self.__init_add_posts_tests()
 
@@ -777,15 +801,17 @@ class TestDiscussionImporter(TestCase):
         self.assertEqual(8, h.push_config.call_count)
         self.assertEqual(8, thread.add_post.call_count)
         self.assertEqual(8, post.add_multiple_attachments.call_count)
-    
 
     @mock.patch.object(discussion, 'c')
     @mock.patch.object(discussion, 'h')
     def test_add_posts_with_unicode(self, h, c):
-        """ This method tests if it is possible to add posts which contain unicode characters in subject and text """
+        """ This method tests if it is possible to add 
+            posts which contain unicode characters in subject and text
+        """
 
         importer, app, thread, user, post = self.__init_add_posts_tests()
-        importer.annotate_text.return_value = "test with un\u00ef\u00e7\u00f8\u2202\u00e9 text"
+        importer.annotate_text.return_value = "test" \
+                + " with un\u00ef\u00e7\u00f8\u2202\u00e9 text"
 
         _json = [
             {
@@ -810,11 +836,12 @@ class TestDiscussionImporter(TestCase):
         )
         post.add_multiple_attachments.assert_called_once_with([])
         
-
     @mock.patch.object(discussion, 'c')
     @mock.patch.object(discussion, 'h')
     def test_add_posts_with_last_edited(self, h, c):
-        """ This method tests if the last edited attribute of a post is correctly updated if specified """
+        """ This method tests if the last edited attribute 
+            of a post is correctly updated if specified
+        """
 
         # Test with legit timestamp
         importer, app, thread, user, post = self.__init_add_posts_tests()
@@ -834,7 +861,6 @@ class TestDiscussionImporter(TestCase):
 
         self.assertEqual(post.last_edit_date, parse(_json[0]['last_edited']))
 
-
         # Test with none
         importer, app, thread, user, post = self.__init_add_posts_tests()
 
@@ -854,7 +880,6 @@ class TestDiscussionImporter(TestCase):
 
         self.assertEqual(post.last_edit_date, '-')
 
-       
         # Test with no last edited 
         importer, app, thread, user, post = self.__init_add_posts_tests()
 
@@ -873,7 +898,6 @@ class TestDiscussionImporter(TestCase):
 
         self.assertEqual(post.last_edit_date, '-')
 
-        
         # Test with junk last edited 
         importer, app, thread, user, post = self.__init_add_posts_tests()
 
@@ -890,11 +914,11 @@ class TestDiscussionImporter(TestCase):
 
         try:
             importer.add_posts(thread, _json, app)
-            self.fail("add_posts() didn't throw exception even last_edited was junk data")
+            self.fail("add_posts() didn't throw exception" \
+                      + " even last_edited was junk data")
         except:
             pass
 
-
     @mock.patch.object(discussion, 'File')
     @mock.patch.object(discussion, 'c')
     @mock.patch.object(discussion, 'h')
@@ -936,10 +960,9 @@ class TestDiscussionImporter(TestCase):
         self.assertEqual(File.call_args_list, [
             mock.call('http://www.foo.com/attachment0'),
             mock.call('http://www.foo.com/attachment1'),
-            mock.call('http://www.foo.com/attachment2')
+            mock.call('http://www.foo.com/attachment2'),
         ])
 
-
     @mock.patch.object(discussion, 'File')
     @mock.patch.object(discussion, 'c')
     @mock.patch.object(discussion, 'h')
@@ -955,7 +978,7 @@ class TestDiscussionImporter(TestCase):
             mock.Mock(_id=2),
             mock.Mock(_id=3),
             mock.Mock(_id=4),
-            mock.Mock(_id=5)
+            mock.Mock(_id=5),
         ]
 
         _json = [
@@ -1056,12 +1079,13 @@ class TestDiscussionImporter(TestCase):
             )
         ])
 
-
     @mock.patch.object(discussion, 'File')
     @mock.patch.object(discussion, 'c')
     @mock.patch.object(discussion, 'h')
     def test_add_posts_with_missing_keys(self, h, c, File):
-        """ This method checks if add_posts will throw an error if required keys are missing """
+        """ This method checks if add_posts will 
+            throw an error if required keys are missing
+        """
         
         # Test with author attribute missing
         importer, app, thread, user, post = self.__init_add_posts_tests()
@@ -1075,7 +1099,6 @@ class TestDiscussionImporter(TestCase):
 
         self.__check_posts_exceptions(importer, thread, _json, app)
 
-
         # Test with subject attribute missing
         importer, app, thread, user, post = self.__init_add_posts_tests()
 
@@ -1088,7 +1111,6 @@ class TestDiscussionImporter(TestCase):
 
         self.__check_posts_exceptions(importer, thread, _json, app)
 
-
         # Test with text attribute missing
         importer, app, thread, user, post = self.__init_add_posts_tests()
 
@@ -1101,7 +1123,6 @@ class TestDiscussionImporter(TestCase):
 
         self.__check_posts_exceptions(importer, thread, _json, app)
 
-
         # Test with timestamp attribute missing
         importer, app, thread, user, post = self.__init_add_posts_tests()
 
@@ -1114,7 +1135,6 @@ class TestDiscussionImporter(TestCase):
 
         self.__check_posts_exceptions(importer, thread, _json, app)
 
-
         # Test with attachments attribute missing
         importer, app, thread, user, post = self.__init_add_posts_tests()
 
@@ -1127,7 +1147,6 @@ class TestDiscussionImporter(TestCase):
 
         self.__check_posts_exceptions(importer, thread, _json, app)
 
-
         # Test with url of attachments attribute missing
         importer, app, thread, user, post = self.__init_add_posts_tests()
 
@@ -1146,11 +1165,11 @@ class TestDiscussionImporter(TestCase):
 
         self.__check_posts_exceptions(importer, thread, _json, app)
 
-
     def __check_posts_exceptions(self, importer, thread, posts, app):
         try:
             importer.add_posts(thread, posts, app)
-            self.fail("add_posts() didn't throw an exception even though attribute are missing")
+            self.fail("add_posts() didn't throw an "\
+                    + "exception even though attribute are missing")
         except:
             pass
 
@@ -1177,7 +1196,9 @@ class TestDiscussionImporter(TestCase):
         return importer, app, thread, user1, post
 
     def test_annotate_text_with_existing_user(self):
-        """ This test tests the annotate_text method if an existing user is passed as argument """
+        """ This test tests the annotate_text method if 
+            an existing user is passed as argument 
+        """
 
         importer = discussion.ForgeDiscussionImporter()
         
@@ -1188,9 +1209,10 @@ class TestDiscussionImporter(TestCase):
 
         self.assertEqual(importer.annotate_text('foo', user, username), 'foo')
 
-
     def test_annotate_text_with_not_existing_user(self):
-        """ This test tests the annotate_text method with a not existing user """
+        """ This test tests the annotate_text method 
+            with a not existing user
+        """
 
         importer = discussion.ForgeDiscussionImporter()
 
@@ -1203,10 +1225,13 @@ class TestDiscussionImporter(TestCase):
         text = 'foo'
 
         # Text that the method should return
-        return_text = '*Originally created by:* {username}\n\n{text}'.format(username=username, text=text)
-
-        self.assertEqual(importer.annotate_text(text, user, username), return_text)
+        return_text = '*Originally created by:* {username}\n\n{text}' \
+                .format(username=username, text=text)
 
+        self.assertEqual(
+                         importer.annotate_text(text, user, username),
+                         return_text
+                        )
 
     def test_annotate_text_with_anonymous_user(self):
         """ This test tests the annotate_text method with an anonymous user """
@@ -1221,12 +1246,19 @@ class TestDiscussionImporter(TestCase):
 
         text = 'foo'
 
-        self.assertEqual(importer.annotate_text(text, user, usernames[0]), text)
-        self.assertEqual(importer.annotate_text(text, user, usernames[1]), text)
-
+        self.assertEqual(
+                importer.annotate_text(text, user, usernames[0]),
+                text
+        )
+        self.assertEqual(
+                importer.annotate_text(text, user, usernames[1]),
+                text
+        )
         
     def test_annotate_text_with_unicode(self):
-        """ This method tests if annotate text can handle unicode characters """
+        """ This method tests if annotate text 
+            can handle unicode characters
+        """
 
         importer = discussion.ForgeDiscussionImporter()
 
@@ -1239,7 +1271,6 @@ class TestDiscussionImporter(TestCase):
         except:
             self.fail("annotate_text() can't handle unicode characters")
 
-
         # unicode in text of a not existing user
         text = "post with un\u00ef\u00e7\u00f8\u2202\u00e9"
         user = mock.Mock(is_anonymous=lambda: True)
@@ -1250,7 +1281,6 @@ class TestDiscussionImporter(TestCase):
         except:
             self.fail("annotate_text() can't handle unicode characters")
 
-
         # unicode in text of an anonymous user
         text = "post with un\u00ef\u00e7\u00f8\u2202\u00e9"
         user = mock.Mock(is_anonymous=lambda: True)
@@ -1261,9 +1291,10 @@ class TestDiscussionImporter(TestCase):
         except:
             self.fail("annotate_text() can't handle unicode characters")
 
-
     def test_annotate_text_with_junk(self):
-        """ This test tests if the annotate_text method correctly handles junk data """
+        """ This test tests if the annotate_text method
+            correctly handles junk data
+        """
 
         importer = discussion.ForgeDiscussionImporter()
 
@@ -1276,7 +1307,6 @@ class TestDiscussionImporter(TestCase):
         text = 'foo'
         self.assertEqual(importer.annotate_text(text, user, username), text)
 
-
     def __get_forum_dict(self, app, forum_json):
         new_forum = dict(
             app_config_id = app.config._id,
@@ -1292,7 +1322,6 @@ class TestDiscussionImporter(TestCase):
 
         return new_forum
 
-
     def __check_missing(self, project, user, importer, h, g, utils):
         try:       
             importer.import_tool(project, user, 'mount_point', 'mount_label')
@@ -1310,7 +1339,6 @@ class TestForgeDiscussionController(TestController, TestCase):
     
     def setUp(self):
         super(TestForgeDiscussionController, self).setUp()
-
     
     @with_discussion
     def test_index(self):
@@ -1319,27 +1347,31 @@ class TestForgeDiscussionController(TestController, TestCase):
         self.assertIsNotNone(r.html.find(attrs=dict(name="mount_label")))
         self.assertIsNotNone(r.html.find(attrs=dict(name="mount_point")))
 
-
     @with_discussion
     @mock.patch('forgeimporters.forge.discussion.save_importer_upload')
     @mock.patch('forgeimporters.base.import_tool')
     def test_create(self, import_tool, siu):
         project = M.Project.query.get(shortname='test')
         params = {
-            'discussions_json': webtest.Upload('discussions.json', b'{"key": "val"}'),
+            'discussions_json': webtest.Upload('discussions.json',
+                                               b'{"key": "val"}'),
             'mount_label': 'mylabel',
             'mount_point': 'mymount',
         }
-        r = self.app.post('/p/test/admin/ext/import/forge-discussion/create', params,
-                          status=302)
+        r = self.app.post('/p/test/admin/ext/import/forge-discussion/create',
+                          params,
+                          status=302
+                         )
         self.assertEqual(r.location, 'http://localhost/p/test/admin/')
-        siu.assert_called_once_with(project, 'discussions.json', '{"key": "val"}')
+        siu.assert_called_once_with(project,
+                                    'discussions.json',
+                                    '{"key": "val"}'
+                                    )
         self.assertEqual(
             'mymount', import_tool.post.call_args[1]['mount_point'])
         self.assertEqual(
             'mylabel', import_tool.post.call_args[1]['mount_label'])
 
-
     @with_discussion
     @mock.patch('forgeimporters.forge.discussion.save_importer_upload')
     @mock.patch('forgeimporters.base.import_tool')
@@ -1348,11 +1380,14 @@ class TestForgeDiscussionController(TestController, TestCase):
         project.set_tool_data('ForgeDiscussionImporter', pending=1)
         ThreadLocalORMSession.flush_all()
         params = {
-            'discussions_json': webtest.Upload('discussions.json', b'{"key": "val"}'),
+            'discussions_json': webtest.Upload('discussions.json',
+                                               b'{"key": "val"}'
+                                              ),
             'mount_label': 'mylabel',
             'mount_point': 'mymount',
         }
-        r = self.app.post('/p/test/admin/ext/import/forge-discussion/create', params,
+        r = self.app.post('/p/test/admin/ext/import/forge-discussion/create',
+                          params,
                           status=302).follow()
         self.assertIn('Please wait and try again', r)
         self.assertEqual(import_tool.post.call_count, 0)