diff --git a/capella2polarion/connectors/polarion_worker.py b/capella2polarion/connectors/polarion_worker.py index 352d874..4576cdf 100644 --- a/capella2polarion/connectors/polarion_worker.py +++ b/capella2polarion/connectors/polarion_worker.py @@ -85,7 +85,7 @@ def __init__( self.project_client = self.polarion_client.generate_project_client( project_id=self.polarion_params.project_id, delete_status=( - "deleted" if self.polarion_params.delete_work_items else None + None if self.polarion_params.delete_work_items else "deleted" ), ) self._additional_clients: dict[str, polarion_api.ProjectClient] = {} diff --git a/tests/test_worker.py b/tests/test_worker.py new file mode 100644 index 0000000..052fa9c --- /dev/null +++ b/tests/test_worker.py @@ -0,0 +1,36 @@ +# Copyright DB InfraGO AG and contributors +# SPDX-License-Identifier: Apache-2.0 + +from unittest import mock + +from capella2polarion.connectors import polarion_worker + + +def test_polarion_worker_non_delete_mode(): + with mock.patch.object( + polarion_worker.CapellaPolarionWorker, "check_client" + ): + worker = polarion_worker.CapellaPolarionWorker( + polarion_worker.PolarionWorkerParams( + project_id="TEST", + url="http://127.0.0.1", + pat="PrivateAccessToken", + delete_work_items=False, + ) + ) + assert worker.project_client.work_items.delete_status == "deleted" + + +def test_polarion_worker_delete_mode(): + with mock.patch.object( + polarion_worker.CapellaPolarionWorker, "check_client" + ): + worker = polarion_worker.CapellaPolarionWorker( + polarion_worker.PolarionWorkerParams( + project_id="TEST", + url="http://127.0.0.1", + pat="PrivateAccessToken", + delete_work_items=True, + ) + ) + assert worker.project_client.work_items.delete_status is None