Skip to content

Commit

Permalink
fix(converter): Fix serialization logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ewuerger committed Feb 29, 2024
1 parent 327f9c8 commit 21e56b3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
11 changes: 9 additions & 2 deletions capella2polarion/converters/element_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions tests/test_workitem_attachments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
)
Expand Down Expand Up @@ -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]
)
Expand Down

0 comments on commit 21e56b3

Please sign in to comment.