| 148 | # ============================================================================= |
| 149 | |
| 150 | class TestPromptBuilder: |
| 151 | |
| 152 | def setup_method(self): |
| 153 | self.config = ControlLayerConfig(total_tokens=800) |
| 154 | self.builder = PromptBuilder("You are a test assistant.", self.config) |
| 155 | |
| 156 | def test_prompt_contains_system(self): |
| 157 | prompt, _ = self.builder.build("Hello", []) |
| 158 | assert "You are a test assistant." in prompt |
| 159 | |
| 160 | def test_prompt_contains_user_input(self): |
| 161 | prompt, _ = self.builder.build("What is RAG?", []) |
| 162 | assert "What is RAG?" in prompt |
| 163 | |
| 164 | def test_constraints_appear_in_prompt(self): |
| 165 | prompt, _ = self.builder.build("Q", ["Use JSON only.", "No markdown."]) |
| 166 | assert "JSON only" in prompt |
| 167 | assert "No markdown" in prompt |
| 168 | |
| 169 | def test_mutation_hint_appears_when_provided(self): |
| 170 | prompt, _ = self.builder.build("Q", [], mutation_hint="Fix your JSON.") |
| 171 | assert "Correction note" in prompt |
| 172 | assert "Fix your JSON." in prompt |
| 173 | |
| 174 | def test_context_appears_when_provided(self): |
| 175 | prompt, _ = self.builder.build("Q", [], context="Relevant document text.") |
| 176 | assert "Relevant document text." in prompt |
| 177 | |
| 178 | def test_budget_is_returned(self): |
| 179 | _, budget = self.builder.build("Q", []) |
| 180 | assert isinstance(budget, TokenBudget) |
| 181 | assert budget.used() > 0 |
| 182 | |
| 183 | |
| 184 | # ============================================================================= |
nothing calls this directly
no outgoing calls
no test coverage detected