| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- """V3-M0A: FakeGeminiVideoClient unit tests."""
- from __future__ import annotations
- from content_agent.interfaces import GeminiVideoClient
- from tests.gemini_helpers import (
- FakeGeminiVideoClient,
- fake_gemini_fail,
- fake_gemini_pool,
- fake_gemini_review,
- )
- def test_fake_gemini_default_returns_pool():
- client = FakeGeminiVideoClient()
- result = client.analyze({"platform_content_id": "c1"}, {}, {})
- assert result["fit_senior_50plus"] is True
- assert result["relevance_score"] == 0.85
- assert client.calls[0]["content"]["platform_content_id"] == "c1"
- def test_fake_gemini_by_content_id_routing():
- client = FakeGeminiVideoClient(
- result_by_content_id={"c1": fake_gemini_review(), "c2": fake_gemini_fail()}
- )
- assert client.analyze({"platform_content_id": "c1"}, {}, {})["relevance_score"] == 0.45
- assert client.analyze({"platform_content_id": "c2"}, {}, {})["status"] == "failed"
- assert client.analyze({"platform_content_id": "c3"}, {}, {})["relevance_score"] == 0.85
- def test_fake_gemini_records_calls_with_deepcopy():
- client = FakeGeminiVideoClient()
- first = client.analyze({"platform_content_id": "c1"}, {}, {})
- first["fit_senior_50plus"] = "mutated"
- second = client.analyze({"platform_content_id": "c1"}, {}, {})
- assert second["fit_senior_50plus"] is True
- assert len(client.calls) == 2
- def test_fake_gemini_conforms_to_protocol():
- client: GeminiVideoClient = FakeGeminiVideoClient()
- result = client.analyze({"platform_content_id": "c1"}, {"play_url": None}, {"name": "case"})
- assert isinstance(result, dict)
- assert fake_gemini_pool()["fit_senior_50plus"] is True
|