49 lines
1.3 KiB
Python
49 lines
1.3 KiB
Python
|
import pytest
|
||
|
import markdown
|
||
|
from guild_md.entity_links import GuildLinkExtension
|
||
|
from guild.models import NPC, Character
|
||
|
|
||
|
|
||
|
@pytest.mark.parametrize(
|
||
|
["objs", "md", "html"],
|
||
|
[
|
||
|
[
|
||
|
[],
|
||
|
"",
|
||
|
"",
|
||
|
],
|
||
|
[
|
||
|
[Character(name="Blimm")],
|
||
|
"[[Char/Blimm]]",
|
||
|
'<p><a href="/characters/1/">Blimm</a></p>',
|
||
|
],
|
||
|
[
|
||
|
[Character(name="Blimm")],
|
||
|
"[[Char/Lun]]",
|
||
|
'<p><a class="invalid-url" href="">Lun</a></p>',
|
||
|
],
|
||
|
[
|
||
|
[Character(name="Blimm"), Character(name="Lun")],
|
||
|
"[[Char/Lun]] and [[Char/Blimm]]",
|
||
|
'<p><a href="/characters/2/">Lun</a> and <a href="/characters/1/">Blimm</a></p>',
|
||
|
],
|
||
|
[
|
||
|
[NPC(name="Frank")],
|
||
|
"[[NPC/Frank]]",
|
||
|
'<p><a href="/npcs/1/">Frank</a></p>',
|
||
|
],
|
||
|
[
|
||
|
[NPC(name="Frank"), Character(name="Blimm")],
|
||
|
"[[Char/Blimm]] and [[NPC/Frank]]",
|
||
|
'<p><a href="/characters/1/">Blimm</a> and <a href="/npcs/1/">Frank</a></p>',
|
||
|
],
|
||
|
],
|
||
|
)
|
||
|
@pytest.mark.django_db
|
||
|
def test_link_conversion(objs, md, html):
|
||
|
for obj in objs:
|
||
|
obj.save()
|
||
|
|
||
|
output = markdown.markdown(md, extensions=[GuildLinkExtension()])
|
||
|
assert output == html
|