|
1 | 1 | import pytest |
2 | | -import yaml |
3 | | - |
| 2 | +from typing import Any |
4 | 3 | from kubernetes.dynamic import DynamicClient |
5 | 4 | from simple_logger.logger import get_logger |
6 | 5 |
|
7 | | -from ocp_resources.config_map import ConfigMap |
8 | | -from ocp_resources.resource import ResourceEditor |
9 | 6 |
|
10 | 7 | from utilities.infra import get_openshift_token |
11 | 8 | from timeout_sampler import TimeoutSampler |
@@ -51,45 +48,24 @@ def test_labels_endpoint_configmap_updates( |
51 | 48 | admin_client: DynamicClient, |
52 | 49 | model_registry_namespace: str, |
53 | 50 | model_catalog_rest_url: list[str], |
| 51 | + labels_configmap_patch: dict[str, Any], |
54 | 52 | ): |
55 | 53 | """ |
56 | 54 | Sanity test: Edit the editable ConfigMap and verify changes are reflected in API. |
57 | 55 | """ |
| 56 | + _ = labels_configmap_patch |
58 | 57 |
|
59 | | - # Get the editable ConfigMap |
60 | | - sources_cm = ConfigMap(name="model-catalog-sources", client=admin_client, namespace=model_registry_namespace) |
61 | | - |
62 | | - # Parse current data and add test label |
63 | | - current_data = yaml.safe_load(sources_cm.instance.data["sources.yaml"]) |
64 | | - |
65 | | - new_label = { |
66 | | - "name": "test-dynamic", |
67 | | - "displayName": "Dynamic Test Label", |
68 | | - "description": "A label added during test execution", |
69 | | - } |
70 | | - |
71 | | - if "labels" not in current_data: |
72 | | - current_data["labels"] = [] |
73 | | - current_data["labels"].append(new_label) |
74 | | - |
75 | | - # Update ConfigMap temporarily |
76 | | - patches = {"data": {"sources.yaml": yaml.dump(current_data, default_flow_style=False)}} |
77 | | - |
78 | | - with ResourceEditor(patches={sources_cm: patches}): |
79 | | - |
80 | | - def _check_updated_labels(): |
81 | | - # Get updated expected labels from ConfigMaps |
82 | | - expected_labels = get_labels_from_configmaps( |
83 | | - admin_client=admin_client, namespace=model_registry_namespace |
84 | | - ) |
| 58 | + def _check_updated_labels(): |
| 59 | + # Get updated expected labels from ConfigMaps |
| 60 | + expected_labels = get_labels_from_configmaps(admin_client=admin_client, namespace=model_registry_namespace) |
85 | 61 |
|
86 | | - # Get labels from API |
87 | | - api_labels = get_labels_from_api( |
88 | | - model_catalog_rest_url=model_catalog_rest_url[0], user_token=get_openshift_token() |
89 | | - ) |
| 62 | + # Get labels from API |
| 63 | + api_labels = get_labels_from_api( |
| 64 | + model_catalog_rest_url=model_catalog_rest_url[0], user_token=get_openshift_token() |
| 65 | + ) |
90 | 66 |
|
91 | | - # Verify they match (including the new label) |
92 | | - verify_labels_match(expected_labels=expected_labels, api_labels=api_labels) |
| 67 | + # Verify they match (including the new label) |
| 68 | + verify_labels_match(expected_labels=expected_labels, api_labels=api_labels) |
93 | 69 |
|
94 | | - sampler = TimeoutSampler(wait_timeout=60, sleep=5, func=_check_updated_labels) |
95 | | - next(iter(sampler)) |
| 70 | + sampler = TimeoutSampler(wait_timeout=60, sleep=5, func=_check_updated_labels) |
| 71 | + next(iter(sampler)) |
0 commit comments