aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/resources/tests
diff options
context:
space:
mode:
authorGravatar jchristgit <[email protected]>2023-07-15 15:05:29 +0200
committerGravatar GitHub <[email protected]>2023-07-15 14:05:29 +0100
commit2227c8d42846d45e0529dfe9f56e24f938e60d86 (patch)
treecc0d58fed799c01e2a9fe627ffc5c37cb1851e24 /pydis_site/apps/resources/tests
parentFix empty <h1> tag on page listing (#1033) (diff)
Fix duplicated links in resources (#1034)
* Add test for duplicate links * Remove duplicated links Closes #1022. Closes #1023. Closes #1024.
Diffstat (limited to 'pydis_site/apps/resources/tests')
-rw-r--r--pydis_site/apps/resources/tests/test_resource_data.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/pydis_site/apps/resources/tests/test_resource_data.py b/pydis_site/apps/resources/tests/test_resource_data.py
new file mode 100644
index 00000000..3a96e8b9
--- /dev/null
+++ b/pydis_site/apps/resources/tests/test_resource_data.py
@@ -0,0 +1,25 @@
+import yaml
+from django.test import TestCase
+
+from pydis_site.apps.resources.views import RESOURCES_PATH
+
+
+class TestResourceData(TestCase):
+ """Test data validity of resources."""
+
+ def test_no_duplicate_links(self):
+ """Test that there are no duplicate links in each resource."""
+ for path in RESOURCES_PATH.rglob('*.yaml'):
+ with self.subTest(resource=path.stem):
+ content = yaml.safe_load(path.read_text())
+ url_links = tuple(item['url'] for item in content.get('urls', ()))
+ if 'title_url' in content:
+ all_links = url_links + (content['title_url'],)
+ else:
+ all_links = url_links
+
+ self.assertCountEqual(
+ all_links,
+ set(all_links),
+ msg="One or more links are duplicated on the resource",
+ )