-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_bug.py
More file actions
110 lines (93 loc) · 3.23 KB
/
Copy pathtest_bug.py
File metadata and controls
110 lines (93 loc) · 3.23 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/env python3
"""
버그 테스트 스크립트
"""
import sys
import traceback
def test_import():
"""백엔드 모듈 import 테스트"""
print("🧪 백엔드 모듈 import 테스트 중...")
try:
sys.path.append('./backend')
from main import app
print("✅ Import 성공")
return True
except Exception as e:
print(f"❌ Import 실패: {str(e)}")
print(f"📋 에러 상세:")
traceback.print_exc()
return False
def test_syntax():
"""구문 검사 테스트"""
print("\n🧪 구문 검사 테스트 중...")
try:
import py_compile
py_compile.compile('./backend/main.py', doraise=True)
print("✅ 구문 검사 통과")
return True
except Exception as e:
print(f"❌ 구문 오류 발견: {str(e)}")
return False
def test_api_endpoints():
"""API 엔드포인트 테스트"""
print("\n🧪 API 엔드포인트 테스트 중...")
try:
from fastapi.testclient import TestClient
sys.path.append('./backend')
from main import app
client = TestClient(app)
# 루트 엔드포인트 테스트
print(" - 루트 엔드포인트 테스트...")
response = client.get("/")
assert response.status_code == 200
print(" ✅ 루트 엔드포인트 성공")
# 헬스 체크 테스트
print(" - 헬스 체크 테스트...")
response = client.get("/health")
assert response.status_code == 200
print(" ✅ 헬스 체크 성공")
# 테스트 엔드포인트 (버그가 있는 엔드포인트)
print(" - 테스트 엔드포인트 테스트...")
response = client.get("/api/test")
print(f" 📊 응답 상태: {response.status_code}")
if response.status_code != 200:
print(f" ❌ 테스트 엔드포인트 실패")
return False
print(" ✅ 테스트 엔드포인트 성공")
return True
except Exception as e:
print(f"❌ API 테스트 실패: {str(e)}")
print(f"📋 에러 상세:")
traceback.print_exc()
return False
def main():
"""메인 테스트 실행"""
print("🚀 버그 테스트 시작")
print("=" * 50)
tests = [
("구문 검사", test_syntax),
("모듈 Import", test_import),
("API 엔드포인트", test_api_endpoints)
]
failed_tests = []
for test_name, test_func in tests:
try:
if not test_func():
failed_tests.append(test_name)
except Exception as e:
print(f"❌ {test_name} 테스트 중 예외 발생: {str(e)}")
failed_tests.append(test_name)
print("\n" + "=" * 50)
print("📊 테스트 결과 요약")
if failed_tests:
print(f"❌ 실패한 테스트: {len(failed_tests)}개")
for test in failed_tests:
print(f" - {test}")
print("\n🐛 버그가 발견되었습니다!")
return False
else:
print("✅ 모든 테스트 통과!")
return True
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1)