Skip to content

Commit f206021

Browse files
authored
test: source returned regardless of their status (opendatahub-io#996)
* test: source returned regardless of their status * fix: add single test to retrieve disabled and enabled sources
1 parent 7366095 commit f206021

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

tests/model_registry/model_catalog/metadata/test_sources_endpoint.py

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313

1414
class TestSourcesEndpoint:
15-
"""Test class for the model catalog sources endpoint status and error fields, RHOAIENG-41849."""
15+
"""Test class for the model catalog sources endpoint."""
1616

1717
@pytest.mark.smoke
1818
def test_available_source_status(
@@ -22,7 +22,7 @@ def test_available_source_status(
2222
model_registry_rest_headers: dict[str, str],
2323
):
2424
"""
25-
Test that the sources endpoint returns no error for available sources.
25+
RHOAIENG-41849: Test that the sources endpoint returns no error for available sources.
2626
"""
2727
response = execute_get_command(url=f"{model_catalog_rest_url[0]}sources", headers=model_registry_rest_headers)
2828
items = response.get("items", [])
@@ -47,6 +47,7 @@ def test_disabled_source_status(
4747
model_registry_rest_headers: dict[str, str],
4848
):
4949
"""
50+
RHOAIENG-41849:
5051
This test disables an existing catalog and verifies:
5152
- status field is "disabled"
5253
- error field is null or empty
@@ -73,3 +74,35 @@ def test_disabled_source_status(
7374
f"Status: {disabled_catalog.get('status')}, "
7475
f"Error: {error_value}"
7576
)
77+
78+
@pytest.mark.parametrize("disabled_catalog_source", ["redhat_ai_models"], indirect=True)
79+
@pytest.mark.sanity
80+
def test_sources_endpoint_returns_all_sources_regardless_of_enabled_field(
81+
self,
82+
enabled_model_catalog_config_map: ConfigMap,
83+
disabled_catalog_source: str,
84+
model_catalog_rest_url: list[str],
85+
model_registry_rest_headers: dict[str, str],
86+
):
87+
"""
88+
RHOAIENG-41633: Test that sources endpoint returns ALL sources regardless of enabled field value.
89+
"""
90+
response = execute_get_command(url=f"{model_catalog_rest_url[0]}sources", headers=model_registry_rest_headers)
91+
items = response.get("items", [])
92+
93+
assert len(items) > 1, "Expected multiple sources to be returned"
94+
95+
# Verify we have at least one enabled source
96+
enabled_sources = [item for item in items if item.get("status") == "available"]
97+
assert enabled_sources, "Expected at least one enabled source"
98+
99+
# Verify we have at least one disabled source
100+
disabled_sources = [item for item in items if item.get("status") == "disabled"]
101+
assert disabled_sources, "Expected at least one disabled source"
102+
103+
assert len(enabled_sources) + len(disabled_sources) == len(items), "Expected all sources to be returned"
104+
105+
LOGGER.info(
106+
f"Sources endpoint returned {len(items)} total sources: "
107+
f"{len(enabled_sources)} enabled, {len(disabled_sources)} disabled"
108+
)

0 commit comments

Comments
 (0)