mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-22 20:32:25 +00:00
fix: Fix unit tests script and failing tests
This commit is contained in:
parent
09abdb0a37
commit
034d51e775
4 changed files with 27 additions and 22 deletions
|
|
@ -5,6 +5,14 @@
|
||||||
#
|
#
|
||||||
# This source code is licensed under the terms described in the LICENSE file in
|
# This source code is licensed under the terms described in the LICENSE file in
|
||||||
# the root directory of this source tree.
|
# the root directory of this source tree.
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Always run this at the end, even if something fails
|
||||||
|
cleanup() {
|
||||||
|
echo "Generating coverage report..."
|
||||||
|
uv run --python "$PYTHON_VERSION" coverage html -d htmlcov-$PYTHON_VERSION
|
||||||
|
}
|
||||||
|
trap cleanup EXIT
|
||||||
|
|
||||||
PYTHON_VERSION=${PYTHON_VERSION:-3.12}
|
PYTHON_VERSION=${PYTHON_VERSION:-3.12}
|
||||||
|
|
||||||
|
|
@ -19,6 +27,3 @@ fi
|
||||||
# Run unit tests with coverage
|
# Run unit tests with coverage
|
||||||
uv run --python "$PYTHON_VERSION" --with-editable . --group unit \
|
uv run --python "$PYTHON_VERSION" --with-editable . --group unit \
|
||||||
coverage run --source=llama_stack -m pytest -s -v tests/unit/ "$@"
|
coverage run --source=llama_stack -m pytest -s -v tests/unit/ "$@"
|
||||||
|
|
||||||
# Generate HTML coverage report
|
|
||||||
uv run --python "$PYTHON_VERSION" coverage html -d htmlcov-$PYTHON_VERSION
|
|
||||||
|
|
|
||||||
|
|
@ -346,7 +346,7 @@ pip_packages:
|
||||||
|
|
||||||
def test_external_provider_from_module_building(self, mock_providers):
|
def test_external_provider_from_module_building(self, mock_providers):
|
||||||
"""Test loading an external provider from a module during build (building=True, partial spec)."""
|
"""Test loading an external provider from a module during build (building=True, partial spec)."""
|
||||||
from llama_stack.distribution.datatypes import BuildConfig, DistributionSpec, Provider
|
from llama_stack.distribution.datatypes import BuildConfig, BuildProvider, DistributionSpec
|
||||||
from llama_stack.providers.datatypes import Api
|
from llama_stack.providers.datatypes import Api
|
||||||
|
|
||||||
# No importlib patch needed, should not import module when type of `config` is BuildConfig or DistributionSpec
|
# No importlib patch needed, should not import module when type of `config` is BuildConfig or DistributionSpec
|
||||||
|
|
@ -358,10 +358,8 @@ pip_packages:
|
||||||
description="test",
|
description="test",
|
||||||
providers={
|
providers={
|
||||||
"inference": [
|
"inference": [
|
||||||
Provider(
|
BuildProvider(
|
||||||
provider_id="external_test",
|
|
||||||
provider_type="external_test",
|
provider_type="external_test",
|
||||||
config={},
|
|
||||||
module="external_test",
|
module="external_test",
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -162,26 +162,28 @@ async def test_register_model_existing_different(
|
||||||
await helper.register_model(known_model)
|
await helper.register_model(known_model)
|
||||||
|
|
||||||
|
|
||||||
async def test_unregister_model(helper: ModelRegistryHelper, known_model: Model) -> None:
|
# TODO: unregister_model functionality was removed/disabled by https://github.com/meta-llama/llama-stack/pull/2916
|
||||||
await helper.register_model(known_model) # duplicate entry
|
# async def test_unregister_model(helper: ModelRegistryHelper, known_model: Model) -> None:
|
||||||
assert helper.get_provider_model_id(known_model.model_id) == known_model.provider_model_id
|
# await helper.register_model(known_model) # duplicate entry
|
||||||
await helper.unregister_model(known_model.model_id)
|
# assert helper.get_provider_model_id(known_model.model_id) == known_model.provider_model_id
|
||||||
assert helper.get_provider_model_id(known_model.model_id) is None
|
# await helper.unregister_model(known_model.model_id)
|
||||||
|
# assert helper.get_provider_model_id(known_model.model_id) is None
|
||||||
|
|
||||||
|
|
||||||
async def test_unregister_unknown_model(helper: ModelRegistryHelper, unknown_model: Model) -> None:
|
# TODO: unregister_model functionality was removed/disabled by https://github.com/meta-llama/llama-stack/pull/2916
|
||||||
with pytest.raises(ValueError):
|
# async def test_unregister_unknown_model(helper: ModelRegistryHelper, unknown_model: Model) -> None:
|
||||||
await helper.unregister_model(unknown_model.model_id)
|
# with pytest.raises(ValueError):
|
||||||
|
# await helper.unregister_model(unknown_model.model_id)
|
||||||
|
|
||||||
|
|
||||||
async def test_register_model_during_init(helper: ModelRegistryHelper, known_model: Model) -> None:
|
async def test_register_model_during_init(helper: ModelRegistryHelper, known_model: Model) -> None:
|
||||||
assert helper.get_provider_model_id(known_model.provider_resource_id) == known_model.provider_model_id
|
assert helper.get_provider_model_id(known_model.provider_resource_id) == known_model.provider_model_id
|
||||||
|
|
||||||
|
# TODO: unregister_model functionality was removed/disabled by https://github.com/meta-llama/llama-stack/pull/2916
|
||||||
async def test_unregister_model_during_init(helper: ModelRegistryHelper, known_model: Model) -> None:
|
# async def test_unregister_model_during_init(helper: ModelRegistryHelper, known_model: Model) -> None:
|
||||||
assert helper.get_provider_model_id(known_model.provider_resource_id) == known_model.provider_model_id
|
# assert helper.get_provider_model_id(known_model.provider_resource_id) == known_model.provider_model_id
|
||||||
await helper.unregister_model(known_model.provider_resource_id)
|
# await helper.unregister_model(known_model.provider_resource_id)
|
||||||
assert helper.get_provider_model_id(known_model.provider_resource_id) is None
|
# assert helper.get_provider_model_id(known_model.provider_resource_id) is None
|
||||||
|
|
||||||
|
|
||||||
async def test_register_model_from_check_model_availability(
|
async def test_register_model_from_check_model_availability(
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ def github_token_app():
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add auth middleware
|
# Add auth middleware
|
||||||
app.add_middleware(AuthenticationMiddleware, auth_config=auth_config)
|
app.add_middleware(AuthenticationMiddleware, auth_config=auth_config, impls={})
|
||||||
|
|
||||||
@app.get("/test")
|
@app.get("/test")
|
||||||
def test_endpoint():
|
def test_endpoint():
|
||||||
|
|
@ -149,7 +149,7 @@ def test_github_enterprise_support(mock_client_class):
|
||||||
access_policy=[],
|
access_policy=[],
|
||||||
)
|
)
|
||||||
|
|
||||||
app.add_middleware(AuthenticationMiddleware, auth_config=auth_config)
|
app.add_middleware(AuthenticationMiddleware, auth_config=auth_config, impls={})
|
||||||
|
|
||||||
@app.get("/test")
|
@app.get("/test")
|
||||||
def test_endpoint():
|
def test_endpoint():
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue