mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2026-01-02 05:44:32 +01:00
Fixing memory challenges, naming, testing mini-agi, smooth retrieval scaling (#166)
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import os
|
||||
from typing import Any, Dict
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
def test_make_request_and_assert() -> None:
|
||||
result = make_request_and_assert()
|
||||
print(result)
|
||||
expected_result = {"status": "OK"}
|
||||
error_message = f"AssertionError: Expected the output to be {expected_result}"
|
||||
print(error_message)
|
||||
assert result == expected_result, error_message
|
||||
|
||||
|
||||
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()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# test for the case when server is healthy
|
||||
test_make_request_and_assert()
|
||||
Reference in New Issue
Block a user