Skip to content

Commit

Permalink
fix: delete work item logic (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
micha91 authored Oct 25, 2024
1 parent 1e0589e commit 68ffb72
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion capella2polarion/connectors/polarion_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {}
Expand Down
36 changes: 36 additions & 0 deletions tests/test_worker.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 68ffb72

Please sign in to comment.