From 21e56b32b4c3dd1cf21e058e9003916cd5cf547d Mon Sep 17 00:00:00 2001 From: ewuerger Date: Thu, 29 Feb 2024 13:41:25 +0100 Subject: [PATCH] fix(converter): Fix serialization logging --- capella2polarion/converters/element_converter.py | 11 +++++++++-- tests/test_workitem_attachments.py | 12 ++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/capella2polarion/converters/element_converter.py b/capella2polarion/converters/element_converter.py index 2fa8b248..a093e2c3 100644 --- a/capella2polarion/converters/element_converter.py +++ b/capella2polarion/converters/element_converter.py @@ -145,11 +145,18 @@ def serialize(self, uuid: str) -> data_models.CapellaWorkItem | None: converter_data.work_item = None if converter_data.errors: - logger.error( - "Serialization of %r successful, but with warnings: \n\t %s", + log_args = ( converter_data.capella_element._short_repr_(), "\n\t".join(converter_data.errors), ) + if converter_data.work_item is None: + logger.error("Serialization of %r failed:\n\t %s", *log_args) + else: + logger.warning( + "Serialization of %r successful, but with warnings:" + "\n\t %s", + *log_args, + ) return converter_data.work_item # General helper functions diff --git a/tests/test_workitem_attachments.py b/tests/test_workitem_attachments.py index f51bf46f..ab609cd8 100644 --- a/tests/test_workitem_attachments.py +++ b/tests/test_workitem_attachments.py @@ -138,9 +138,9 @@ def test_diagram_attachments_new( assert worker.client.create_work_item_attachments.call_count == 1 assert worker.client.get_all_work_item_attachments.call_count == 0 - created_attachments: list[ - polarion_api.WorkItemAttachment - ] = worker.client.create_work_item_attachments.call_args.args[0] + created_attachments: list[polarion_api.WorkItemAttachment] = ( + worker.client.create_work_item_attachments.call_args.args[0] + ) work_item: data_models.CapellaWorkItem = ( worker.client.update_work_item.call_args.args[0] ) @@ -340,9 +340,9 @@ def test_add_context_diagram( assert worker.client.update_work_item.call_count == 1 assert worker.client.create_work_item_attachments.call_count == 1 - created_attachments: list[ - polarion_api.WorkItemAttachment - ] = worker.client.create_work_item_attachments.call_args.args[0] + created_attachments: list[polarion_api.WorkItemAttachment] = ( + worker.client.create_work_item_attachments.call_args.args[0] + ) work_item: data_models.CapellaWorkItem = ( worker.client.update_work_item.call_args.args[0] )