From 2227c8d42846d45e0529dfe9f56e24f938e60d86 Mon Sep 17 00:00:00 2001 From: jchristgit Date: Sat, 15 Jul 2023 15:05:29 +0200 Subject: Fix duplicated links in resources (#1034) * Add test for duplicate links * Remove duplicated links Closes #1022. Closes #1023. Closes #1024. --- .../apps/resources/tests/test_resource_data.py | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 pydis_site/apps/resources/tests/test_resource_data.py (limited to 'pydis_site/apps/resources/tests') 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", + ) -- cgit v1.2.3