incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [34/50] git commit: [#6534] ticket:442 fixed failed tests and added tests for mediawiki method call
Date Fri, 04 Oct 2013 16:31:02 GMT
[#6534] ticket:442 fixed failed tests and added tests for mediawiki method call


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/acb01022
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/acb01022
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/acb01022

Branch: refs/heads/cj/5561
Commit: acb010225fad39a26a7293ba991fd61a44024d21
Parents: 1506e8a
Author: coldmind <sokandpal@yandex.ru>
Authored: Tue Sep 24 16:24:11 2013 +0300
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Fri Oct 4 14:21:23 2013 +0000

----------------------------------------------------------------------
 .../forgeimporters/github/tests/test_wiki.py    | 26 ++++++++++++++++----
 ForgeImporters/forgeimporters/github/wiki.py    | 11 ++++++---
 2 files changed, 28 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/acb01022/ForgeImporters/forgeimporters/github/tests/test_wiki.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/tests/test_wiki.py b/ForgeImporters/forgeimporters/github/tests/test_wiki.py
index e280e4e..5ad3aed 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_wiki.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_wiki.py
@@ -83,8 +83,8 @@ class TestGitHubWikiImporter(TestCase):
 
     @patch('forgeimporters.github.wiki.WM.Page.upsert')
     @patch('forgeimporters.github.wiki.h.render_any_markup')
-    @patch('forgeimporters.github.wiki.convert_markup')
     def test_without_history(self, render, upsert):
+        self.commit2.tree.blobs = [self.blob2, self.blob3]
         upsert.text = Mock()
         importer = GitHubWikiImporter()
         importer.github_wiki_url = 'https://github.com/a/b/wiki'
@@ -92,10 +92,9 @@ class TestGitHubWikiImporter(TestCase):
         importer.app.url = '/p/test/wiki/'
         importer.rewrite_links = Mock(return_value='')
         importer._without_history(self.commit2)
-        assert_equal(upsert.call_args_list, [call('Home'), call('Home2'), call('Home3')])
+        assert_equal(upsert.call_args_list, [call('Home2'), call('Home3')])
 
         assert_equal(render.call_args_list, [
-            call('Home.md', u'# test message'),
             call('Home2.creole', u'**test message**'),
             call('Home3.rest', u'test message')])
 
@@ -127,8 +126,23 @@ class TestGitHubWikiImporter(TestCase):
 
     @patch('forgeimporters.github.wiki.WM.Page.upsert')
     @patch('forgeimporters.github.wiki.h.render_any_markup')
-    @patch('forgeimporters.github.wiki.convert_markup')
     def test_with_history(self, render, upsert):
+        self.commit2.stats.files = {"Home.rst": self.blob1}
+        self.commit2.tree = {"Home.rst": self.blob1}
+        importer = GitHubWikiImporter()
+        importer.github_wiki_url = 'https://github.com/a/b/wiki'
+        importer.app = Mock()
+        importer.app.url = '/p/test/wiki/'
+        importer.rewrite_links = Mock(return_value='')
+        importer._with_history(self.commit2)
+        assert_equal(upsert.call_args_list, [call('Home')])
+        assert_equal(render.call_args_list, [call('Home.rst', u'# test message')])
+
+
+    @skipif(module_not_available('html2text'))
+    @patch('forgeimporters.github.wiki.WM.Page.upsert')
+    @patch('forgeimporters.github.wiki.mediawiki2markdown')
+    def test_with_history_mediawiki(self, md2mkm, upsert):
         self.commit2.stats.files = {"Home.md": self.blob1}
         self.commit2.tree = {"Home.md": self.blob1}
         importer = GitHubWikiImporter()
@@ -136,9 +150,11 @@ class TestGitHubWikiImporter(TestCase):
         importer.app = Mock()
         importer.app.url = '/p/test/wiki/'
         importer.rewrite_links = Mock(return_value='')
+        importer.convert_gollum_tags = Mock()
         importer._with_history(self.commit2)
         assert_equal(upsert.call_args_list, [call('Home')])
-        assert_equal(render.call_args_list, [call('Home.md', u'# test message')])
+        assert_equal(md2mkm.call_args_list, [call(u'# test message')])
+
 
     def test_convert_page_name(self):
         f = GitHubWikiImporter()._convert_page_name

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/acb01022/ForgeImporters/forgeimporters/github/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/wiki.py b/ForgeImporters/forgeimporters/github/wiki.py
index 68f206b..0f0693a 100644
--- a/ForgeImporters/forgeimporters/github/wiki.py
+++ b/ForgeImporters/forgeimporters/github/wiki.py
@@ -223,9 +223,12 @@ class GitHubWikiImporter(ToolImporter):
 
         Conversion happens in 4 phases:
 
-        1. Convert source text to a html using h.render_any_markup
+        1. Convert source text to a html using h.render_any_markup,
+           if file format is not mediawiki. If mediawiki, it will
+           converted using mediawiki2markdown method.
         2. Rewrite links that match the wiki URL prefix with new location
-        3. Convert resulting html to a markdown using html2text, if available.
+        3. Convert resulting html to a markdown using html2text, if available,
+           and not mediawiki.
         4. Convert gollum tags
 
         If html2text module isn't available then only phases 1 and 2 will be executed.
@@ -238,9 +241,9 @@ class GitHubWikiImporter(ToolImporter):
         if html2text and ext in ['md', 'mediawiki']:
             text = mediawiki2markdown(text)
             text = self.convert_gollum_tags(text)
-        else:    
+        else:
             text = h.render_any_markup(filename, text)
-        
+
         text = self.rewrite_links(text, self.github_wiki_url, self.app.url)
         if html2text and ext not in ['md', 'mediawiki']:
             text = html2text.html2text(text)


Mime
View raw message