def test_convert_markup_with_mediawiki2markdown(self): importer = GitHubWikiImporter() importer.github_wiki_url = 'https://github.com/a/b/wiki' importer.app = Mock() importer.app.url = '/p/test/wiki/' f = importer.convert_markup source = u''' ''Al'fredas 235 BC'' == See also == * [https://github.com/a/b/wiki/AgentSpring-running-instructions-for-d13n-model Test1] * [https://github.com/a/b/wiki/AgentSpring-conventions Test2] * [https://github.com/a/b/wiki/AgentSpring-Q&A Test3] * [https://github.com/a/b/wiki/Extensions Test4]''' result = u'''_Al'fredas 235 BC_ ## See also * [Test1](/p/test/wiki/AgentSpring running instructions for d13n model) * [Test2](/p/test/wiki/AgentSpring conventions) * [Test3](/p/test/wiki/AgentSpring Q&A) * [Test4](/p/test/wiki/Extensions) ''' assert_equal(f(source, 'test.mediawiki'), result)
def test_convert_markup_without_html2text(self): importer = GitHubWikiImporter() importer.github_wiki_url = 'https://github.com/a/b/wiki' importer.app = Mock() importer.app.url = '/p/test/wiki/' f = importer.convert_markup source = '''Look at [[this page|Some Page]] More info at: [[MoreInfo]] [[Even More Info]] Our website is [[http://domain.net]]. '[[Escaped Tag]] [External link to the wiki page](https://github.com/a/b/wiki/Page) [External link](https://github.com/a/b/issues/1)''' result = '''<p>Look at [[this page|Some Page]]</p> <p>More info at: [[MoreInfo]] [[Even More Info]]</p> <p>Our website is [[http://domain.net]].</p> <p>\u2018[[Escaped Tag]]</p> <p>[External link to the wiki page](https://github.com/a/b/wiki/Page)</p> <p>[External link](https://github.com/a/b/issues/1)</p>''' assert_equal(f(source, 'test.textile').strip(), result)
def test_convert_markup_with_mediawiki2markdown(self): importer = GitHubWikiImporter() importer.github_wiki_url = 'https://github.com/a/b/wiki' importer.app = Mock() importer.app.url = '/p/test/wiki/' f = importer.convert_markup source = ''' ''Al'fredas 235 BC'' == See also == * [https://github.com/a/b/wiki/AgentSpring-running-instructions-for-d13n-model Test1] * [https://github.com/a/b/wiki/AgentSpring-conventions Test2] * [https://github.com/a/b/wiki/AgentSpring-Q&A Test3] * [https://github.com/a/b/wiki/Extensions Test4]''' result = '''_Al'fredas 235 BC_ ## See also * [Test1](/p/test/wiki/AgentSpring running instructions for d13n model) * [Test2](/p/test/wiki/AgentSpring conventions) * [Test3](/p/test/wiki/AgentSpring Q&A) * [Test4](/p/test/wiki/Extensions) ''' assert_equal(f(source, 'test.mediawiki'), result)
def test_convert_markup_without_html2text(self): importer = GitHubWikiImporter() importer.github_wiki_url = 'https://github.com/a/b/wiki' importer.app = Mock() importer.app.url = '/p/test/wiki/' f = importer.convert_markup source = u'''Look at [[this page|Some Page]] More info at: [[MoreInfo]] [[Even More Info]] Our website is [[http://sf.net]]. '[[Escaped Tag]] [External link to the wiki page](https://github.com/a/b/wiki/Page) [External link](https://github.com/a/b/issues/1)''' result = u'''<p>Look at [[this page|Some Page]]</p> <p>More info at: [[MoreInfo]] [[Even More Info]]</p> <p>Our website is [[http://sf.net]].</p> <p>'[[Escaped Tag]]</p> <p>[External link to the wiki page](https://github.com/a/b/wiki/Page)</p> <p>[External link](https://github.com/a/b/issues/1)</p>''' assert_equal(f(source, 'test.textile').strip(), result)
def test_convert_textile_special_tag(self): importer = GitHubWikiImporter() importer.github_wiki_url = 'https://github.com/a/b/wiki' importer.app = Mock() importer.app.url = '/p/test/wiki/' f = importer.convert_markup source = u'*[[this checklist|Troubleshooting]]*' assert_equal(f(source, 't.textile').strip(), u'**[this checklist](Troubleshooting)**')
def test_convert_textile_special_tag_without_html2text(self): importer = GitHubWikiImporter() importer.github_wiki_url = 'https://github.com/a/b/wiki' importer.app = Mock() importer.app.url = '/p/test/wiki/' f = importer.convert_markup source = u'*[[this checklist|Troubleshooting]]*' result = u'<p><strong>[[this checklist|Troubleshooting]]</strong></p>' assert_equal(f(source, 't.textile').strip(), result)
def test_convert_textile_special_tag_without_html2text(self): importer = GitHubWikiImporter() importer.github_wiki_url = 'https://github.com/a/b/wiki' importer.app = Mock() importer.app.url = '/p/test/wiki/' f = importer.convert_markup source = '*[[this checklist|Troubleshooting]]*' result = '<p><strong>[[this checklist|Troubleshooting]]</strong></p>' assert_equal(f(source, 't.textile').strip(), result)
def test_convert_textile_special_tag(self): importer = GitHubWikiImporter() importer.github_wiki_url = 'https://github.com/a/b/wiki' importer.app = Mock() importer.app.url = '/p/test/wiki/' f = importer.convert_markup source = '*[[this checklist|Troubleshooting]]*' assert_equal(f(source, 't.textile').strip(), '**[this checklist](Troubleshooting)**')
def test_convert_markup_with_amp_in_links(self): importer = GitHubWikiImporter() importer.github_wiki_url = 'https://github.com/a/b/wiki' importer.app = Mock() importer.app.url = '/p/test/wiki/' f = importer.convert_markup source = '[[Ticks & Leeches]]' result = '[Ticks & Leeches]' # markdown should be untouched assert_equal(f(source, 'test.rst').strip(), result)
def test_convert_markup_with_amp_in_links(self): importer = GitHubWikiImporter() importer.github_wiki_url = 'https://github.com/a/b/wiki' importer.app = Mock() importer.app.url = '/p/test/wiki/' f = importer.convert_markup source = u'[[Ticks & Leeches]]' result = u'[Ticks & Leeches]' # markdown should be untouched assert_equal(f(source, 'test.rst').strip(), result)
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._set_available_pages = Mock() importer.github_wiki_url = 'https://github.com/a/b/wiki' importer.app = Mock() importer.app.config.options = {} 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')])
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._set_available_pages = Mock() importer.github_wiki_url = 'https://github.com/a/b/wiki' importer.app = Mock() importer.app.config.options = {} 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', '# test message')])
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' importer.app = Mock() importer.app.config.options = {} importer.app.url = '/p/test/wiki/' importer.rewrite_links = Mock(return_value='') importer._without_history(self.commit2) assert_equal(upsert.call_args_list, [call('Home2'), call('Home3')]) assert_equal(render.call_args_list, [ call('Home2.creole', '**test message**'), call('Home3.rest', 'test message')])
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' importer.app = Mock() importer.app.config.options = {} importer.app.url = '/p/test/wiki/' importer.rewrite_links = Mock(return_value='') importer._without_history(self.commit2) assert_equal(upsert.call_args_list, [call('Home2'), call('Home3')]) assert_equal(render.call_args_list, [ call('Home2.creole', u'**test message**'), call('Home3.rest', u'test message')])
def test_import_id(self, upsert): page = Mock() upsert.return_value = page importer = GitHubWikiImporter() importer.app = Mock() importer.app.config.options = { 'import_id': { 'source': 'GitHub', 'project_name': 'me/project', } } importer._make_page('text', 'Page.md', self.commit2) import_id = { 'source': 'GitHub', 'project_name': 'me/project', 'source_id': 'Page', } assert_equal(page.import_id, import_id)
def test_import_id(self, upsert): page = Mock() upsert.return_value = page importer = GitHubWikiImporter() importer.app = Mock() importer.app.config.options = { 'import_id': { 'source': 'GitHub', 'project_name': 'me/project', } } importer._make_page('text', 'Page.md', self.commit2) import_id = { 'source': 'GitHub', 'project_name': 'me/project', 'source_id': 'Page', } assert_equal(page.import_id, import_id)
def test_convert_markup_textile(self): importer = GitHubWikiImporter() importer.github_wiki_url = 'https://github.com/a/b/wiki' importer.app = Mock() importer.app.url = '/p/test/wiki/' f = importer.convert_markup # check if lists converting works properly source = '''There are good reasons for this: # Duplicate libraries regularly break builds # Subtle bugs emerge with duplicate libraries, and to a lesser extent, duplicate tools # We want you to try harder to make your formula work with what OS X comes with ''' result = '''There are good reasons for this: 1. Duplicate libraries regularly break builds 2. Subtle bugs emerge with duplicate libraries, and to a lesser extent, duplicate tools 3. We want you to try harder to make your formula work with what OS X comes with ''' assert_equal(f(source, 'test.textile'), result) # textile-style links converts normal source = '*"Textile":Troubleshooting*' result = '**[Textile](Troubleshooting)**\n\n' assert_equal(f(source, 'test2.textile'), result) # links with formatting converts normal in textile now source = '''*[[this checklist|Troubleshooting]]* some text and *[[Tips n' Tricks]]* *[[link|http://otherlink.com]]* ''' result = '''**[this checklist](Troubleshooting)** some text and **[Tips n\u2019 Tricks]** **[link](http://otherlink.com)** ''' assert_equal(f(source, 'test3.textile'), result)
def test_convert_markup(self): importer = GitHubWikiImporter() importer.github_wiki_url = 'https://github.com/a/b/wiki' importer.app = Mock() importer.app.url = '/p/test/wiki/' importer.github_markdown_converter = GitHubMarkdownConverter( 'user', 'proj') f = importer.convert_markup source = u'''Look at [[this page|Some Page]] More info at: [[MoreInfo]] [[Even More Info]] Our website is [[http://domain.net]]. '[[Escaped Tag]] ```python codeblock ``` ticket #1 #1 header sha aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa''' result = u'''Look at [this page](Some Page) More info at: [MoreInfo] [Even More Info] Our website is <http://domain.net>. [[Escaped Tag]] :::python codeblock ticket [#1] [#1] header sha [aaaaaa]''' assert_equal(f(source, 'test.md').strip(), result) assert_equal(f(u'h1. Hello', 't.textile').strip(), u'# Hello')
def test_convert_markup(self): importer = GitHubWikiImporter() importer.github_wiki_url = 'https://github.com/a/b/wiki' importer.app = Mock() importer.app.url = '/p/test/wiki/' importer.github_markdown_converter = GitHubMarkdownConverter( 'user', 'proj') f = importer.convert_markup source = '''Look at [[this page|Some Page]] More info at: [[MoreInfo]] [[Even More Info]] Our website is [[http://domain.net]]. '[[Escaped Tag]] ```python codeblock ``` ticket #1 #1 header sha aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa''' result = '''Look at [this page](Some Page) More info at: [MoreInfo] [Even More Info] Our website is <http://domain.net>. [[Escaped Tag]] :::python codeblock ticket [#1] [#1] header sha [aaaaaa]''' assert_equal(f(source, 'test.md').strip(), result) assert_equal(f('h1. Hello', 't.textile').strip(), '# Hello')
def test_convert_markup_textile(self): importer = GitHubWikiImporter() importer.github_wiki_url = 'https://github.com/a/b/wiki' importer.app = Mock() importer.app.url = '/p/test/wiki/' f = importer.convert_markup # check if lists converting works properly source = u'''There are good reasons for this: # Duplicate libraries regularly break builds # Subtle bugs emerge with duplicate libraries, and to a lesser extent, duplicate tools # We want you to try harder to make your formula work with what OS X comes with ''' result = u'''There are good reasons for this: 1. Duplicate libraries regularly break builds 2. Subtle bugs emerge with duplicate libraries, and to a lesser extent, duplicate tools 3. We want you to try harder to make your formula work with what OS X comes with ''' assert_equal(f(source, 'test.textile'), result) # textile-style links converts normal source = '*"Textile":Troubleshooting*' result = '**[Textile](Troubleshooting)**\n' assert_equal(f(source, 'test2.textile'), result) # links with formatting converts normal in textile now source = u'''*[[this checklist|Troubleshooting]]* some text and *[[Tips n' Tricks]]* *[[link|http://otherlink.com]]* ''' result = u'''**[this checklist](Troubleshooting)** some text and **[Tips n' Tricks]** **[link](http://otherlink.com)** ''' assert_equal(f(source, 'test3.textile'), result)
def test_convert_markup(self): importer = GitHubWikiImporter() importer.github_wiki_url = 'https://github.com/a/b/wiki' importer.app = Mock() importer.app.url = '/p/test/wiki/' f = importer.convert_markup source = u'''Look at [[this page|Some Page]] More info at: [[MoreInfo]] [[Even More Info]] Our website is [[http://sf.net]]. '[[Escaped Tag]] [External link to the wiki page](https://github.com/a/b/wiki/Page) [External link](https://github.com/a/b/issues/1)''' # markdown should be untouched assert_equal(f(source, 'test.md'), source) assert_equal(f(u'h1. Hello', 't.textile').strip(), u'# Hello')
def test_convert_textile_no_leading_tabs(self): importer = GitHubWikiImporter() importer.github_wiki_url = 'https://github.com/a/b/wiki' importer.app = Mock() importer.app.url = '/p/test/wiki/' f = importer.convert_markup source = '''h1. Header 1 Some text 1. h2. Header 2 See [[Page]]''' result = '''# Header 1 Some text 1. ## Header 2 See [Page]''' assert_equal(f(source, 'test.textile').strip(), result)
def test_convert_textile_no_leading_tabs(self): importer = GitHubWikiImporter() importer.github_wiki_url = 'https://github.com/a/b/wiki' importer.app = Mock() importer.app.url = '/p/test/wiki/' f = importer.convert_markup source = u'''h1. Header 1 Some text 1. h2. Header 2 See [[Page]]''' result = u'''# Header 1 Some text 1. ## Header 2 See [Page]''' assert_equal(f(source, 'test.textile').strip(), result)
def test_convert_markup(self): importer = GitHubWikiImporter() importer.github_wiki_url = 'https://github.com/a/b/wiki' importer.app = Mock() importer.app.url = '/p/test/wiki/' f = importer.convert_markup source = u'''Look at [[this page|Some Page]] More info at: [[MoreInfo]] [[Even More Info]] Our website is [[http://sf.net]]. '[[Escaped Tag]] [External link to the wiki page](https://github.com/a/b/wiki/Page) [External link](https://github.com/a/b/issues/1)''' # markdown should be untouched assert_equal(f(source, 'test.md'), source) assert_equal(f(u'h1. Hello', 't.textile').strip(), u'# Hello')