aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/api/tests
diff options
context:
space:
mode:
authorGravatar Mark <[email protected]>2021-04-19 00:02:48 -0700
committerGravatar GitHub <[email protected]>2021-04-19 00:02:48 -0700
commit8cd9e3b3bc307dd6f586bbb789d96a13228bf245 (patch)
tree8baba14d03013fa3155ba5a93d8b1c92d868e92d /pydis_site/apps/api/tests
parentMerge pull request #472 from python-discord/ks123/ghcr-token-to-github (diff)
parentMerge branch 'main' into doc-validator (diff)
Merge pull request #373 from Numerlor/doc-validator
Add a validator for documentation package names and base urls.
Diffstat (limited to 'pydis_site/apps/api/tests')
-rw-r--r--pydis_site/apps/api/tests/test_documentation_links.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/pydis_site/apps/api/tests/test_documentation_links.py b/pydis_site/apps/api/tests/test_documentation_links.py
index e560a2fd..39fb08f3 100644
--- a/pydis_site/apps/api/tests/test_documentation_links.py
+++ b/pydis_site/apps/api/tests/test_documentation_links.py
@@ -60,7 +60,7 @@ class DetailLookupDocumentationLinkAPITests(APISubdomainTestCase):
def setUpTestData(cls):
cls.doc_link = DocumentationLink.objects.create(
package='testpackage',
- base_url='https://example.com',
+ base_url='https://example.com/',
inventory_url='https://example.com'
)
@@ -108,6 +108,17 @@ class DetailLookupDocumentationLinkAPITests(APISubdomainTestCase):
self.assertEqual(response.status_code, 400)
+ def test_create_invalid_package_name_returns_400(self):
+ test_cases = ("InvalidPackage", "invalid package", "i\u0150valid")
+ for case in test_cases:
+ with self.subTest(package_name=case):
+ body = self.doc_json.copy()
+ body['package'] = case
+ url = reverse('bot:documentationlink-list', host='api')
+ response = self.client.post(url, data=body)
+
+ self.assertEqual(response.status_code, 400)
+
class DocumentationLinkCreationTests(APISubdomainTestCase):
def setUp(self):
@@ -115,7 +126,7 @@ class DocumentationLinkCreationTests(APISubdomainTestCase):
self.body = {
'package': 'example',
- 'base_url': 'https://example.com',
+ 'base_url': 'https://example.com/',
'inventory_url': 'https://docs.example.com'
}