-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_api.py
More file actions
40 lines (31 loc) · 1.25 KB
/
test_api.py
File metadata and controls
40 lines (31 loc) · 1.25 KB
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
import sys
import os
def test_health_check():
"""Просто проверяем что файлы существуют"""
if not os.path.exists("backend/main.py"):
print("backend/main.py not found")
return False
# Да, мне лень прописывать тесты апи
# И вообще Дейкстра сказал: "Тестирование программ может показать наличие ошибок, но никогда не покажет их отсутствие"
try:
with open("backend/main.py", "r", encoding="utf-8") as f:
content = f.read()
checks = [
'@app.get("/")',
'async def health_check',
'def health_check',
'GET /"'
]
found = any(check in content for check in checks)
if found:
print("Health check endpoint found in code")
return True
else:
print("Health check endpoint not found in code")
return False
except Exception as e:
print(f"Error reading main.py: {e}")
return False
if __name__ == "__main__":
success = test_health_check()
sys.exit(0 if success else 1)