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]]", '
', ], [ [Character(name="Blimm")], "[[Char/Lun]]", '', ], [ [Character(name="Blimm"), Character(name="Lun")], "[[Char/Lun]] and [[Char/Blimm]]", '', ], [ [NPC(name="Frank")], "[[NPC/Frank]]", '', ], [ [NPC(name="Frank"), Character(name="Blimm")], "[[Char/Blimm]] and [[NPC/Frank]]", '', ], ], ) @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