govon-runtime / scripts /final_api_check.py
umyunsang's picture
sync: scripts/ (verify_e2e_tool_calling.py)
769e684 verified
import os
import requests
def test_law():
oc = os.getenv("LAW_GO_KR_OC")
url = f"http://www.law.go.kr/DRF/lawSearch.do?target=law&query=민원&type=XML&OC={oc}"
try:
res = requests.get(url, timeout=10)
print(f"[LAW] Status: {res.status_code}")
if "μ‚¬μš©μž 정보 검증에 μ‹€νŒ¨" in res.text:
print("[LAW] ❌ IP 미승인 μƒνƒœ (λ“±λ‘ν•œ IPκ°€ λ°˜μ˜λ˜μ§€ μ•Šμ•˜κ±°λ‚˜ 닀름)")
elif "<law" in res.text:
print("[LAW] βœ… 인증 성곡! 데이터 μˆ˜μ§‘ κ°€λŠ₯")
else:
print(f"[LAW] ⚠️ 응닡 확인 ν•„μš” (λ‚΄μš© 일뢀): {res.text[:200]}")
except Exception as e:
print(f"[LAW] ❌ μ—λŸ¬: {e}")
def test_alio():
key = os.getenv("DATA_GO_KR_API_KEY")
# Decoding ν‚€ μ‚¬μš©
url = "https://apis.data.go.kr/1051000/public_inst/list"
params = {"serviceKey": key, "pageNo": 1, "numOfRows": 1, "resultType": "json"}
try:
res = requests.get(url, params=params, timeout=10)
print(f"[ALIO] Status: {res.status_code}")
if res.status_code == 200:
if "SERVICE_KEY_IS_NOT_REGISTERED" in res.text:
print("[ALIO] ❌ ν‚€ λ―Έν™œμ„± μƒνƒœ (동기화 λŒ€κΈ° 쀑)")
elif "INVALID_REQUEST_PARAMETER_ERROR" in res.text:
print("[ALIO] ❌ νŒŒλΌλ―Έν„° 였λ₯˜")
else:
try:
data = res.json()
# κ²°κ³Ό μ½”λ“œ 확인
res_code = data.get("response", {}).get("header", {}).get("resultCode")
if res_code == "00":
print("[ALIO] βœ… 인증 성곡! 데이터 μˆ˜μ§‘ κ°€λŠ₯")
else:
print(f"[ALIO] ❌ κ²°κ³Ό 였λ₯˜ (μ½”λ“œ: {res_code})")
except:
print(f"[ALIO] ⚠️ 비정상 응닡 (λ‚΄μš© 일뢀): {res.text[:200]}")
else:
print(f"[ALIO] ❌ HTTP 였λ₯˜: {res.status_code}")
except Exception as e:
print(f"[ALIO] ❌ μ—°κ²° μ—λŸ¬: {e}")
if __name__ == "__main__":
print("-" * 50)
print("πŸš€ API μ΅œμ’… μœ νš¨μ„± 검사 μ‹œμž‘")
test_law()
test_alio()
print("-" * 50)