本文整理汇总了Python中forgeimporters.github.wiki.GitHubWikiImporter类的典型用法代码示例。如果您正苦于以下问题:Python GitHubWikiImporter类的具体用法?Python GitHubWikiImporter怎么用?Python GitHubWikiImporter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GitHubWikiImporter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_convert_markup_with_mediawiki2markdown
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)
示例2: test_convert_markup_without_html2text
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)
示例3: test_convert_textile_special_tag
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)**')
示例4: test_convert_textile_special_tag_without_html2text
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)
示例5: test_convert_markup_with_amp_in_links
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)
示例6: test_set_available_pages
def test_set_available_pages(self):
importer = GitHubWikiImporter()
commit = Mock()
blobs = [Mock() for i in range(3)]
blobs[0].name = u'Home-42.md'
blobs[1].name = u'image.png'
blobs[2].name = u'code & fun.textile'
commit.tree.traverse.return_value = blobs
importer._set_available_pages(commit)
assert_equal(importer.available_pages, [u'Home 42', u'code & fun'])
示例7: test_has_wiki_repo
def test_has_wiki_repo(self, repo, rmtree, mkdtemp):
mkdtemp.return_value = 'fake path'
i = GitHubWikiImporter()
assert_equal(i.has_wiki_repo('fake url'), True)
repo.clone_from.assert_called_once_with(
'fake url', to_path='fake path', bare=True)
rmtree.assert_called_once_with('fake path')
def raise_error(*args, **kw):
raise git.GitCommandError('bam', 'bam', 'bam')
repo.clone_from.side_effect = raise_error
assert_equal(i.has_wiki_repo('fake url'), False)
示例8: test_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)
示例9: test_convert_markup
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')
示例10: test_convert_markup_textile
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)
示例11: test_convert_textile_no_leading_tabs
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)
示例12: test_convert_markup
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')
示例13: test_with_history_mediawiki
def test_with_history_mediawiki(self, md2mkm, upsert):
self.commit2.stats.files = {"Home.mediawiki": self.blob1}
self.commit2.tree = {"Home.mediawiki": self.blob1}
md2mkm.return_value = u'# test message'
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.convert_gollum_tags = Mock(return_value=u'# test message')
importer._with_history(self.commit2)
assert_equal(upsert.call_args_list, [call('Home')])
assert_equal(md2mkm.call_args_list, [call(u'# test message')])
示例14: test_without_history
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')])
示例15: test_gollum_page_links_case_insensitive
def test_gollum_page_links_case_insensitive(self):
i = GitHubWikiImporter()
i.available_pages = [u'Home 42', u'code & fun']
assert_equal(i.convert_gollum_tags(u'[[Code & Fun]]'), u'[code & fun]')
assert_equal(i.convert_gollum_tags(u'[[home-42]]'), u'[Home 42]')
assert_equal(i.convert_gollum_tags(u'[[Unknown]]'), u'[Unknown]')