blob: d96d840ef2ac0eaff29214c4e615f49812ae88ce (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
import yaml
from django.test import TestCase
from pydis_site.apps.resources.apps 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",
)
|