Spaces:
Running
Running
| """Tests for prompt templates.""" | |
| from src.prompts import ( | |
| DETECTION_TEMPLATES, | |
| SPACE_DEBRIS_EXAMPLES, | |
| PromptTemplate, | |
| build_detect_prompt, | |
| build_grounding_prompt, | |
| get_example_prompts, | |
| ) | |
| class TestPromptTemplate: | |
| def test_template_fields(self): | |
| t = DETECTION_TEMPLATES[0] | |
| assert isinstance(t, PromptTemplate) | |
| assert t.name | |
| assert t.template | |
| assert t.description | |
| assert t.category | |
| def test_template_has_placeholder(self): | |
| for t in DETECTION_TEMPLATES: | |
| assert "{" in t.template or "Detect" in t.template | |
| class TestBuildPrompts: | |
| def test_build_detect_prompt_single(self): | |
| prompt = build_detect_prompt(["debris"]) | |
| assert "debris" in prompt | |
| assert "Locate" in prompt | |
| def test_build_detect_prompt_multiple(self): | |
| prompt = build_detect_prompt(["debris", "antenna", "panel"]) | |
| assert "</c>" in prompt | |
| assert "debris" in prompt | |
| assert "antenna" in prompt | |
| def test_build_grounding_prompt_multi(self): | |
| prompt = build_grounding_prompt("solar panel") | |
| assert "solar panel" in prompt | |
| assert "all the instances" in prompt | |
| def test_build_grounding_prompt_single(self): | |
| prompt = build_grounding_prompt("spacecraft", single=True) | |
| assert "spacecraft" in prompt | |
| assert "single instance" in prompt | |
| class TestExamples: | |
| def test_examples_not_empty(self): | |
| assert len(SPACE_DEBRIS_EXAMPLES) > 0 | |
| def test_example_structure(self): | |
| for ex in SPACE_DEBRIS_EXAMPLES: | |
| assert "phrase" in ex | |
| assert "prompt" in ex | |
| assert "description" in ex | |
| def test_get_example_prompts(self): | |
| prompts = get_example_prompts() | |
| assert len(prompts) == len(SPACE_DEBRIS_EXAMPLES) | |
| for p in prompts: | |
| assert len(p) == 1 | |
| assert isinstance(p[0], str) | |
| assert len(p[0]) > 0 | |