Skip to content

Commit

Permalink
test: add additional tests for new features
Browse files Browse the repository at this point in the history
  • Loading branch information
micha91 committed Sep 4, 2024
1 parent 22a5a59 commit 1b775ba
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/data/documents/mixed_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ mixed_authority:
section1: test-icd.html.j2
section2: test-icd.html.j2
heading_numbering: True
text_work_item_type: myType
text_work_item_id_field: myId
work_item_layouts:
componentExchange:
fields_at_start:
Expand Down
4 changes: 4 additions & 0 deletions tests/test_documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,10 @@ def test_mixed_authority_document_config():
}
assert conf.mixed_authority[1].project_id is None
assert conf.mixed_authority[1].status_allow_list is None
assert conf.mixed_authority[0].text_work_item_type == "text"
assert conf.mixed_authority[0].text_work_item_id_field == "__C2P__id"
assert conf.mixed_authority[1].text_work_item_type == "myType"
assert conf.mixed_authority[1].text_work_item_id_field == "myId"


def test_combined_config():
Expand Down
34 changes: 34 additions & 0 deletions tests/test_polarion_worker_documents.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright DB InfraGO AG and contributors
# SPDX-License-Identifier: Apache-2.0
from unittest import mock

import polarion_rest_api_client as polarion_api

Expand Down Expand Up @@ -106,3 +107,36 @@ def test_create_document(
assert client.work_items.update.call_count == 2
assert len(client.work_items.update.call_args_list[0].args[0]) == 0
assert len(client.work_items.update.call_args_list[1].args[0]) == 0


def test_use_correct_client(
empty_polarion_worker: polarion_worker.CapellaPolarionWorker,
):
empty_polarion_worker.project_client = mock.MagicMock()
document = polarion_api.Document(
module_folder="_default",
module_name="TEST-DOC-A",
rendering_layouts=[],
home_page_content=polarion_api.TextContent(
type="text/html",
value="",
),
)

document_data = data_models.DocumentData(
document,
[],
text_work_item_provider.TextWorkItemProvider(),
)

empty_polarion_worker.create_documents([document_data], "OtherProject")
empty_polarion_worker.update_documents([document_data], "OtherProject")

assert len(empty_polarion_worker.project_client.method_calls) == 0
assert len(empty_polarion_worker._additional_clients) == 1
assert (
client := empty_polarion_worker._additional_clients.get("OtherProject")
)
assert client.documents.update.call_count == 1
assert client.documents.create.call_count == 1
assert client.work_items.update.call_count == 1

0 comments on commit 1b775ba

Please sign in to comment.