Files
VianoBugAnalysis/tests/test_connection_test.py

25 lines
1.1 KiB
Python

import json
import pytest
import viano_bug_analysis.connection_test as connection
from viano_bug_analysis.llm import ProviderResponse, ProviderUnavailable
from test_llm_gateway import Adapter, provider
from viano_bug_analysis.llm import GatewayConfig, LLMGateway
@pytest.mark.parametrize("response,status", [
(ProviderResponse({"answer": "ok"}, "fixture", 1, 1), "SUCCESS"),
(ProviderUnavailable("LLM_HTTP_TEMPORARY", http_status=503), "UNAVAILABLE"),
])
def test_one_round_no_workspace_files(tmp_path, monkeypatch, capsys, response, status):
adapter = Adapter({"first": response})
gateway = LLMGateway(GatewayConfig((provider(),)), {"fixture": adapter})
monkeypatch.setattr(connection, "preflight", lambda path: gateway)
monkeypatch.chdir(tmp_path)
exit_code = connection.main([])
result = json.loads(capsys.readouterr().out)
assert result["status"] == status
assert exit_code == (0 if status == "SUCCESS" else 2)
assert adapter.calls == ["first"] and not list(tmp_path.iterdir())
if status == "UNAVAILABLE":
assert result["attempts"][0]["http_status"] == 503