-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
test_prod.py
executable file
·52 lines (39 loc) · 1.07 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
#!/usr/bin/env python3
"""A basic test suite to ensure that prod is loading correctly.
We use this in our deploy script to check the basic health of the site.
"""
import sys
import requests
URLS_200 = [
"/",
"/api/dictionaries/vacaspatyam/nara",
"/texts/",
"/texts/mahabharatam/1.1",
"/texts/mahabharatam/18.5",
"/tools/dictionaries/",
"/tools/dictionaries/apte/nara",
"/tools/dictionaries/mw/nara",
"/tools/dictionaries/shabdakalpadruma/nara",
"/tools/dictionaries/vacaspatyam/nara",
"/proofing/",
"/tools/dictionaries/",
]
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() -> bool:
ok = True
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}")
ok = False
return ok
if __name__ == "__main__":
ok = check_200()
if not ok:
sys.exit(1)