Skip to content

Commit a9da519

Browse files
added tests
1 parent 75119e0 commit a9da519

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

tests/unitary/with_extras/aqua/test_model.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,3 +1654,44 @@ def test_build_search_text(self, description, tags, expected_output):
16541654
self.app._build_search_text(tags=tags, description=description)
16551655
== expected_output
16561656
)
1657+
1658+
@pytest.mark.parametrize(
1659+
"remove_indices, expected_len",
1660+
[
1661+
([], 2), # All models have AQUA_TAG -> include both
1662+
([1], 1), # Second model missing AQUA_TAG -> include first only
1663+
([0, 1], 0), # Both missing AQUA_TAG -> include none
1664+
],
1665+
)
1666+
@patch.object(AquaApp, "get_container_config")
1667+
def test_list_service_models_filters_missing_aqua_tag(
1668+
self,
1669+
mock_get_container_config,
1670+
remove_indices,
1671+
expected_len,
1672+
):
1673+
"""Ensure list() excludes models that do not have AQUA_TAG in freeform_tags."""
1674+
mock_get_container_config.return_value = get_container_config()
1675+
1676+
import copy
1677+
1678+
items = copy.deepcopy(TestDataset.model_summary_objects)
1679+
for idx in remove_indices:
1680+
# remove AQUA tag entirely to validate filter behavior
1681+
items[idx]["freeform_tags"].pop("OCI_AQUA", None)
1682+
1683+
self.app.list_resource = MagicMock(
1684+
return_value=[
1685+
oci.data_science.models.ModelSummary(**item) for item in items
1686+
]
1687+
)
1688+
1689+
# Clear service models cache
1690+
self.app.clear_model_list_cache()
1691+
1692+
results = self.app.list(
1693+
compartment_id=TestDataset.SERVICE_COMPARTMENT_ID,
1694+
category=ads.config.SERVICE,
1695+
)
1696+
1697+
assert len(results) == expected_len

0 commit comments

Comments
 (0)