Skip to content

Commit 79ffbcc

Browse files
committed
address PR review feedback
merge duplicate prompt tests into one, fix misplaced docstring, loosen brittle double-space assertion to just check location line content, add docstring to test_model_config_values explaining why values are pinned
1 parent 58e915b commit 79ffbcc

2 files changed

Lines changed: 12 additions & 19 deletions

File tree

backend/tests/test_constants.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,12 @@ def test_vertex_ai_datastore_uri_extraction(self, mock_path):
106106

107107

108108
def test_model_config_values():
109-
"""Verify hard-coded model config values are sensible."""
109+
"""Pin model config values that affect legal advice quality.
110+
111+
Low temperature and top_p produce consistent, citation-heavy responses
112+
rather than creative ones. Changing these accidentally could degrade the
113+
quality of legal guidance, so this test should break loudly.
114+
"""
110115
from tenantfirstaid.constants import SINGLETON
111116

112117
assert SINGLETON.MODEL_TEMPERATURE == 0.1

backend/tests/test_langchain_chat_manager.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,13 @@
1010
from tenantfirstaid.location import UsaState
1111

1212

13-
def test_system_prompt_includes_location(oregon_state, portland_city):
14-
state = oregon_state
15-
city = portland_city
16-
17-
chat_manager = LangChainChatManager()
18-
13+
def test_system_prompt_includes_city_and_state(oregon_state, portland_city):
1914
"""Test that system prompt includes user location."""
20-
prompt = chat_manager._prepare_system_prompt(city, state)
21-
22-
assert "Portland OR" in prompt
23-
24-
25-
def test_prepare_system_prompt_includes_city_state(oregon_state, portland_city):
26-
state = oregon_state
27-
city = portland_city
2815
chat_manager = LangChainChatManager()
16+
prompt = chat_manager._prepare_system_prompt(portland_city, oregon_state)
2917

30-
instructions = chat_manager._prepare_system_prompt(city, state)
31-
assert f"The user is in {city.capitalize()} {state.upper()}." in instructions
18+
assert "Portland" in prompt
19+
assert "OR" in prompt
3220

3321

3422
def test_tools_include_rag_retrieval():
@@ -43,11 +31,11 @@ def test_tools_include_rag_retrieval():
4331

4432

4533
def test_system_prompt_no_city(oregon_state):
34+
"""When no city is provided, the location line should mention state only."""
4635
chat_manager = LangChainChatManager()
4736
prompt = chat_manager._prepare_system_prompt(None, oregon_state)
37+
assert "The user is in" in prompt
4838
assert "OR" in prompt
49-
# City portion should be empty.
50-
assert "The user is in OR." in prompt
5139

5240

5341
def test_system_prompt_state_only():

0 commit comments

Comments
 (0)