Fail CSVAnswers persistence closed
This commit is contained in:
@@ -50,6 +50,9 @@ def test_full_stack_product_contract():
|
||||
assert {"analyze_csv", "get_analysis", "analyze_csv_upload_base64", "analyze_csv_file", "list_analyses"} <= skill_names
|
||||
analyze_schema = next(skill.input_schema for skill in card.skills if skill.name == "analyze_csv")
|
||||
assert set(analyze_schema["required"]) == {"analysis_id", "csv_text", "question"}
|
||||
assert analyze_schema["properties"]["analysis_id"]["maxLength"] == 128
|
||||
assert analyze_schema["properties"]["csv_text"]["maxLength"] == agent_module.MAX_CSV_BYTES
|
||||
assert analyze_schema["properties"]["question"]["maxLength"] == 500
|
||||
upload_schema = next(skill.input_schema for skill in card.skills if skill.name == "analyze_csv_file")
|
||||
assert upload_schema["properties"]["file"]["x-a2a-file-upload"]["max_bytes"] == agent_module.MAX_CSV_BYTES
|
||||
databases = card.runtime.platform_resources.databases
|
||||
@@ -60,7 +63,7 @@ def test_full_stack_product_contract():
|
||||
|
||||
|
||||
def test_success_reload_and_receipt_persist_locally(monkeypatch):
|
||||
monkeypatch.delenv("DATABASE_URL", raising=False)
|
||||
monkeypatch.setattr(agent_module, "_connect", lambda: None)
|
||||
_reset_local_state_for_tests()
|
||||
app = CsvAnswersStudioV1()
|
||||
|
||||
@@ -92,7 +95,7 @@ def test_malformed_csv_rejected_deterministically(monkeypatch):
|
||||
|
||||
|
||||
def test_browser_base64_bridge(monkeypatch):
|
||||
monkeypatch.delenv("DATABASE_URL", raising=False)
|
||||
monkeypatch.setattr(agent_module, "_connect", lambda: None)
|
||||
_reset_local_state_for_tests()
|
||||
app = CsvAnswersStudioV1()
|
||||
upload = {
|
||||
@@ -107,7 +110,7 @@ def test_browser_base64_bridge(monkeypatch):
|
||||
|
||||
|
||||
def test_mcp_tools_list_and_call(monkeypatch):
|
||||
monkeypatch.delenv("DATABASE_URL", raising=False)
|
||||
monkeypatch.setattr(agent_module, "_connect", lambda: None)
|
||||
_reset_local_state_for_tests()
|
||||
app = CsvAnswersStudioV1()
|
||||
server = MCPServer(app, context_builder=lambda skill_name: make_ctx(f"mcp-{skill_name}"))
|
||||
@@ -140,3 +143,26 @@ def test_mcp_tools_list_and_call(monkeypatch):
|
||||
"params": {"name": "get_analysis", "arguments": {"analysis_id": "studio-csv-v1"}},
|
||||
}))
|
||||
assert reopened["result"]["structuredContent"]["ok"] is True
|
||||
|
||||
|
||||
def test_database_unavailable_fails_closed(monkeypatch):
|
||||
def unavailable():
|
||||
raise RuntimeError("database unavailable")
|
||||
|
||||
monkeypatch.setattr(agent_module, "_connect", unavailable)
|
||||
app = CsvAnswersStudioV1()
|
||||
|
||||
result = run(
|
||||
app.invoke(
|
||||
"analyze_csv",
|
||||
make_ctx(),
|
||||
analysis_id="studio-csv-db-failure",
|
||||
csv_text=SUCCESS_CSV,
|
||||
question="Which month has the highest revenue?",
|
||||
)
|
||||
)
|
||||
|
||||
assert result.ok is False
|
||||
assert result.code == "database_error"
|
||||
assert result.saved is False
|
||||
assert "RuntimeError" not in (result.message or "")
|
||||
|
||||
Reference in New Issue
Block a user