Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/unit/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Unit tests for models."""
51 changes: 51 additions & 0 deletions tests/unit/models/test_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""Unit tests for functions defined in src/models/config.py."""

import pytest

from models.config import Configuration, LLamaStackConfiguration


def test_llama_stack_configuration_constructor():
"""Test the LLamaStackConfiguration constructor."""
l = LLamaStackConfiguration(
use_as_library_client=True, library_client_config_path="foo"
)
assert l is not None

l = LLamaStackConfiguration(use_as_library_client=False, url="http://localhost")
assert l is not None

l = LLamaStackConfiguration(url="http://localhost")
assert l is not None

l = LLamaStackConfiguration(
use_as_library_client=False, url="http://localhost", api_key="foo"
)
assert l is not None


def test_llama_stack_wrong_configuration_constructor_no_url():
"""Test the LLamaStackConfiguration constructor."""
with pytest.raises(
ValueError,
match="LLama stack URL is not specified and library client mode is not specified",
):
LLamaStackConfiguration()


def test_llama_stack_wrong_configuration_constructor_library_mode_off():
"""Test the LLamaStackConfiguration constructor."""
with pytest.raises(
ValueError,
match="LLama stack URL is not specified and library client mode is not enabled",
):
LLamaStackConfiguration(use_as_library_client=False)


def test_llama_stack_wrong_configuration_no_config_file():
"""Test the LLamaStackConfiguration constructor."""
with pytest.raises(
ValueError,
match="LLama stack library client mode is enabled but a configuration file path is not specified",
):
LLamaStackConfiguration(use_as_library_client=True)