gaia-final-assignment / tests /test_gaia_client.py
ykumar2020's picture
Publish verified modular GAIA agent source
c641d5f verified
Raw
History Blame Contribute Delete
1.43 kB
from pathlib import Path
from config import Settings
from gaia_client import GaiaClient
class Response:
headers = {"content-type": "application/json"}
content = b"{}"
def raise_for_status(self):
return None
def json(self):
return {"score": 100}
class Session:
def __init__(self):
self.post_call = None
def mount(self, *args):
pass
def post(self, url, json, timeout):
self.post_call = (url, json, timeout)
return Response()
def settings(tmp_path: Path) -> Settings:
return Settings(
api_url="https://example.test",
hf_token=None,
model_id="model",
vision_model_id="vision",
inference_provider=None,
asr_model_id="asr",
cache_dir=tmp_path,
request_timeout=10,
retries=1,
backoff_seconds=0,
max_steps=2,
use_cache=True,
stockfish_path=None,
)
def test_submission_contract_is_unchanged(tmp_path):
session = Session()
client = GaiaClient(settings(tmp_path), session=session)
answer = {"task_id": "id", "submitted_answer": "A"}
assert client.submit("user", "https://code", [answer]) == {"score": 100}
url, payload, _ = session.post_call
assert url == "https://example.test/submit"
assert payload == {
"username": "user",
"agent_code": "https://code",
"answers": [answer],
}