Skip to content

Commit affe2b2

Browse files
dbasunagclaude
andcommitted
fix: label tests needed update to accomodate mcp labels
Signed-off-by: Debarati Basu-Nag <dbasunag@redhat.com> Co-Authored-By: Claude <noreply@anthropic.com>
1 parent c74eb5a commit affe2b2

File tree

2 files changed

+31
-13
lines changed

2 files changed

+31
-13
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from typing import Any
2+
3+
import pytest
4+
from kubernetes.dynamic import DynamicClient
5+
6+
from tests.model_registry.model_catalog.metadata.utils import get_labels_from_configmaps
7+
8+
9+
@pytest.fixture()
10+
def expected_labels_by_asset_type(
11+
admin_client: DynamicClient,
12+
model_registry_namespace: str,
13+
) -> dict[str, list[dict[str, Any]]]:
14+
"""Get expected labels from ConfigMaps, split by asset type."""
15+
all_labels = get_labels_from_configmaps(admin_client=admin_client, namespace=model_registry_namespace)
16+
mcp_labels = [label for label in all_labels if label.get("assetType") == "mcp_servers"]
17+
model_labels = [label for label in all_labels if label not in mcp_labels]
18+
return {"models": model_labels, "mcp_servers": mcp_labels}

tests/model_registry/model_catalog/metadata/test_labels_endpoint.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any
1+
from typing import Any, Literal
22

33
import pytest
44
import structlog
@@ -19,27 +19,27 @@ class TestLabelsEndpoint:
1919
"""Test class for the model catalog labels endpoint."""
2020

2121
@pytest.mark.smoke
22+
@pytest.mark.parametrize(
23+
"asset_type",
24+
[
25+
pytest.param("models", id="models"),
26+
pytest.param("mcp_servers", id="mcp_servers"),
27+
],
28+
)
2229
def test_labels_endpoint_default_data(
2330
self,
24-
admin_client: DynamicClient,
25-
model_registry_namespace: str,
2631
model_catalog_rest_url: list[str],
32+
expected_labels_by_asset_type: dict[str, list[dict[str, Any]]],
33+
asset_type: Literal["models", "mcp_servers"],
2734
):
2835
"""
2936
Smoke test: Validate default labels from ConfigMaps are returned by the endpoint.
3037
"""
31-
LOGGER.info("Testing labels endpoint with default data")
32-
33-
# Get expected labels from ConfigMaps
34-
expected_labels = get_labels_from_configmaps(admin_client=admin_client, namespace=model_registry_namespace)
35-
36-
# Get labels from API
38+
LOGGER.info(f"Testing labels endpoint with default data for asset type: {asset_type}")
3739
api_labels = get_labels_from_api(
38-
model_catalog_rest_url=model_catalog_rest_url[0], user_token=get_openshift_token()
40+
model_catalog_rest_url=model_catalog_rest_url[0], user_token=get_openshift_token(), asset_type=asset_type
3941
)
40-
41-
# Verify they match
42-
verify_labels_match(expected_labels=expected_labels, api_labels=api_labels)
42+
verify_labels_match(expected_labels=expected_labels_by_asset_type[asset_type], api_labels=api_labels)
4343

4444
@pytest.mark.tier1
4545
def test_labels_endpoint_configmap_updates(

0 commit comments

Comments
 (0)