mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-07-27 06:28:50 +00:00
update: code review
- change type from str to Field with description - remove test from test_distrubution.py, keep in test_providers.py Signed-off-by: Wen Zhou <wenzhou@redhat.com>
This commit is contained in:
parent
0b051c037b
commit
2ce9402593
3 changed files with 30 additions and 127 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from llama_stack.apis.providers import ProviderInfo
|
||||
from llama_stack.distribution.datatypes import Provider, StackRunConfig
|
||||
|
@ -37,6 +38,23 @@ class TestProviderImpl:
|
|||
)
|
||||
return ProviderImplConfig(run_config=run_config)
|
||||
|
||||
@pytest.fixture
|
||||
def mock_config_malformed_metrics(self):
|
||||
"""Create a mock configuration with invalid metrics URL for testing."""
|
||||
run_config = StackRunConfig(
|
||||
image_name="test_image",
|
||||
providers={
|
||||
"inference": [
|
||||
Provider(
|
||||
provider_id="test_provider_malformed_metrics",
|
||||
provider_type="test_type3",
|
||||
config={"url": "http://localhost:8000", "metrics": "abcde-llama-stack"},
|
||||
),
|
||||
]
|
||||
},
|
||||
)
|
||||
return ProviderImplConfig(run_config=run_config)
|
||||
|
||||
@pytest.fixture
|
||||
def mock_deps(self):
|
||||
"""Create mock dependencies."""
|
||||
|
@ -111,3 +129,11 @@ class TestProviderImpl:
|
|||
|
||||
with pytest.raises(ValueError, match="Provider nonexistent not found"):
|
||||
await provider_impl.inspect_provider("nonexistent")
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_inspect_provider_malformed_metrics(self, mock_config_malformed_metrics, mock_deps):
|
||||
"""Test inspect_provider with invalid metrics URL raises validation error."""
|
||||
provider_impl = ProviderImpl(mock_config_malformed_metrics, mock_deps)
|
||||
|
||||
with pytest.raises(ValidationError):
|
||||
await provider_impl.inspect_provider("test_provider_malformed_metrics")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue