@@ -167,6 +167,55 @@ def test_build_instructions(
167167 assert not_expected not in result
168168
169169
170+ # --- Test _build_instructions with customization.system_prompt ---
171+
172+
173+ @pytest .mark .parametrize (
174+ ("custom_prompt" , "expected_prompt" ),
175+ [
176+ pytest .param (
177+ "You are a RHEL expert." ,
178+ "You are a RHEL expert." ,
179+ id = "customization_system_prompt_set" ,
180+ ),
181+ pytest .param (
182+ None ,
183+ constants .DEFAULT_SYSTEM_PROMPT ,
184+ id = "customization_system_prompt_none" ,
185+ ),
186+ ],
187+ )
188+ def test_build_instructions_with_customization (
189+ mocker : MockerFixture ,
190+ custom_prompt : str | None ,
191+ expected_prompt : str ,
192+ ) -> None :
193+ """Test _build_instructions uses customization.system_prompt when set."""
194+ mock_customization = mocker .Mock ()
195+ mock_customization .system_prompt = custom_prompt
196+ mock_config = mocker .Mock ()
197+ mock_config .customization = mock_customization
198+ mocker .patch ("app.endpoints.rlsapi_v1.configuration" , mock_config )
199+
200+ systeminfo = RlsapiV1SystemInfo (os = "RHEL" , version = "9.3" , arch = "x86_64" )
201+ result = _build_instructions (systeminfo )
202+
203+ assert expected_prompt in result
204+ assert "OS: RHEL" in result
205+
206+
207+ def test_build_instructions_no_customization (mocker : MockerFixture ) -> None :
208+ """Test _build_instructions falls back when customization is None."""
209+ mock_config = mocker .Mock ()
210+ mock_config .customization = None
211+ mocker .patch ("app.endpoints.rlsapi_v1.configuration" , mock_config )
212+
213+ systeminfo = RlsapiV1SystemInfo ()
214+ result = _build_instructions (systeminfo )
215+
216+ assert result == constants .DEFAULT_SYSTEM_PROMPT
217+
218+
170219# --- Test _get_default_model_id ---
171220
172221
0 commit comments