From 91522b75a0945eb854fd2158f4d5a4af649f91f9 Mon Sep 17 00:00:00 2001 From: Kevin DeJong Date: Fri, 6 Oct 2023 14:07:46 -0700 Subject: [PATCH] More formatting fixes --- src/rpdk/core/contract/resource_client.py | 14 +++++++------- .../contract/suite/resource/contract_asserts.py | 8 ++++---- .../contract/suite/resource/handler_commons.py | 16 ++++++++-------- .../contract/suite/resource/handler_update.py | 2 +- .../suite/resource/handler_update_invalid.py | 5 ++--- 5 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/rpdk/core/contract/resource_client.py b/src/rpdk/core/contract/resource_client.py index 743a23c1..aada0d5a 100644 --- a/src/rpdk/core/contract/resource_client.py +++ b/src/rpdk/core/contract/resource_client.py @@ -290,7 +290,7 @@ def assert_write_only_property_does_not_exist(self, resource_model): assertion_error_message = ( "The model MUST NOT return properties defined as writeOnlyProperties" " in the resource schema \n Write only properties in resource model :" - f" {error_list} \n Output Resource Model : {{resource_model}} \n" + f" {error_list} \n Output Resource Model : {resource_model} \n" ) assert not any(error_list), assertion_error_message @@ -486,7 +486,7 @@ def compare_model(self, inputs, outputs, path=()): assertion_error_message = ( f"{assertion_error_message} Value for property {key} in" f" Request Model({inputs[key]}) and Response" - " Model({outputs[key]}) does not match" + f" Model({outputs[key]}) does not match" ) assert inputs[key] == outputs[key], assertion_error_message else: @@ -636,8 +636,8 @@ def is_primary_identifier_equal( ) except KeyError as e: raise AssertionError( - "The primaryIdentifier returned in every progress event must " - " match the primaryIdentifier passed into the request" + "The primaryIdentifier returned in every progress event must " + "match the primaryIdentifier passed into the request" ) from e @staticmethod @@ -652,8 +652,8 @@ def get_primary_identifier(primary_identifier_path, model): return pid_list except KeyError as e: raise AssertionError( - "The primaryIdentifier returned in every progress event must " - " match the primaryIdentifier passed into the request \n" + "The primaryIdentifier returned in every progress event must " + "match the primaryIdentifier passed into the request \n" ) from e def _make_payload( @@ -751,7 +751,7 @@ def call_and_assert( if not self.has_required_handlers(): raise ValueError("Create/Read/Delete handlers are required") if assert_status not in [OperationStatus.SUCCESS, OperationStatus.FAILED]: - raise ValueError("Assert status {assert_status} not supported.") + raise ValueError(f"Assert status {assert_status} not supported.") status, response = self.call(action, current_model, previous_model, **kwargs) if assert_status == OperationStatus.SUCCESS: diff --git a/src/rpdk/core/contract/suite/resource/contract_asserts.py b/src/rpdk/core/contract/suite/resource/contract_asserts.py index 5089a790..bf813850 100644 --- a/src/rpdk/core/contract/suite/resource/contract_asserts.py +++ b/src/rpdk/core/contract/suite/resource/contract_asserts.py @@ -16,9 +16,9 @@ def response_contains_resource_model_equal_updated_model( **current_resource_model, **update_resource_model, }, ( - "All properties specified in the update request MUST be present in the " - " model returned, and they MUST match exactly, with the exception of " - " properties defined as writeOnlyProperties in the resource schema" + "All properties specified in the update request MUST be present in the " + "model returned, and they MUST match exactly, with the exception of " + "properties defined as writeOnlyProperties in the resource schema" ) @@ -38,7 +38,7 @@ def response_contains_unchanged_primary_identifier( current_resource_model, response["resourceModel"], ), ( - "PrimaryIdentifier returned in every progress event must match the" + "PrimaryIdentifier returned in every progress event must match the" " primaryIdentifier passed into the request" ) diff --git a/src/rpdk/core/contract/suite/resource/handler_commons.py b/src/rpdk/core/contract/suite/resource/handler_commons.py index 709939fb..bc4fc430 100644 --- a/src/rpdk/core/contract/suite/resource/handler_commons.py +++ b/src/rpdk/core/contract/suite/resource/handler_commons.py @@ -29,8 +29,8 @@ def test_create_success(resource_client, current_resource_model): @failed_event( error_code=HandlerErrorCode.AlreadyExists, msg=( - "A create handler MUST NOT create multiple resources given the same" - " idempotency token" + "A create handler MUST NOT create multiple resources given the same " + "idempotency token" ), ) def test_create_failure_if_repeat_writeable_id(resource_client, current_resource_model): @@ -61,8 +61,8 @@ def test_read_success(resource_client, current_resource_model): @failed_event( error_code=HandlerErrorCode.NotFound, msg=( - "A read handler MUST return FAILED with a NotFound error code if the" - " resource does not exist" + "A read handler MUST return FAILED with a NotFound error code if the " + "resource does not exist" ), ) def test_read_failure_not_found( @@ -144,8 +144,8 @@ def test_update_success(resource_client, update_resource_model, current_resource @failed_event( error_code=HandlerErrorCode.NotFound, msg=( - "An update handler MUST return FAILED with a NotFound error code if the" - " resource did not exist prior to the update request" + "An update handler MUST return FAILED with a NotFound error code if the " + "resource did not exist prior to the update request" ), ) def test_update_failure_not_found(resource_client, current_resource_model): @@ -166,8 +166,8 @@ def test_delete_success(resource_client, current_resource_model): @failed_event( error_code=HandlerErrorCode.NotFound, msg=( - "A delete hander MUST return FAILED with a NotFound error code if the" - " resource did not exist prior to the delete request" + "A delete hander MUST return FAILED with a NotFound error code if the " + "resource did not exist prior to the delete request" ), ) def test_delete_failure_not_found(resource_client, current_resource_model): diff --git a/src/rpdk/core/contract/suite/resource/handler_update.py b/src/rpdk/core/contract/suite/resource/handler_update.py index 283b5f62..74edddb6 100644 --- a/src/rpdk/core/contract/suite/resource/handler_update.py +++ b/src/rpdk/core/contract/suite/resource/handler_update.py @@ -93,7 +93,7 @@ def contract_update_list(updated_resource, resource_client): assert resource_client.is_primary_identifier_equal( resource_client.primary_identifier_paths, _created_model, updated_model ), ( - "The primaryIdentifier returned must match the primaryIdentifier passed" + "The primaryIdentifier returned must match the primaryIdentifier passed" " into the request" ) assert test_model_in_list(resource_client, updated_model), error_test_model_in_list( diff --git a/src/rpdk/core/contract/suite/resource/handler_update_invalid.py b/src/rpdk/core/contract/suite/resource/handler_update_invalid.py index f217a826..7e7766c7 100644 --- a/src/rpdk/core/contract/suite/resource/handler_update_invalid.py +++ b/src/rpdk/core/contract/suite/resource/handler_update_invalid.py @@ -17,7 +17,7 @@ def contract_update_without_create(resource_client): @failed_event( error_code=HandlerErrorCode.NotFound, msg=( - "An update handler MUST return FAILED with a NotFound error code if the" + "An update handler MUST return FAILED with a NotFound error code if the" " resource did not exist prior to the update request" ), ) @@ -28,8 +28,7 @@ def test_update_without_create(resource_client): Action.UPDATE, OperationStatus.FAILED, update_request, create_request ) assert response["message"], ( - "The progress event MUST return an error message when the status is" - " failed" + "The progress event MUST return an error message when the status is" " failed" ) return _error