diff --git a/tests/data/documents/mixed_config.yaml b/tests/data/documents/mixed_config.yaml index fb346aa..f3ca058 100644 --- a/tests/data/documents/mixed_config.yaml +++ b/tests/data/documents/mixed_config.yaml @@ -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: diff --git a/tests/test_documents.py b/tests/test_documents.py index 69e046f..5069b46 100644 --- a/tests/test_documents.py +++ b/tests/test_documents.py @@ -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(): diff --git a/tests/test_polarion_worker_documents.py b/tests/test_polarion_worker_documents.py index 949ca9f..714847b 100644 --- a/tests/test_polarion_worker_documents.py +++ b/tests/test_polarion_worker_documents.py @@ -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 @@ -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