diff --git a/tests/test_captioner.py b/tests/test_captioner.py index 8aab057..1911f7d 100644 --- a/tests/test_captioner.py +++ b/tests/test_captioner.py @@ -5,7 +5,7 @@ import tempfile import unittest from unittest.mock import Mock -from scene_search.captioner import OllamaCaptioner +from scene_search.captioner import OllamaCaptioner, ensure_caption_prompt_file class OllamaCaptionerTests(unittest.TestCase): @@ -30,6 +30,18 @@ class OllamaCaptionerTests(unittest.TestCase): self.assertEqual(payload["messages"][0]["role"], "user") self.assertTrue(payload["messages"][0]["images"][0]) + def test_prompt_file_is_created_once_and_remains_editable(self) -> None: + with tempfile.TemporaryDirectory() as tmp: + prompt_path = Path(tmp) / "caption_prompt.txt" + first = ensure_caption_prompt_file(prompt_path) + self.assertTrue(prompt_path.is_file()) + self.assertTrue(first) + + prompt_path.write_text("My test prompt\n", encoding="utf-8") + second = ensure_caption_prompt_file(prompt_path) + + self.assertEqual(second, "My test prompt") + if __name__ == "__main__": unittest.main()