test_gemini_helpers.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. """V3-M0A: FakeGeminiVideoClient unit tests."""
  2. from __future__ import annotations
  3. from content_agent.interfaces import GeminiVideoClient
  4. from tests.gemini_helpers import (
  5. FakeGeminiVideoClient,
  6. fake_gemini_fail,
  7. fake_gemini_pool,
  8. fake_gemini_review,
  9. )
  10. def test_fake_gemini_default_returns_pool():
  11. client = FakeGeminiVideoClient()
  12. result = client.analyze({"platform_content_id": "c1"}, {}, {})
  13. assert result["fit_senior_50plus"] is True
  14. assert result["relevance_score"] == 0.85
  15. assert client.calls[0]["content"]["platform_content_id"] == "c1"
  16. def test_fake_gemini_by_content_id_routing():
  17. client = FakeGeminiVideoClient(
  18. result_by_content_id={"c1": fake_gemini_review(), "c2": fake_gemini_fail()}
  19. )
  20. assert client.analyze({"platform_content_id": "c1"}, {}, {})["relevance_score"] == 0.45
  21. assert client.analyze({"platform_content_id": "c2"}, {}, {})["status"] == "failed"
  22. assert client.analyze({"platform_content_id": "c3"}, {}, {})["relevance_score"] == 0.85
  23. def test_fake_gemini_records_calls_with_deepcopy():
  24. client = FakeGeminiVideoClient()
  25. first = client.analyze({"platform_content_id": "c1"}, {}, {})
  26. first["fit_senior_50plus"] = "mutated"
  27. second = client.analyze({"platform_content_id": "c1"}, {}, {})
  28. assert second["fit_senior_50plus"] is True
  29. assert len(client.calls) == 2
  30. def test_fake_gemini_conforms_to_protocol():
  31. client: GeminiVideoClient = FakeGeminiVideoClient()
  32. result = client.analyze({"platform_content_id": "c1"}, {"play_url": None}, {"name": "case"})
  33. assert isinstance(result, dict)
  34. assert fake_gemini_pool()["fit_senior_50plus"] is True