66
77
88def test_default_configuration () -> None :
9+ """Test that configuration attributes are not accessible for uninitialized app."""
910 cfg = AppConfig ()
1011 assert cfg is not None
1112
1213 # configuration is not loaded
1314 with pytest .raises (Exception , match = "logic error: configuration is not loaded" ):
1415 # try to read property
15- cfg .configuration
16+ cfg .configuration # pylint: disable=pointless-statement
1617
1718 with pytest .raises (Exception , match = "logic error: configuration is not loaded" ):
1819 # try to read property
19- cfg .llama_stack_configuration
20+ cfg .service_configuration # pylint: disable=pointless-statement
2021
2122 with pytest .raises (Exception , match = "logic error: configuration is not loaded" ):
2223 # try to read property
23- cfg .user_data_collection_configuration
24+ cfg .llama_stack_configuration # pylint: disable=pointless-statement
25+
26+ with pytest .raises (Exception , match = "logic error: configuration is not loaded" ):
27+ # try to read property
28+ cfg .user_data_collection_configuration # pylint: disable=pointless-statement
29+
30+ with pytest .raises (Exception , match = "logic error: configuration is not loaded" ):
31+ # try to read property
32+ cfg .mcp_servers # pylint: disable=pointless-statement
33+
34+ with pytest .raises (Exception , match = "logic error: configuration is not loaded" ):
35+ # try to read property
36+ cfg .authentication_configuration # pylint: disable=pointless-statement
37+
38+ with pytest .raises (Exception , match = "logic error: configuration is not loaded" ):
39+ # try to read property
40+ cfg .customization # pylint: disable=pointless-statement
2441
2542
2643def test_configuration_is_singleton () -> None :
44+ """Test that configuration is singleton."""
2745 cfg1 = AppConfig ()
2846 cfg2 = AppConfig ()
2947 assert cfg1 == cfg2
3048
3149
3250def test_init_from_dict () -> None :
51+ """Test the configuration initialization from dictionary with config values."""
3352 config_dict = {
3453 "name" : "foo" ,
3554 "service" : {
@@ -126,8 +145,9 @@ def test_init_from_dict_with_mcp_servers() -> None:
126145
127146
128147def test_load_proper_configuration (tmpdir ) -> None :
148+ """Test loading proper configuration from YAML file."""
129149 cfg_filename = tmpdir / "config.yaml"
130- with open (cfg_filename , "w" ) as fout :
150+ with open (cfg_filename , "w" , encoding = "utf-8" ) as fout :
131151 fout .write (
132152 """
133153name: foo bar baz
@@ -159,7 +179,7 @@ def test_load_proper_configuration(tmpdir) -> None:
159179def test_load_configuration_with_mcp_servers (tmpdir ) -> None :
160180 """Test loading configuration from YAML file with MCP servers."""
161181 cfg_filename = tmpdir / "config.yaml"
162- with open (cfg_filename , "w" ) as fout :
182+ with open (cfg_filename , "w" , encoding = "utf-8" ) as fout :
163183 fout .write (
164184 """
165185name: test service
@@ -273,7 +293,7 @@ def test_configuration_not_loaded():
273293 with pytest .raises (
274294 AssertionError , match = "logic error: configuration is not loaded"
275295 ):
276- cfg .configuration
296+ cfg .configuration # pylint: disable=pointless-statement
277297
278298
279299def test_service_configuration_not_loaded ():
@@ -282,7 +302,7 @@ def test_service_configuration_not_loaded():
282302 with pytest .raises (
283303 AssertionError , match = "logic error: configuration is not loaded"
284304 ):
285- cfg .service_configuration
305+ cfg .service_configuration # pylint: disable=pointless-statement
286306
287307
288308def test_llama_stack_configuration_not_loaded ():
@@ -291,7 +311,7 @@ def test_llama_stack_configuration_not_loaded():
291311 with pytest .raises (
292312 AssertionError , match = "logic error: configuration is not loaded"
293313 ):
294- cfg .llama_stack_configuration
314+ cfg .llama_stack_configuration # pylint: disable=pointless-statement
295315
296316
297317def test_user_data_collection_configuration_not_loaded ():
@@ -300,7 +320,7 @@ def test_user_data_collection_configuration_not_loaded():
300320 with pytest .raises (
301321 AssertionError , match = "logic error: configuration is not loaded"
302322 ):
303- cfg .user_data_collection_configuration
323+ cfg .user_data_collection_configuration # pylint: disable=pointless-statement
304324
305325
306326def test_mcp_servers_not_loaded ():
@@ -309,17 +329,35 @@ def test_mcp_servers_not_loaded():
309329 with pytest .raises (
310330 AssertionError , match = "logic error: configuration is not loaded"
311331 ):
312- cfg .mcp_servers
332+ cfg .mcp_servers # pylint: disable=pointless-statement
333+
334+
335+ def test_authentication_configuration_not_loaded ():
336+ """Test that accessing authentication_configuration before loading raises an error."""
337+ cfg = AppConfig ()
338+ with pytest .raises (
339+ AssertionError , match = "logic error: configuration is not loaded"
340+ ):
341+ cfg .authentication_configuration # pylint: disable=pointless-statement
342+
343+
344+ def test_customization_not_loaded ():
345+ """Test that accessing customization before loading raises an error."""
346+ cfg = AppConfig ()
347+ with pytest .raises (
348+ AssertionError , match = "logic error: configuration is not loaded"
349+ ):
350+ cfg .customization # pylint: disable=pointless-statement
313351
314352
315353def test_load_configuration_with_customization_system_prompt_path (tmpdir ) -> None :
316354 """Test loading configuration from YAML file with customization."""
317355 system_prompt_filename = tmpdir / "system_prompt.txt"
318- with open (system_prompt_filename , "w" ) as fout :
356+ with open (system_prompt_filename , "w" , encoding = "utf-8" ) as fout :
319357 fout .write ("this is system prompt" )
320358
321359 cfg_filename = tmpdir / "config.yaml"
322- with open (cfg_filename , "w" ) as fout :
360+ with open (cfg_filename , "w" , encoding = "utf-8" ) as fout :
323361 fout .write (
324362 f"""
325363name: test service
@@ -359,7 +397,7 @@ def test_load_configuration_with_customization_system_prompt_path(tmpdir) -> Non
359397def test_load_configuration_with_customization_system_prompt (tmpdir ) -> None :
360398 """Test loading configuration from YAML file with system_prompt in the customization."""
361399 cfg_filename = tmpdir / "config.yaml"
362- with open (cfg_filename , "w" ) as fout :
400+ with open (cfg_filename , "w" , encoding = "utf-8" ) as fout :
363401 fout .write (
364402 """
365403name: test service
0 commit comments