mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-27 19:04:25 +01:00
Add "Simple web server" challenge (#74)
Co-authored-by: Silen Naihin <silen.naihin@gmail.com>
This commit is contained in:
27
agbenchmark/challenges/code/d3/custom_python/api_tests.py
Normal file
27
agbenchmark/challenges/code/d3/custom_python/api_tests.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import os
|
||||
from typing import Any, Dict
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
def make_assertion() -> None:
|
||||
if os.environ.get("MOCK_TEST", "False").lower() == "true":
|
||||
mock_response = Mock(requests.Response)
|
||||
mock_response.status_code = 200
|
||||
mock_response.json.return_value = {"status": "OK"}
|
||||
|
||||
with patch("requests.get", return_value=mock_response):
|
||||
make_request_and_assert()
|
||||
else:
|
||||
make_request_and_assert()
|
||||
|
||||
|
||||
def make_request_and_assert() -> Dict[str, Any]:
|
||||
response = requests.get("http://localhost:8079/health")
|
||||
if response.status_code != 200:
|
||||
raise AssertionError(
|
||||
f"Expected status code 200, but got {response.status_code}"
|
||||
)
|
||||
|
||||
return response.json()
|
||||
Reference in New Issue
Block a user