Skip to content

Commit 08a371e

Browse files
authored
Merge pull request #396 from tisnik/lcore-390-nits
LCORE-390: nits
2 parents d7dc087 + a8c13f1 commit 08a371e

File tree

2 files changed

+37
-7
lines changed

2 files changed

+37
-7
lines changed

src/models/responses.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from typing import Any, Optional
44

5-
from pydantic import BaseModel
5+
from pydantic import BaseModel, Field
66

77

88
class ModelsResponse(BaseModel):
@@ -252,8 +252,16 @@ class AuthorizedResponse(BaseModel):
252252
username: The name of the logged in user.
253253
"""
254254

255-
user_id: str
256-
username: str
255+
user_id: str = Field(
256+
...,
257+
description="User ID, for example UUID",
258+
examples=["c5260aec-4d82-4370-9fdf-05cf908b3f16"],
259+
)
260+
username: str = Field(
261+
...,
262+
description="User name",
263+
examples=["John Doe", "Adam Smith"],
264+
)
257265

258266
# provides examples for /docs endpoint
259267
model_config = {

tests/unit/models/test_config.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,22 @@ def test_tls_configuration() -> None:
227227
assert cfg.tls_key_password == Path("tests/configuration/password")
228228

229229

230+
def test_tls_configuration_in_service_configuration() -> None:
231+
"""Test the TLS configuration in service configuration."""
232+
cfg = ServiceConfiguration(
233+
tls_config=TLSConfiguration(
234+
tls_certificate_path=Path("tests/configuration/server.crt"),
235+
tls_key_path=Path("tests/configuration/server.key"),
236+
tls_key_password=Path("tests/configuration/password"),
237+
)
238+
)
239+
assert cfg is not None
240+
assert cfg.tls_config is not None
241+
assert cfg.tls_config.tls_certificate_path == Path("tests/configuration/server.crt")
242+
assert cfg.tls_config.tls_key_path == Path("tests/configuration/server.key")
243+
assert cfg.tls_config.tls_key_password == Path("tests/configuration/password")
244+
245+
230246
def test_tls_configuration_wrong_certificate_path() -> None:
231247
"""Test the TLS configuration loading when some path is broken."""
232248
with pytest.raises(ValueError, match="Path does not point to a file"):
@@ -416,7 +432,13 @@ def test_dump_configuration(tmp_path) -> None:
416432
"""
417433
cfg = Configuration(
418434
name="test_name",
419-
service=ServiceConfiguration(),
435+
service=ServiceConfiguration(
436+
tls_config=TLSConfiguration(
437+
tls_certificate_path=Path("tests/configuration/server.crt"),
438+
tls_key_path=Path("tests/configuration/server.key"),
439+
tls_key_password=Path("tests/configuration/password"),
440+
)
441+
),
420442
llama_stack=LlamaStackConfiguration(
421443
use_as_library_client=True,
422444
library_client_config_path="tests/configuration/run.yaml",
@@ -462,9 +484,9 @@ def test_dump_configuration(tmp_path) -> None:
462484
"color_log": True,
463485
"access_log": True,
464486
"tls_config": {
465-
"tls_certificate_path": None,
466-
"tls_key_path": None,
467-
"tls_key_password": None,
487+
"tls_certificate_path": "tests/configuration/server.crt",
488+
"tls_key_password": "tests/configuration/password",
489+
"tls_key_path": "tests/configuration/server.key",
468490
},
469491
},
470492
"llama_stack": {

0 commit comments

Comments
 (0)