@@ -34,13 +34,45 @@ def test_get_generative_answer_success(client, mocker, mock_response):
3434 "aiModel" : model ,
3535 "chatHistory" : [],
3636 "temperature" : 0.7 ,
37+ "headerPrompt" : "" ,
38+ "footerPrompt" : "" ,
3739 }
3840 client ._mock_httpx_instance .request .assert_called_once_with (
3941 method = "POST" , url = "/answer" , json = expected_payload , params = None
4042 )
4143 assert result == expected_response
4244
4345
46+ def test_generate_answer_with_prompts (client , mocker , mock_response ):
47+ """Test get_generative_answer with header and footer prompts."""
48+ query = "What is Moorcheh?"
49+ header = "You are a helpful assistant."
50+ footer = "Answer concisely."
51+
52+ expected_response = {
53+ "answer" : "Moorcheh is great." ,
54+ "model" : "claude" ,
55+ "contextCount" : 1 ,
56+ "query" : query ,
57+ }
58+ mock_resp = mock_response (200 , json_data = expected_response )
59+ client ._mock_httpx_instance .request .return_value = mock_resp
60+
61+ client .answer .generate (
62+ namespace = TEST_NAMESPACE ,
63+ query = query ,
64+ header_prompt = header ,
65+ footer_prompt = footer ,
66+ )
67+
68+ client ._mock_httpx_instance .request .assert_called_once ()
69+ call_args = client ._mock_httpx_instance .request .call_args
70+ payload = call_args .kwargs ["json" ]
71+
72+ assert payload ["headerPrompt" ] == header
73+ assert payload ["footerPrompt" ] == footer
74+
75+
4476@pytest .mark .parametrize (
4577 "ns, q, tk, model, temp, history, msg" ,
4678 [
0 commit comments