forked from marqo-ai/marqo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_documentation.py
26 lines (22 loc) · 991 Bytes
/
test_documentation.py
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
26
import unittest
import pytest
import httpx
from marqo import marqo_docs
class TestDocumentation(unittest.TestCase):
def test_urls(self):
# Retrieve all public functions in the module
public_functions = [func for func in dir(marqo_docs)
if callable(getattr(marqo_docs, func)) and not func.startswith("_")]
# Verify all URLs return a 200 response
for func in public_functions:
with self.subTest(func=func):
url = getattr(marqo_docs, func)()
print(f"url: {url}")
response = httpx.get(url, follow_redirects=True)
response.raise_for_status()
self.assertFalse(
'404.html' in response.content.decode(), f"{func} URL returned a 404 response"
)
self.assertFalse(
'<title>Redirecting</title>' in response.content.decode(), f"{func} URL is a redirect"
)