Skip to content

Commit 2de8a7d

Browse files
authored
Compared create/update input to read output (#583)
1 parent 8a3af14 commit 2de8a7d

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

src/rpdk/core/contract/suite/handler_create.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def created_resource(resource_client):
3232
)
3333
model = response["resourceModel"]
3434
test_input_equals_output(resource_client, input_model, model)
35-
yield model, request
35+
yield input_model, model, request
3636
finally:
3737
resource_client.call_and_assert(Action.DELETE, OperationStatus.SUCCESS, model)
3838

@@ -76,21 +76,24 @@ def _create_with_invalid_model(resource_client):
7676
@pytest.mark.create
7777
@skip_not_writable_identifier
7878
def contract_create_duplicate(created_resource, resource_client):
79-
_created_model, request = created_resource
79+
_input_model, _created_model, request = created_resource
8080
test_create_failure_if_repeat_writeable_id(resource_client, request)
8181

8282

8383
@pytest.mark.create
8484
@pytest.mark.read
8585
def contract_create_read_success(created_resource, resource_client):
86-
created_model, _request = created_resource
87-
test_read_success(resource_client, created_model)
86+
input_model, created_model, _request = created_resource
87+
read_response = test_read_success(resource_client, created_model)
88+
test_input_equals_output(
89+
resource_client, input_model, read_response["resourceModel"]
90+
)
8891

8992

9093
@pytest.mark.create
9194
@pytest.mark.list
9295
@pytest.mark.read
9396
def contract_create_list_success(created_resource, resource_client):
94-
created_model, _request = created_resource
97+
_input_model, created_model, _request = created_resource
9598
assert test_model_in_list(resource_client, created_model)
9699
test_read_success(resource_client, created_model)

src/rpdk/core/contract/suite/handler_update.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ def updated_resource(resource_client):
3232
updated_model = response["resourceModel"]
3333
test_input_equals_output(resource_client, updated_input_model, updated_model)
3434

35-
yield create_request, created_model, update_request, updated_model
35+
# flake8: noqa: B950
36+
# pylint: disable=C0301
37+
yield create_request, created_model, update_request, updated_model, updated_input_model
3638
finally:
3739
resource_client.call_and_assert(Action.DELETE, OperationStatus.SUCCESS, model)
3840

@@ -42,20 +44,35 @@ def updated_resource(resource_client):
4244
def contract_update_read_success(updated_resource, resource_client):
4345
# should be able to use the created model
4446
# to read since physical resource id is immutable
45-
_create_request, _created_model, _update_request, updated_model = updated_resource
47+
(
48+
_create_request,
49+
_created_model,
50+
_update_request,
51+
updated_model,
52+
updated_input_model,
53+
) = updated_resource
4654
assert resource_client.is_primary_identifier_equal(
4755
resource_client.primary_identifier_paths, _created_model, updated_model
4856
), "The primaryIdentifier returned must match\
4957
the primaryIdentifier passed into the request"
50-
test_read_success(resource_client, updated_model)
58+
read_response = test_read_success(resource_client, updated_model)
59+
test_input_equals_output(
60+
resource_client, updated_input_model, read_response["resourceModel"]
61+
)
5162

5263

5364
@pytest.mark.update
5465
@pytest.mark.list
5566
def contract_update_list_success(updated_resource, resource_client):
5667
# should be able to use the created model
5768
# to read since physical resource id is immutable
58-
_create_request, _created_model, _update_request, updated_model = updated_resource
69+
(
70+
_create_request,
71+
_created_model,
72+
_update_request,
73+
updated_model,
74+
_updated_input_model,
75+
) = updated_resource
5976
assert resource_client.is_primary_identifier_equal(
6077
resource_client.primary_identifier_paths, _created_model, updated_model
6178
), "The primaryIdentifier returned must match\

0 commit comments

Comments
 (0)