aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/content/tests
diff options
context:
space:
mode:
authorGravatar Hassan Abouelela <[email protected]>2022-08-23 12:54:16 +0400
committerGravatar Hassan Abouelela <[email protected]>2022-08-23 12:57:06 +0400
commitefe784fe8a6c23248c6698aefab8bf54c5c85900 (patch)
treeaeb4f58c274b1938182862eafc1275be5fadbbc3 /pydis_site/apps/content/tests
parentMerge branch 'main' into bot-tags (diff)
Support Hyperlinked Tag Group Replacement
Signed-off-by: Hassan Abouelela <[email protected]>
Diffstat (limited to 'pydis_site/apps/content/tests')
-rw-r--r--pydis_site/apps/content/tests/test_views.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/pydis_site/apps/content/tests/test_views.py b/pydis_site/apps/content/tests/test_views.py
index 658ac2cc..da06fc80 100644
--- a/pydis_site/apps/content/tests/test_views.py
+++ b/pydis_site/apps/content/tests/test_views.py
@@ -358,6 +358,34 @@ class TagViewTests(django.test.TestCase):
response.context.get("page")
)
+ def test_hyperlinked_group(self):
+ """Test hyperlinking with a group works as intended."""
+ Tag.objects.create(
+ name="example", body="!tags group-name grouped-tag", last_commit=self.commit
+ )
+ Tag.objects.create(name="grouped-tag", group="group-name")
+
+ other_url = reverse("content:tag", kwargs={"location": "group-name/grouped-tag"})
+ response = self.client.get("/pages/tags/example/")
+ self.assertEqual(
+ markdown.markdown(f"[!tags group-name grouped-tag]({other_url})"),
+ response.context.get("page")
+ )
+
+ def test_hyperlinked_extra_text(self):
+ """Test hyperlinking when a tag is followed by extra, unrelated text."""
+ Tag.objects.create(
+ name="example", body="!tags other unrelated text", last_commit=self.commit
+ )
+ Tag.objects.create(name="other")
+
+ other_url = reverse("content:tag", kwargs={"location": "other"})
+ response = self.client.get("/pages/tags/example/")
+ self.assertEqual(
+ markdown.markdown(f"[!tags other]({other_url}) unrelated text"),
+ response.context.get("page")
+ )
+
def test_tag_root_page(self):
"""Test the root tag page which lists all tags."""
Tag.objects.create(name="tag-1", last_commit=self.commit)