Skip to content

Commit 41e0d6f

Browse files
authored
test: add catalog preview endpoint tests (#969)
Add test coverage for the catalog preview API including: - Filter validation with includedModels/excludedModels patterns - filterStatus parameter testing (all/included/excluded) - Error handling for invalid configs and nonexistent paths - User-provided catalog data support via catalogData parameter Implement helper utilities for preview API testing Enhance test fixtures to support parameterized catalog selection, enabling tests against both default and validated catalog sources.
1 parent 8516939 commit 41e0d6f

File tree

4 files changed

+602
-2
lines changed

4 files changed

+602
-2
lines changed

tests/model_registry/model_catalog/conftest.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
DEFAULT_CATALOG_FILE,
1616
CATALOG_CONTAINER,
1717
REDHAT_AI_CATALOG_ID,
18+
DEFAULT_CATALOGS,
1819
)
1920
from tests.model_registry.model_catalog.utils import get_models_from_catalog_api, get_catalog_url_and_headers
2021
from tests.model_registry.constants import (
@@ -257,9 +258,31 @@ def randomly_picked_model_from_catalog_api_by_source(
257258

258259

259260
@pytest.fixture(scope="class")
260-
def default_model_catalog_yaml_content(admin_client: DynamicClient, model_registry_namespace: str) -> dict[Any, Any]:
261+
def default_model_catalog_yaml_content(
262+
request: pytest.FixtureRequest, admin_client: DynamicClient, model_registry_namespace: str
263+
) -> dict[Any, Any]:
264+
"""
265+
Fetch and parse catalog YAML from the catalog pod.
266+
267+
Defaults to DEFAULT_CATALOG_FILE if not parameterized.
268+
Use with @pytest.mark.parametrize indirect parameter to specify a different catalog:
269+
270+
Args:
271+
request.param: Optional catalog ID, if not provided, uses DEFAULT_CATALOG_FILE.
272+
273+
Returns:
274+
Parsed YAML content as dictionary
275+
"""
276+
# If parameterized, get the catalog file path from the catalog ID
277+
# Otherwise, use DEFAULT_CATALOG_FILE
278+
catalog_id = getattr(request, "param", None)
279+
if catalog_id:
280+
catalog_file_path = DEFAULT_CATALOGS[catalog_id]["properties"]["yamlCatalogPath"]
281+
else:
282+
catalog_file_path = DEFAULT_CATALOG_FILE
283+
261284
model_catalog_pod = get_model_catalog_pod(client=admin_client, model_registry_namespace=model_registry_namespace)[0]
262-
return yaml.safe_load(model_catalog_pod.execute(command=["cat", DEFAULT_CATALOG_FILE], container=CATALOG_CONTAINER))
285+
return yaml.safe_load(model_catalog_pod.execute(command=["cat", catalog_file_path], container=CATALOG_CONTAINER))
263286

264287

265288
@pytest.fixture(scope="class")

tests/model_registry/model_catalog/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
REDHAT_AI_CATALOG_ID: str = "redhat_ai_models"
3737
DEFAULT_CATALOG_FILE: str = DEFAULT_CATALOGS[REDHAT_AI_CATALOG_ID]["properties"]["yamlCatalogPath"]
3838
VALIDATED_CATALOG_ID: str = "redhat_ai_validated_models"
39+
VALIDATED_CATALOG_FILE: str = DEFAULT_CATALOGS[VALIDATED_CATALOG_ID]["properties"]["yamlCatalogPath"]
3940

4041
MODEL_ARTIFACT_TYPE: str = "model-artifact"
4142
METRICS_ARTIFACT_TYPE: str = "metrics-artifact"

0 commit comments

Comments
 (0)