"""Live Fireworks integration test (opt-in, needs a real key). Validates that the configured FIREWORKS_MODEL slug (default accounts/fireworks/models/deepseek-v4-pro) actually works end to end and returns JSON the reviewer can parse. Skipped automatically when FIREWORKS_API_KEY is unset, so the mocked suite and CI stay offline. Run just this: ``pytest -m live`` """ from __future__ import annotations import os import pytest from dotenv import load_dotenv # Ensure .env is loaded so the skip guard and Config both see the real key. load_dotenv() from app.config import Config # noqa: E402 from app.reviewer import Reviewer # noqa: E402 pytestmark = pytest.mark.live @pytest.mark.skipif( not os.getenv("FIREWORKS_API_KEY"), reason="FIREWORKS_API_KEY not set; live Fireworks test skipped", ) def test_live_fireworks_review_roundtrip() -> None: cfg = Config() assert cfg.FIREWORKS_API_KEY, "expected a real Fireworks key from .env" reviewer = Reviewer(cfg) pr = { "number": 1, "title": "Add divide helper", "author": "octocat", "owner": "Sea-Haven-Industries", "repo": "sandbox", "body": "Adds a small division helper.", } diff = ( "diff --git a/calc.py b/calc.py\n" "new file mode 100644\n" "--- /dev/null\n" "+++ b/calc.py\n" "@@ -0,0 +1,2 @@\n" "+def divide(a, b):\n" "+ return a / b\n" ) result = reviewer.review(pr, diff) # The response must be parseable JSON shaped like a review. assert isinstance(result, dict) assert "summary" in result assert "_body_markdown" in result assert result["_body_markdown"].startswith("**Summary:**") # recommended_event, when present, must be one of the allowed values. if result.get("recommended_event"): assert result["recommended_event"] in { "COMMENT", "APPROVE", "REQUEST_CHANGES", }