Skip to content

Commit f69e8b4

Browse files
authored
Merge pull request 3scale-qe#6 from mkudlej/add_annotation_tests
Add annotation tests
2 parents 5edccc5 + ca475e1 commit f69e8b4

File tree

6 files changed

+39
-6
lines changed

6 files changed

+39
-6
lines changed

tests/integration/conftest.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ def api(
9494

9595
@pytest.fixture(scope="session")
9696
def api_origin(
97-
url: str, token: str, ssl_verify: bool, ocp_provider_ref: str
98-
) -> threescale_api.ThreeScaleClient:
97+
url: str, token: str, ssl_verify: bool) -> threescale_api.ThreeScaleClient:
9998
return threescale_api.ThreeScaleClient(url=url, token=token, ssl_verify=ssl_verify)
10099

101100

@@ -111,6 +110,16 @@ def master_api(
111110
)
112111

113112

113+
@pytest.fixture(scope="session")
114+
def master_api_origin(
115+
master_url: str, master_token: str, ssl_verify: bool) -> threescale_api.ThreeScaleClient:
116+
return threescale_api.ThreeScaleClient(
117+
url=master_url,
118+
token=master_token,
119+
ssl_verify=ssl_verify,
120+
)
121+
122+
114123
@pytest.fixture(scope="module")
115124
def apicast_http_client(application, proxy, ssl_verify):
116125
proxy.deploy()

tests/integration/test_integration_backends.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,8 @@ def test_backend_metrics_list(backend, backend_metric):
5252

5353
def test_backend_mapping_rules_list(backend, backend_mapping_rule):
5454
assert backend.mapping_rules.list()
55+
56+
57+
def test_backend_annotation(backend, api_origin):
58+
backend_origin = api_origin.backends.fetch(backend.entity_id)
59+
assert backend_origin['annotations']['managed_by'] == 'operator'

tests/integration/test_integration_custom_tenant.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,8 @@ def test_tenant_can_be_updated(api, custom_tenant):
4747

4848

4949
# end of tests important for CRD - CRU + list
50+
51+
52+
def test_tenant_annotation(custom_tenant, master_api_origin):
53+
tenant_origin = master_api_origin.tenants.read(custom_tenant.entity_id)
54+
assert tenant_origin["signup"]["account"]["annotations"]["managed_by"] == "operator"

tests/integration/test_integration_openapis.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,12 @@ def test_openapi_can_be_updated(api, openapi):
3333

3434

3535
# end of tests important for CRD - CRU + list
36+
37+
38+
def test_openapi_annotation(openapi, api_origin):
39+
service_origin = api_origin.services.fetch(openapi.service.entity_id)
40+
assert service_origin['annotations']['managed_by'] == 'operator'
41+
42+
for backend in openapi.backends:
43+
backend_origin = api_origin.backends.fetch(backend.entity_id)
44+
assert backend_origin['annotations']['managed_by'] == 'operator'

tests/integration/test_integration_services.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,8 @@ def test_service_active_docs(service, active_doc):
145145
assert all(
146146
[acs["service_id"] == service["id"] for acs in service.active_docs.list()]
147147
)
148+
149+
150+
def test_service_annotation(service, api_origin):
151+
service_origin = api_origin.services.fetch(service.entity_id)
152+
assert service_origin['annotations']['managed_by'] == 'operator'

threescale_api_crd/resources.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3212,10 +3212,10 @@ def __init__(self, entity_name="system_name", **kwargs):
32123212

32133213
self.entity_id = entity["id"]
32143214
super().__init__(crd=crd, entity=entity, entity_name=entity_name, **kwargs)
3215-
3216-
# this is not here because of some backup, but because we need to have option
3217-
# to creater empty object without any data. This is related to "lazy load"
3218-
super().__init__(entity_name=entity_name, **kwargs)
3215+
else:
3216+
# this is not here because of some backup, but because we need to have option
3217+
# to creater empty object without any data. This is related to "lazy load"
3218+
super().__init__(entity_name=entity_name, **kwargs)
32193219

32203220
@property
32213221
def metric(self) -> "Metric":

0 commit comments

Comments
 (0)