forked from ambuda-org/ambuda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_prod.py
executable file
·58 lines (43 loc) · 1.19 KB
/
test_prod.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python3
"""A basic test suite to ensure that prod is loading correctly."""
import requests
URLS_200 = [
"/",
"/api/dictionaries/vacaspatyam/nara",
"/tools/dictionaries/",
"/tools/dictionaries/apte/nara",
"/tools/dictionaries/mw/nara",
"/tools/dictionaries/shabdakalpadruma/nara",
"/tools/dictionaries/vacaspatyam/nara",
"/texts/",
"/texts/mahabharatam/1.1",
"/texts/mahabharatam/18.5",
]
URLS_404 = [
"/dictionaries/unknown",
"/texts/mahabharatam/unknown",
"/texts/unknown",
]
def _ok(s) -> str:
print(f"\033[92m[ OK ] {s}\033[0m")
def _fail(s) -> str:
print(f"\033[91m[ FAIL ] {s}\033[0m")
def check_200():
for path in URLS_200:
url = f"https://ambuda.org{path}"
resp = requests.get(url)
if resp.status_code == 200:
_ok(f"HTTP 200 {url}")
else:
_fail(f"HTTP 200 {url}")
def check_404():
for path in URLS_404:
url = f"https://ambuda.org{path}"
resp = requests.get(url)
if resp.status_code == 404:
_ok(f"HTTP 404 {url}")
else:
_fail(f"HTTP 404 {url}")
if __name__ == "__main__":
check_200()
check_404()