本文整理汇总了Python中taiga.mdrender.service.render函数的典型用法代码示例。如果您正苦于以下问题:Python render函数的具体用法?Python render怎么用?Python render使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了render函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_proccessor_invalid_type_reference
def test_proccessor_invalid_type_reference():
with patch("taiga.mdrender.extensions.references.get_instance_by_ref") as mock:
instance = mock.return_value
instance.content_type.model = "other"
instance.content_object.subject = "test"
result = render(dummy_project, "**#4**")
assert result == "<p><strong>#4</strong></p>"
示例2: test_proccessor_valid_issue_reference
def test_proccessor_valid_issue_reference():
with patch("taiga.mdrender.extensions.references.get_instance_by_ref") as mock:
instance = mock.return_value
instance.content_type.model = "issue"
instance.content_object.subject = "test"
result = render(dummy_project, "**#2**")
expected_result = '<p><strong><a alt="test" class="reference issue" href="/#/project/test/issues/2" title="test">#2</a></strong></p>'
assert result == expected_result
示例3: test_proccessor_valid_us_reference
def test_proccessor_valid_us_reference():
with patch("taiga.mdrender.extensions.references.get_instance_by_ref") as mock:
instance = mock.return_value
instance.content_type.model = "userstory"
instance.content_object.subject = "test"
result = render(dummy_project, "**#1**")
expected_result = '<p><strong><a alt="test" class="reference user-story" href="http://localhost:9001/project/test/us/1" title="test">#1</a></strong></p>'
assert result == expected_result
示例4: test_proccessor_valid_task_reference
def test_proccessor_valid_task_reference():
with patch("taiga.mdrender.extensions.references.get_instance_by_ref") as mock:
instance = mock.return_value
instance.content_type.model = "task"
instance.content_object.subject = "test"
result = render(dummy_project, "**#3**")
expected_result = '<p><strong><a class="reference task" href="http://localhost:9001/project/test/task/3" title="#3 test">#3</a></strong></p>'
assert result == expected_result
示例5: test_mentions_valid_username_with_dash
def test_mentions_valid_username_with_dash():
with patch("taiga.mdrender.extensions.mentions.get_user_model") as get_user_model_mock:
dummy_uuser = MagicMock()
dummy_uuser.get_full_name.return_value = "Ginny Weasley"
get_user_model_mock.return_value.objects.get = MagicMock(return_value=dummy_uuser)
result = render(dummy_project, "text @super-ginny text")
get_user_model_mock.return_value.objects.get.assert_called_with(username="super-ginny")
assert result == ('<p>text <a class="mention" href="http://localhost:9001/profile/super-ginny" '
'title="Ginny Weasley">@super-ginny</a> text</p>')
示例6: test_mentions_valid_username_with_points
def test_mentions_valid_username_with_points():
with patch("taiga.mdrender.extensions.mentions.get_user_model") as get_user_model_mock:
dummy_uuser = MagicMock()
dummy_uuser.get_full_name.return_value = "Luna Lovegood"
get_user_model_mock.return_value.objects.get = MagicMock(return_value=dummy_uuser)
result = render(dummy_project, "text @luna.lovegood text")
get_user_model_mock.return_value.objects.get.assert_called_with(username="luna.lovegood")
assert result == ('<p>text <a class="mention" href="http://localhost:9001/profile/luna.lovegood" '
'title="Luna Lovegood">@luna.lovegood</a> text</p>')
示例7: test_mentions_valid_username
def test_mentions_valid_username():
with patch("taiga.mdrender.extensions.mentions.get_user_model") as get_user_model_mock:
dummy_uuser = MagicMock()
dummy_uuser.get_full_name.return_value = "Hermione Granger"
get_user_model_mock.return_value.objects.get = MagicMock(return_value=dummy_uuser)
result = render(dummy_project, "text @hermione text")
get_user_model_mock.return_value.objects.get.assert_called_with(username="hermione")
assert result == ('<p>text <a class="mention" href="http://localhost:9001/profile/hermione" '
'title="Hermione Granger">@hermione</a> text</p>')
示例8: test_render_reference_links
def test_render_reference_links():
expected_result = "<p>An <a href=\"http://example.com/\" target=\"_blank\" title=\"Title\">example</a> of reference link</p>"
source = "An [example][id] of reference link\n [id]: http://example.com/ \"Title\""
assert render(dummy_project, source) == expected_result
示例9: test_render_wikilink_relative_to_absolute
def test_render_wikilink_relative_to_absolute():
expected_result = "<p><a href=\"http://localhost:9001/project/test/\">test project</a></p>"
assert render(dummy_project, "[test project](/project/test/)") == expected_result
示例10: test_render_triple_quote_code
def test_render_triple_quote_code():
expected_result = "<div class=\"codehilite\"><pre><span class=\"n\">print</span><span class=\"p\">(</span><span class=\"s\">"test"</span><span class=\"p\">)</span>\n</pre></div>"
assert render(dummy_project, "```\nprint(\"test\")\n```") == expected_result
示例11: test_render_triple_quote_and_lang_code
def test_render_triple_quote_and_lang_code():
expected_result = '<div class="codehilite"><pre><span></span><span class="k">print</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>\n</pre></div>'
assert render(dummy_project, "```python\nprint(\"test\")\n```") == expected_result
示例12: test_render_relative_image
def test_render_relative_image():
assert render(dummy_project, "![test](test.png)") == "<p><img alt=\"test\" src=\"test.png\"></p>"
示例13: test_render_url_automail
def test_render_url_automail():
expected_result = "<p>Test the <a href=\"mailto:[email protected]\" target=\"_blank\">[email protected]</a> automail</p>"
source = "Test the [email protected] automail"
assert render(dummy_project, source) == expected_result
示例14: test_proccessor_valid_email
def test_proccessor_valid_email():
result = render(dummy_project, "**[email protected]**")
expected_result = "<p><strong><a href=\"mailto:[email protected]\" target=\"_blank\">[email protected]</a></strong></p>"
assert result == expected_result
示例15: test_proccessor_invalid_user_mention
def test_proccessor_invalid_user_mention():
result = render(dummy_project, "**@notvaliduser**")
assert result == '<p><strong>@notvaliduser</strong></p>'