From b5a6e0ed22fccc10e69d7829b42e9f3223623763 Mon Sep 17 00:00:00 2001 From: Martin Kudlej Date: Thu, 15 May 2025 12:34:52 +0200 Subject: [PATCH 1/2] add annotation tests --- tests/integration/conftest.py | 13 +++++++++++-- tests/integration/test_integration_backends.py | 5 +++++ tests/integration/test_integration_custom_tenant.py | 5 +++++ tests/integration/test_integration_openapis.py | 9 +++++++++ tests/integration/test_integration_services.py | 5 +++++ 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 14e816f..ea7be03 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -94,8 +94,7 @@ def api( @pytest.fixture(scope="session") def api_origin( - url: str, token: str, ssl_verify: bool, ocp_provider_ref: str -) -> threescale_api.ThreeScaleClient: + url: str, token: str, ssl_verify: bool) -> threescale_api.ThreeScaleClient: return threescale_api.ThreeScaleClient(url=url, token=token, ssl_verify=ssl_verify) @@ -111,6 +110,16 @@ def master_api( ) +@pytest.fixture(scope="session") +def master_api_origin( + master_url: str, master_token: str, ssl_verify: bool) -> threescale_api.ThreeScaleClient: + return threescale_api.ThreeScaleClient( + url=master_url, + token=master_token, + ssl_verify=ssl_verify, + ) + + @pytest.fixture(scope="module") def apicast_http_client(application, proxy, ssl_verify): proxy.deploy() diff --git a/tests/integration/test_integration_backends.py b/tests/integration/test_integration_backends.py index 1c81b02..20e8b77 100644 --- a/tests/integration/test_integration_backends.py +++ b/tests/integration/test_integration_backends.py @@ -52,3 +52,8 @@ def test_backend_metrics_list(backend, backend_metric): def test_backend_mapping_rules_list(backend, backend_mapping_rule): assert backend.mapping_rules.list() + + +def test_backend_annotation(backend, api_origin): + backend_origin = api_origin.backends.fetch(backend.entity_id) + assert backend_origin['annotations']['managed_by'] == 'operator' diff --git a/tests/integration/test_integration_custom_tenant.py b/tests/integration/test_integration_custom_tenant.py index 6332b5a..624bdd4 100644 --- a/tests/integration/test_integration_custom_tenant.py +++ b/tests/integration/test_integration_custom_tenant.py @@ -47,3 +47,8 @@ def test_tenant_can_be_updated(api, custom_tenant): # end of tests important for CRD - CRU + list + + +def test_tenant_annotation(custom_tenant, master_api_origin): + tenant_origin = master_api_origin.tenants.read(custom_tenant.entity_id) + assert tenant_origin["signup"]["account"]["annotations"]["managed_by"] == "operator" diff --git a/tests/integration/test_integration_openapis.py b/tests/integration/test_integration_openapis.py index 560cc95..e24f5f8 100644 --- a/tests/integration/test_integration_openapis.py +++ b/tests/integration/test_integration_openapis.py @@ -33,3 +33,12 @@ def test_openapi_can_be_updated(api, openapi): # end of tests important for CRD - CRU + list + + +def test_openapi_annotation(openapi, api_origin): + service_origin = api_origin.services.fetch(openapi.service.entity_id) + assert service_origin['annotations']['managed_by'] == 'operator' + + for backend in openapi.backends: + backend_origin = api_origin.backends.fetch(backend.entity_id) + assert backend_origin['annotations']['managed_by'] == 'operator' diff --git a/tests/integration/test_integration_services.py b/tests/integration/test_integration_services.py index f080526..9369dfd 100644 --- a/tests/integration/test_integration_services.py +++ b/tests/integration/test_integration_services.py @@ -145,3 +145,8 @@ def test_service_active_docs(service, active_doc): assert all( [acs["service_id"] == service["id"] for acs in service.active_docs.list()] ) + + +def test_service_annotation(service, api_origin): + service_origin = api_origin.services.fetch(service.entity_id) + assert service_origin['annotations']['managed_by'] == 'operator' From ca475e1a77110db15076b40dd3cb1ac32e280d32 Mon Sep 17 00:00:00 2001 From: Martin Kudlej Date: Thu, 15 May 2025 12:35:58 +0200 Subject: [PATCH 2/2] fix bug in method init function --- threescale_api_crd/resources.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/threescale_api_crd/resources.py b/threescale_api_crd/resources.py index b6342b2..ae5288b 100644 --- a/threescale_api_crd/resources.py +++ b/threescale_api_crd/resources.py @@ -3212,10 +3212,10 @@ def __init__(self, entity_name="system_name", **kwargs): self.entity_id = entity["id"] super().__init__(crd=crd, entity=entity, entity_name=entity_name, **kwargs) - - # this is not here because of some backup, but because we need to have option - # to creater empty object without any data. This is related to "lazy load" - super().__init__(entity_name=entity_name, **kwargs) + else: + # this is not here because of some backup, but because we need to have option + # to creater empty object without any data. This is related to "lazy load" + super().__init__(entity_name=entity_name, **kwargs) @property def metric(self) -> "Metric":