Skip to content

Commit f22de7a

Browse files
committed
New test for client.py
1 parent 6459aac commit f22de7a

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/unit/test_client.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,29 @@
66
from models.config import LlamaStackConfiguration
77

88

9+
def test_client_get_client_method() -> None:
10+
"""Test how get_client method works for unitialized client."""
11+
12+
client = LlamaStackClientHolder()
13+
14+
with pytest.raises(
15+
RuntimeError,
16+
match="LlamaStackClient has not been initialised. Ensure 'load\\(..\\)' has been called.",
17+
):
18+
client.get_client()
19+
20+
21+
def test_async_client_get_client_method() -> None:
22+
"""Test how get_client method works for unitialized client."""
23+
client = AsyncLlamaStackClientHolder()
24+
25+
with pytest.raises(
26+
RuntimeError,
27+
match="AsyncLlamaStackClient has not been initialised. Ensure 'load\\(..\\)' has been called.",
28+
):
29+
client.get_client()
30+
31+
932
def test_get_llama_stack_library_client() -> None:
1033
"""Test if Llama Stack can be initialized in library client mode."""
1134
cfg = LlamaStackConfiguration(
@@ -18,6 +41,9 @@ def test_get_llama_stack_library_client() -> None:
1841
client.load(cfg)
1942
assert client is not None
2043

44+
ls_client = client.get_client()
45+
assert ls_client is not None
46+
2147

2248
def test_get_llama_stack_remote_client() -> None:
2349
"""Test if Llama Stack can be initialized in remove client (server) mode."""
@@ -31,6 +57,9 @@ def test_get_llama_stack_remote_client() -> None:
3157
client.load(cfg)
3258
assert client is not None
3359

60+
ls_client = client.get_client()
61+
assert ls_client is not None
62+
3463

3564
def test_get_llama_stack_wrong_configuration() -> None:
3665
"""Test if configuration is checked before Llama Stack is initialized."""
@@ -61,6 +90,9 @@ async def test_get_async_llama_stack_library_client() -> None:
6190
await client.load(cfg)
6291
assert client is not None
6392

93+
ls_client = client.get_client()
94+
assert ls_client is not None
95+
6496

6597
async def test_get_async_llama_stack_remote_client() -> None:
6698
"""Test the initialization of asynchronous Llama Stack client in server mode."""
@@ -74,6 +106,9 @@ async def test_get_async_llama_stack_remote_client() -> None:
74106
await client.load(cfg)
75107
assert client is not None
76108

109+
ls_client = client.get_client()
110+
assert ls_client is not None
111+
77112

78113
async def test_get_async_llama_stack_wrong_configuration() -> None:
79114
"""Test if configuration is checked before Llama Stack is initialized."""

0 commit comments

Comments
 (0)