Skip to content

Commit 1011ab9

Browse files
committed
LCORE-2320: Minimal configuration dump unit tests
1 parent c9e9675 commit 1011ab9

1 file changed

Lines changed: 181 additions & 1 deletion

File tree

tests/unit/models/config/test_dump_configuration.py

Lines changed: 181 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,187 @@
4141
}
4242

4343

44-
def test_dump_configuration(tmp_path: Path) -> None:
44+
def test_dump_configuration_minimal_cfg(tmp_path: Path) -> None:
45+
"""
46+
Test that the Configuration object can be serialized to a JSON file and
47+
that the resulting file contains all expected sections and values.
48+
49+
Please note that redaction process is not in place.
50+
51+
Parameters:
52+
----------
53+
tmp_path (Path): Directory where the test JSON file will be written.
54+
"""
55+
cfg = Configuration(
56+
name="test_name",
57+
service=ServiceConfiguration(
58+
tls_config=TLSConfiguration(
59+
tls_certificate_path=Path("tests/configuration/server.crt"),
60+
tls_key_path=Path("tests/configuration/server.key"),
61+
tls_key_password=Path("tests/configuration/password"),
62+
),
63+
cors=CORSConfiguration(),
64+
),
65+
llama_stack=LlamaStackConfiguration(
66+
use_as_library_client=True,
67+
library_client_config_path="tests/configuration/run.yaml",
68+
api_key=SecretStr("whatever"),
69+
),
70+
user_data_collection=UserDataCollection(
71+
feedback_enabled=False, feedback_storage=None
72+
),
73+
)
74+
assert cfg is not None
75+
dump_file = tmp_path / "test.json"
76+
cfg.dump(dump_file)
77+
78+
with open(dump_file, "r", encoding="utf-8") as fin:
79+
content = json.load(fin)
80+
# content should be loaded
81+
assert content is not None
82+
83+
# all sections must exists
84+
assert "name" in content
85+
assert "service" in content
86+
assert "llama_stack" in content
87+
assert "user_data_collection" in content
88+
assert "mcp_servers" in content
89+
assert "authentication" in content
90+
assert "authorization" in content
91+
assert "customization" in content
92+
assert "inference" in content
93+
assert "database" in content
94+
assert "byok_rag" in content
95+
assert "quota_handlers" in content
96+
assert "azure_entra_id" in content
97+
assert "reranker" in content
98+
99+
# check the whole deserialized JSON file content
100+
assert content == {
101+
"name": "test_name",
102+
"service": {
103+
"host": "localhost",
104+
"port": 8080,
105+
"base_url": None,
106+
"auth_enabled": False,
107+
"workers": 1,
108+
"color_log": True,
109+
"access_log": True,
110+
"tls_config": {
111+
"tls_certificate_path": "tests/configuration/server.crt",
112+
"tls_key_password": "tests/configuration/password",
113+
"tls_key_path": "tests/configuration/server.key",
114+
},
115+
"root_path": "",
116+
"cors": {
117+
"allow_credentials": False,
118+
"allow_headers": [
119+
"*",
120+
],
121+
"allow_methods": [
122+
"*",
123+
],
124+
"allow_origins": [
125+
"*",
126+
],
127+
},
128+
},
129+
"llama_stack": {
130+
"url": None,
131+
"use_as_library_client": True,
132+
"api_key": "**********",
133+
"library_client_config_path": "tests/configuration/run.yaml",
134+
"timeout": 180,
135+
"allow_degraded_mode": False,
136+
"max_retries": constants.DEFAULT_MAX_RETRIES,
137+
"retry_delay": constants.DEFAULT_RETRY_DELAY,
138+
},
139+
"user_data_collection": {
140+
"feedback_enabled": False,
141+
"feedback_storage": None,
142+
"transcripts_enabled": False,
143+
"transcripts_storage": None,
144+
},
145+
"mcp_servers": [],
146+
"authentication": {
147+
"module": "noop",
148+
"skip_tls_verification": False,
149+
"skip_for_health_probes": False,
150+
"skip_for_metrics": False,
151+
"k8s_ca_cert_path": None,
152+
"k8s_cluster_api": None,
153+
"jwk_config": None,
154+
"api_key_config": None,
155+
"rh_identity_config": None,
156+
},
157+
"customization": None,
158+
"inference": {
159+
"default_provider": None,
160+
"default_model": None,
161+
"context_windows": {},
162+
},
163+
"database": {
164+
"sqlite": {
165+
"db_path": "/tmp/lightspeed-stack.db",
166+
},
167+
"postgres": None,
168+
},
169+
"authorization": None,
170+
"conversation_cache": {
171+
"memory": None,
172+
"postgres": None,
173+
"sqlite": None,
174+
"type": None,
175+
},
176+
"compaction": {
177+
"enabled": False,
178+
"threshold_ratio": 0.7,
179+
"token_floor": 4096,
180+
"buffer_turns": 4,
181+
"buffer_max_ratio": 0.3,
182+
},
183+
"approvals": _DEFAULT_APPROVALS_DUMP,
184+
"byok_rag": [],
185+
"quota_handlers": {
186+
"sqlite": None,
187+
"postgres": None,
188+
"limiters": [],
189+
"scheduler": {
190+
"period": 1,
191+
"database_reconnection_count": 10,
192+
"database_reconnection_delay": 1,
193+
},
194+
"enable_token_history": False,
195+
},
196+
"a2a_state": {
197+
"sqlite": None,
198+
"postgres": None,
199+
},
200+
"azure_entra_id": None,
201+
"rag": {
202+
"inline": [],
203+
"tool": [],
204+
},
205+
"okp": {
206+
"rhokp_url": None,
207+
"offline": True,
208+
"chunk_filter_query": None,
209+
},
210+
"rlsapi_v1": {
211+
"allow_verbose_infer": False,
212+
"quota_subject": None,
213+
},
214+
"splunk": None,
215+
"deployment_environment": "development",
216+
"reranker": {
217+
"enabled": False,
218+
"model": "cross-encoder/ms-marco-MiniLM-L6-v2",
219+
},
220+
"skills": None,
221+
}
222+
223+
224+
def test_dump_configuration_valid_values(tmp_path: Path) -> None:
45225
"""
46226
Test that the Configuration object can be serialized to a JSON file and
47227
that the resulting file contains all expected sections and values.

0 commit comments

Comments
 (0)