|
2 | 2 |
|
3 | 3 | from rpdk.core.contract.interface import Action, HandlerErrorCode, OperationStatus
|
4 | 4 | from rpdk.core.contract.resource_client import (
|
| 5 | + create_model_with_properties_in_path, |
5 | 6 | prune_properties_from_model,
|
6 | 7 | prune_properties_if_not_exist_in_path,
|
7 | 8 | )
|
@@ -48,16 +49,22 @@ def test_create_failure_if_repeat_writeable_id(resource_client, current_resource
|
48 | 49 | @response_does_not_contain_write_only_properties
|
49 | 50 | @response_contains_resource_model_equal_current_model
|
50 | 51 | def test_read_success(resource_client, current_resource_model):
|
| 52 | + primay_identifier_only_model = create_model_with_properties_in_path( |
| 53 | + current_resource_model.copy(), resource_client.primary_identifier_paths, |
| 54 | + ) |
51 | 55 | _status, response, _error_code = resource_client.call_and_assert(
|
52 |
| - Action.READ, OperationStatus.SUCCESS, current_resource_model |
| 56 | + Action.READ, OperationStatus.SUCCESS, primay_identifier_only_model |
53 | 57 | )
|
54 | 58 | return response
|
55 | 59 |
|
56 | 60 |
|
57 | 61 | @failed_event(error_code=HandlerErrorCode.NotFound)
|
58 | 62 | def test_read_failure_not_found(resource_client, current_resource_model):
|
| 63 | + primay_identifier_only_model = create_model_with_properties_in_path( |
| 64 | + current_resource_model, resource_client.primary_identifier_paths, |
| 65 | + ) |
59 | 66 | _status, _response, error_code = resource_client.call_and_assert(
|
60 |
| - Action.READ, OperationStatus.FAILED, current_resource_model |
| 67 | + Action.READ, OperationStatus.FAILED, primay_identifier_only_model |
61 | 68 | )
|
62 | 69 | return error_code
|
63 | 70 |
|
@@ -116,30 +123,36 @@ def test_update_failure_not_found(resource_client, current_resource_model):
|
116 | 123 |
|
117 | 124 |
|
118 | 125 | def test_delete_success(resource_client, current_resource_model):
|
| 126 | + primay_identifier_only_model = create_model_with_properties_in_path( |
| 127 | + current_resource_model, resource_client.primary_identifier_paths, |
| 128 | + ) |
119 | 129 | _status, response, _error_code = resource_client.call_and_assert(
|
120 |
| - Action.DELETE, OperationStatus.SUCCESS, current_resource_model |
| 130 | + Action.DELETE, OperationStatus.SUCCESS, primay_identifier_only_model |
121 | 131 | )
|
122 | 132 | return response
|
123 | 133 |
|
124 | 134 |
|
125 | 135 | @failed_event(error_code=HandlerErrorCode.NotFound)
|
126 | 136 | def test_delete_failure_not_found(resource_client, current_resource_model):
|
| 137 | + primay_identifier_only_model = create_model_with_properties_in_path( |
| 138 | + current_resource_model, resource_client.primary_identifier_paths, |
| 139 | + ) |
127 | 140 | _status, _response, error_code = resource_client.call_and_assert(
|
128 |
| - Action.DELETE, OperationStatus.FAILED, current_resource_model |
| 141 | + Action.DELETE, OperationStatus.FAILED, primay_identifier_only_model |
129 | 142 | )
|
130 | 143 | return error_code
|
131 | 144 |
|
132 | 145 |
|
133 | 146 | def test_input_equals_output(resource_client, input_model, output_model):
|
134 |
| - input_model = prune_properties_from_model( |
135 |
| - input_model, resource_client.write_only_paths |
| 147 | + pruned_input_model = prune_properties_from_model( |
| 148 | + input_model.copy(), resource_client.write_only_paths |
136 | 149 | )
|
137 | 150 |
|
138 |
| - output_model = prune_properties_from_model( |
139 |
| - output_model, resource_client.read_only_paths |
| 151 | + pruned_output_model = prune_properties_if_not_exist_in_path( |
| 152 | + output_model.copy(), pruned_input_model, resource_client.read_only_paths |
140 | 153 | )
|
141 |
| - output_model = prune_properties_if_not_exist_in_path( |
142 |
| - output_model, input_model, resource_client.create_only_paths |
| 154 | + pruned_output_model = prune_properties_if_not_exist_in_path( |
| 155 | + pruned_output_model, pruned_input_model, resource_client.create_only_paths |
143 | 156 | )
|
144 | 157 |
|
145 |
| - assert input_model == output_model |
| 158 | + assert pruned_input_model == pruned_output_model |
0 commit comments