aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/content/tests
diff options
context:
space:
mode:
authorGravatar Hassan Abouelela <[email protected]>2022-08-14 04:44:57 +0200
committerGravatar Hassan Abouelela <[email protected]>2022-08-14 05:36:12 +0200
commitb4911d03faf8eecf5c4cced6f8036b0b2ef01d58 (patch)
treecc32c183b6894829dea32506eaf77e25ffa7e73f /pydis_site/apps/content/tests
parentImprove Tag Cropping (diff)
Move Tag URL To Property And Add Group
The URLs can be simply constructed using the other tag properties, so they were removed from the database in favor of a property. A group field was also added to support tags within groups. Signed-off-by: Hassan Abouelela <[email protected]>
Diffstat (limited to 'pydis_site/apps/content/tests')
-rw-r--r--pydis_site/apps/content/tests/test_utils.py6
-rw-r--r--pydis_site/apps/content/tests/test_views.py12
2 files changed, 9 insertions, 9 deletions
diff --git a/pydis_site/apps/content/tests/test_utils.py b/pydis_site/apps/content/tests/test_utils.py
index 89ef81c4..a5d5dcb4 100644
--- a/pydis_site/apps/content/tests/test_utils.py
+++ b/pydis_site/apps/content/tests/test_utils.py
@@ -112,7 +112,7 @@ class TagUtilsTests(TestCase):
@mock.patch.object(utils, "fetch_tags")
def test_static_fetch(self, fetch_mock: mock.Mock):
"""Test that the static fetch function is only called at most once during static builds."""
- tags = [models.Tag(name="Name", body="body", url="url")]
+ tags = [models.Tag(name="Name", body="body")]
fetch_mock.return_value = tags
result = utils.get_tags_static()
second_result = utils.get_tags_static()
@@ -159,8 +159,8 @@ class TagUtilsTests(TestCase):
result = utils.fetch_tags()
self.assertEqual([
- models.Tag(name="first_tag", body=bodies[0], url=f"{utils.TAG_URL_BASE}/first_tag.md"),
- models.Tag(name="second_tag", body=bodies[1], url=f"{utils.TAG_URL_BASE}/first_tag.md"),
+ models.Tag(name="first_tag", body=bodies[0]),
+ models.Tag(name="second_tag", body=bodies[1]),
], sorted(result, key=lambda tag: tag.name))
def test_get_real_tag(self):
diff --git a/pydis_site/apps/content/tests/test_views.py b/pydis_site/apps/content/tests/test_views.py
index a5867260..c4d3474e 100644
--- a/pydis_site/apps/content/tests/test_views.py
+++ b/pydis_site/apps/content/tests/test_views.py
@@ -196,7 +196,7 @@ class TagViewTests(django.test.TestCase):
def test_valid_tag_returns_200(self):
"""Test that a page is returned for a valid tag."""
- Tag.objects.create(name="example", body="This is the tag body.", url="URL")
+ Tag.objects.create(name="example", body="This is the tag body.")
response = self.client.get("/pages/tags/example/")
self.assertEqual(200, response.status_code)
self.assertIn("This is the tag body", response.content.decode("utf-8"))
@@ -216,7 +216,7 @@ class TagViewTests(django.test.TestCase):
Tag content here.
""")
- tag = Tag.objects.create(name="example", body=body, url="URL")
+ tag = Tag.objects.create(name="example", body=body)
response = self.client.get("/pages/tags/example/")
expected = {
"page_title": "example",
@@ -238,7 +238,7 @@ class TagViewTests(django.test.TestCase):
**This text is in bold**
""")
- Tag.objects.create(name="example", body=body, url="URL")
+ Tag.objects.create(name="example", body=body)
response = self.client.get("/pages/tags/example/")
content = response.content.decode("utf-8")
@@ -257,7 +257,7 @@ class TagViewTests(django.test.TestCase):
Tag body.
""")
- Tag.objects.create(name="example", body=body, url="URL")
+ Tag.objects.create(name="example", body=body)
response = self.client.get("/pages/tags/example/")
content = response.content.decode("utf-8")
@@ -273,7 +273,7 @@ class TagViewTests(django.test.TestCase):
---
""")
- Tag.objects.create(name="example", body=body, url="URL")
+ Tag.objects.create(name="example", body=body)
response = self.client.get("/pages/tags/example/")
self.assertEqual(
"Embed title",
@@ -285,7 +285,7 @@ class TagViewTests(django.test.TestCase):
"""Test hyperlinking of tags works as intended."""
filler_before, filler_after = "empty filler text\n\n", "more\nfiller"
body = filler_before + "`!tags return`" + filler_after
- Tag.objects.create(name="example", body=body, url="URL")
+ Tag.objects.create(name="example", body=body)
other_url = reverse("content:tag", kwargs={"name": "return"})
response = self.client.get("/pages/tags/example/")