1111from ocp_resources .config_map import ConfigMap
1212from ocp_resources .route import Route
1313from ocp_resources .service import Service
14- from tests .model_registry .constants import DEFAULT_CUSTOM_MODEL_CATALOG , DEFAULT_MODEL_CATALOG_CFG
15- from tests .model_registry .model_catalog .constants import REDHAT_AI_CATALOG_ID , CATALOG_CONTAINER
14+ from tests .model_registry .model_catalog .constants import DEFAULT_CATALOG_ID , CATALOG_CONTAINER
1615from tests .model_registry .model_catalog .utils import (
1716 validate_model_catalog_enabled ,
1817 execute_get_command ,
3736@pytest .mark .skip_must_gather
3837class TestModelCatalogGeneral :
3938 @pytest .mark .parametrize (
40- "model_catalog_config_map, expected_catalogs " ,
39+ "model_catalog_config_map" ,
4140 [
4241 pytest .param (
43- {"configmap_name" : DEFAULT_CUSTOM_MODEL_CATALOG },
44- 0 ,
42+ {"configmap_name" : "model-catalog-sources" },
4543 id = "test_model_catalog_sources_configmap" ,
4644 ),
4745 pytest .param (
48- {"configmap_name" : DEFAULT_MODEL_CATALOG_CFG },
49- 2 ,
46+ {"configmap_name" : "model-catalog-default-sources" },
5047 id = "test_model_catalog_default_sources_configmap" ,
5148 ),
5249 ],
5350 indirect = ["model_catalog_config_map" ],
5451 )
55- def test_config_map_exists (self : Self , model_catalog_config_map : ConfigMap , expected_catalogs : int ):
52+ def test_config_map_exists (self : Self , model_catalog_config_map : ConfigMap ):
5653 # Check that model catalog configmaps is created when model registry is
5754 # enabled on data science cluster.
5855 catalogs = yaml .safe_load (model_catalog_config_map .instance .data ["sources.yaml" ])["catalogs" ]
59- assert len (catalogs ) == expected_catalogs , (
60- f"{ model_catalog_config_map .name } should have { expected_catalogs } catalog"
61- )
62- if expected_catalogs :
63- validate_default_catalog (catalogs = catalogs )
56+ assert catalogs
57+ assert len (catalogs ) == 1 , f"{ model_catalog_config_map .name } should have 1 catalog"
58+ validate_default_catalog (default_catalog = catalogs [0 ])
6459
6560 @pytest .mark .parametrize (
6661 "resource_name, expected_resource_count" ,
@@ -175,7 +170,7 @@ def test_model_default_catalog_get_model_by_name(
175170 """
176171 model_name = randomly_picked_model_from_default_catalog ["name" ]
177172 result = execute_get_command (
178- url = f"{ model_catalog_rest_url [0 ]} sources/{ REDHAT_AI_CATALOG_ID } /models/{ model_name } " ,
173+ url = f"{ model_catalog_rest_url [0 ]} sources/{ DEFAULT_CATALOG_ID } /models/{ model_name } " ,
179174 headers = get_rest_headers (token = user_token_for_api_calls ),
180175 )
181176 differences = list (diff (randomly_picked_model_from_default_catalog , result ))
@@ -192,7 +187,7 @@ def test_model_default_catalog_get_model_artifact(
192187 """
193188 model_name = randomly_picked_model_from_default_catalog ["name" ]
194189 result = execute_get_command (
195- url = f"{ model_catalog_rest_url [0 ]} sources/{ REDHAT_AI_CATALOG_ID } /models/{ model_name } /artifacts" ,
190+ url = f"{ model_catalog_rest_url [0 ]} sources/{ DEFAULT_CATALOG_ID } /models/{ model_name } /artifacts" ,
196191 headers = get_rest_headers (token = user_token_for_api_calls ),
197192 )["items" ]
198193 assert result , f"No artifacts found for { model_name } "
@@ -290,25 +285,24 @@ def test_model_default_catalog_random_artifact(
290285 LOGGER .info (f"Required artifact fields from OpenAPI schema: { required_artifact_fields } " )
291286
292287 random_model = random .choice (seq = default_model_catalog_yaml_content .get ("models" , []))
293- model_name = random_model ["name" ]
294- LOGGER .info (f"Random model: { model_name } " )
288+ LOGGER .info (f"Random model: { random_model ['name' ]} " )
295289
296290 api_model_artifacts = execute_get_command (
297- url = f"{ model_catalog_rest_url [0 ]} sources/{ REDHAT_AI_CATALOG_ID } /models/{ model_name } /artifacts" ,
291+ url = f"{ model_catalog_rest_url [0 ]} sources/{ DEFAULT_CATALOG_ID } /models/{ random_model [ 'name' ] } /artifacts" ,
298292 headers = model_registry_rest_headers ,
299293 )["items" ]
300294
301295 yaml_artifacts = random_model .get ("artifacts" , [])
302- assert api_model_artifacts , f"No artifacts found in API for { model_name } "
303- assert yaml_artifacts , f"No artifacts found in YAML for { model_name } "
296+ assert api_model_artifacts , f"No artifacts found in API for { random_model [ 'name' ] } "
297+ assert yaml_artifacts , f"No artifacts found in YAML for { random_model [ 'name' ] } "
304298
305299 # Validate all required fields are present in both YAML and API artifact
306300 # FAILS artifactType is not in YAML nor in API until https://issues.redhat.com/browse/RHOAIENG-35569 is fixed
307301 for field in required_artifact_fields :
308302 for artifact in yaml_artifacts :
309- assert field in artifact , f"YAML artifact for { model_name } missing REQUIRED field: { field } "
303+ assert field in artifact , f"YAML artifact for { random_model [ 'name' ] } missing REQUIRED field: { field } "
310304 for artifact in api_model_artifacts :
311- assert field in artifact , f"API artifact for { model_name } missing REQUIRED field: { field } "
305+ assert field in artifact , f"API artifact for { random_model [ 'name' ] } missing REQUIRED field: { field } "
312306
313307 # Filter artifacts to only include schema-defined fields for comparison
314308 yaml_artifacts_filtered = [
@@ -319,5 +313,5 @@ def test_model_default_catalog_random_artifact(
319313 ]
320314
321315 differences = list (diff (yaml_artifacts_filtered , api_artifacts_filtered ))
322- assert not differences , f"Artifacts mismatch for { model_name } : { differences } "
316+ assert not differences , f"Artifacts mismatch for { random_model [ 'name' ] } : { differences } "
323317 LOGGER .info ("Artifacts match" )
0 commit comments