incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [16/50] git commit: [#6534] ticket:441 Tests for links conversion
Date Fri, 04 Oct 2013 16:30:44 GMT
[#6534] ticket:441 Tests for links conversion


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

Branch: refs/heads/cj/5561
Commit: ec066ab8c86387172cce61ffc89a764d09b6f7a9
Parents: 36931df
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Wed Sep 18 12:43:20 2013 +0300
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Fri Oct 4 14:21:21 2013 +0000

----------------------------------------------------------------------
 .../forgeimporters/github/tests/test_wiki.py    | 46 ++++++++++++++++++++
 ForgeImporters/forgeimporters/github/wiki.py    |  6 +++
 2 files changed, 52 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ec066ab8/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 68b3bad..d7f8196 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_wiki.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_wiki.py
@@ -1,3 +1,5 @@
+# coding: utf-8
+
 #       Licensed to the Apache Software Foundation (ASF) under one
 #       or more contributor license agreements.  See the NOTICE file
 #       distributed with this work for additional information
@@ -122,6 +124,50 @@ class TestGitHubWikiImporter(TestCase):
         assert_equal(upsert.call_args_list, [call('Home')])
         assert_equal(render.call_args_list, [call('Home.md', u'# test message')])
 
+    def test_convert_gollum_tags(self):
+        pass
+
+    def test_convert_gollum_page_links(self):
+        f = GitHubWikiImporter().convert_gollum_page_links
+        assert_equal(f(u'[[Page]]'), u'[Page]')
+        assert_equal(f(u'[[Page Title|Page]]'), u'[Page Title](Page)')
+        assert_equal(f(u'[[Pagê Nâme]]'), u'[Pagê Nâme]')
+        # Github always converts spaces and slashes in links to hyphens,
+        # to lookup page in the filesystem. During import we're converting
+        # all hyphens in page name to spaces, but still supporting both link formats.
+        assert_equal(f(u'[[Page With Spaces]]'), u'[Page With Spaces]')
+        assert_equal(f(u'[[Page-With-Spaces]]'), u'[Page With Spaces]')
+        assert_equal(f(u'[[Page / 1]]'), u'[Page   1]')
+        assert_equal(f(u'[[Title|Page With Spaces]]'), u'[Title](Page With Spaces)')
+        assert_equal(f(u'[[Title|Page-With-Spaces]]'), u'[Title](Page With Spaces)')
+        assert_equal(f(u'[[go here|Page / 1]]'), u'[go here](Page   1)')
+
+    def test_convert_gollum_page_links_escaped(self):
+        f = GitHubWikiImporter().convert_gollum_page_links
+        assert_equal(f(u"'[[Page]]"), u'[[Page]]')
+        assert_equal(f(u"'[[Page Title|Page]]"), u'[[Page Title|Page]]')
+        assert_equal(f(u"'[[Page With Spaces]]"), u'[[Page With Spaces]]')
+        assert_equal(f(u"'[[Page-With-Spaces]]"), u'[[Page-With-Spaces]]')
+        assert_equal(f(u"'[[Page / 1]]"), u'[[Page / 1]]')
+        assert_equal(f(u"'[[Title|Page With Spaces]]"), u'[[Title|Page With Spaces]]')
+        assert_equal(f(u"'[[Title|Page-With-Spaces]]"), u'[[Title|Page-With-Spaces]]')
+        assert_equal(f(u"'[[go here|Page / 1]]"), u'[[go here|Page / 1]]')
+
+    def test_convert_gollum_external_links(self):
+        f = GitHubWikiImporter().convert_gollum_external_links
+        assert_equal(f(u'[[http://sf.net]]'), u'<http://sf.net>')
+        assert_equal(f(u'[[https://sf.net]]'), u'<https://sf.net>')
+        assert_equal(f(u'[[SourceForge|http://sf.net]]'), u'[SourceForge](http://sf.net)')
+
+    def test_convert_gollum_external_links_escaped(self):
+        f = GitHubWikiImporter().convert_gollum_external_links
+        assert_equal(f(u"'[[http://sf.net]]"), u'[[http://sf.net]]')
+        assert_equal(f(u"'[[https://sf.net]]"), u'[[https://sf.net]]')
+        assert_equal(f(u"'[[SourceForge|http://sf.net]]"), u'[[SourceForge|http://sf.net]]')
+
+    def test_convert_gollum_toc(self):
+        pass
+
 
 class TestGitHubWikiImportController(TestController, TestCase):
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ec066ab8/ForgeImporters/forgeimporters/github/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/wiki.py b/ForgeImporters/forgeimporters/github/wiki.py
index cabe145..feaca46 100644
--- a/ForgeImporters/forgeimporters/github/wiki.py
+++ b/ForgeImporters/forgeimporters/github/wiki.py
@@ -202,3 +202,9 @@ class GitHubWikiImporter(ToolImporter):
         for commit in reversed(list(wiki.iter_commits())):
             self.get_blobs_with_history(commit)
         rmtree(wiki_path)
+
+    def convert_gollum_page_links(self, text):
+        return text
+
+    def convert_gollum_external_links(self, text):
+        return text


Mime
View raw message