From 33dbc1098ba6409e5cf7fdb128eb453262cf49bf Mon Sep 17 00:00:00 2001 From: Lukasz Lancucki Date: Wed, 1 Apr 2026 13:52:48 +0100 Subject: [PATCH] test(helpdesk): refactor fixtures and unskip chat attachment tests --- tests/e2e/helpdesk/cases/conftest.py | 52 ------------------- .../e2e/helpdesk/chats/attachment/conftest.py | 8 +-- .../chats/attachment/test_async_attachment.py | 12 ++--- .../chats/attachment/test_sync_attachment.py | 12 ++--- tests/e2e/helpdesk/chats/messages/conftest.py | 8 +-- tests/e2e/helpdesk/conftest.py | 50 ++++++++++++++++++ 6 files changed, 66 insertions(+), 76 deletions(-) delete mode 100644 tests/e2e/helpdesk/cases/conftest.py diff --git a/tests/e2e/helpdesk/cases/conftest.py b/tests/e2e/helpdesk/cases/conftest.py deleted file mode 100644 index 31ae33ea..00000000 --- a/tests/e2e/helpdesk/cases/conftest.py +++ /dev/null @@ -1,52 +0,0 @@ -import pytest - - -@pytest.fixture(scope="session") -def invalid_case_id(): - return "CAS-0000-0000" - - -@pytest.fixture -def case_factory(short_uuid, created_queue): - def factory( - title: str = "E2E Created Helpdesk Case", - description: str = "E2E Created Helpdesk Case Description", - ): - return { - "queue": {"id": created_queue.id}, - "chat": {"lastMessage": {"content": "E2E testing!!!"}}, - } - - return factory - - -@pytest.fixture -def created_case(mpt_ops, case_factory): - return mpt_ops.helpdesk.cases.create(case_factory()) - - -@pytest.fixture -def queried_case(mpt_ops, created_case): - return mpt_ops.helpdesk.cases.query(created_case.id, {"queryPrompt": "More details needed"}) - - -@pytest.fixture -def processed_case(mpt_ops, queried_case): - return mpt_ops.helpdesk.cases.process(queried_case.id) - - -@pytest.fixture -async def async_created_case(async_mpt_ops, case_factory): - return await async_mpt_ops.helpdesk.cases.create(case_factory()) - - -@pytest.fixture -async def async_queried_case(async_mpt_ops, async_created_case): - return await async_mpt_ops.helpdesk.cases.query( - async_created_case.id, {"queryPrompt": "More details needed"} - ) - - -@pytest.fixture -async def async_processed_case(async_mpt_ops, async_queried_case): - return await async_mpt_ops.helpdesk.cases.process(async_queried_case.id) diff --git a/tests/e2e/helpdesk/chats/attachment/conftest.py b/tests/e2e/helpdesk/chats/attachment/conftest.py index cff46a34..e9329ac0 100644 --- a/tests/e2e/helpdesk/chats/attachment/conftest.py +++ b/tests/e2e/helpdesk/chats/attachment/conftest.py @@ -4,13 +4,13 @@ @pytest.fixture -def chat_attachments_service(mpt_ops, chat_id): - return mpt_ops.helpdesk.chats.attachments(chat_id) +def chat_attachments_service(mpt_ops, created_chat): + return mpt_ops.helpdesk.chats.attachments(created_chat.id) @pytest.fixture -def async_chat_attachments_service(async_mpt_ops, chat_id): - return async_mpt_ops.helpdesk.chats.attachments(chat_id) +def async_chat_attachments_service(async_mpt_ops, created_chat): + return async_mpt_ops.helpdesk.chats.attachments(created_chat.id) @pytest.fixture diff --git a/tests/e2e/helpdesk/chats/attachment/test_async_attachment.py b/tests/e2e/helpdesk/chats/attachment/test_async_attachment.py index 8e2d4f2c..b11087b0 100644 --- a/tests/e2e/helpdesk/chats/attachment/test_async_attachment.py +++ b/tests/e2e/helpdesk/chats/attachment/test_async_attachment.py @@ -8,7 +8,6 @@ pytestmark = [pytest.mark.flaky] -@pytest.mark.skip(reason="Unskip after MPT-19124 completed") async def test_list_chat_attachments(async_chat_attachments_service, async_created_chat_attachment): result = await async_chat_attachments_service.fetch_page(limit=1) @@ -16,20 +15,17 @@ async def test_list_chat_attachments(async_chat_attachments_service, async_creat assert all(isinstance(attachment, ChatAttachment) for attachment in result) -@pytest.mark.skip(reason="Unskip after MPT-19124 completed") # noqa: AAA01 -def test_create_chat_attachment(async_created_chat_attachment, chat_attachment_data): +def test_create_chat_attachment(async_created_chat_attachment, chat_attachment_data): # noqa: AAA01 assert async_created_chat_attachment.id is not None assert async_created_chat_attachment.to_dict().get("name") == chat_attachment_data["name"] -@pytest.mark.skip(reason="Unskip after MPT-19124 completed") async def test_get_chat_attachment(async_chat_attachments_service, async_created_chat_attachment): result = await async_chat_attachments_service.get(async_created_chat_attachment.id) assert result.id == async_created_chat_attachment.id -@pytest.mark.skip(reason="Unskip after MPT-19124 completed") async def test_update_chat_attachment( async_chat_attachments_service, async_created_chat_attachment, short_uuid ): @@ -44,7 +40,6 @@ async def test_update_chat_attachment( assert result.to_dict().get("name") == updated_name -@pytest.mark.skip(reason="Unskip after MPT-19124 completed") async def test_download_chat_attachment( async_chat_attachments_service, async_created_chat_attachment ): @@ -56,11 +51,12 @@ async def test_download_chat_attachment( assert result.file_contents is not None -@pytest.mark.skip(reason="Unskip after MPT-19124 completed") async def test_delete_chat_attachment(async_chat_attachments_service, chat_attachment_data, pdf_fd): created = await async_chat_attachments_service.create(chat_attachment_data, file=pdf_fd) - await async_chat_attachments_service.delete(created.id) + result = await async_chat_attachments_service.delete(created.id) + + assert result is None async def test_get_chat_attachment_not_found( diff --git a/tests/e2e/helpdesk/chats/attachment/test_sync_attachment.py b/tests/e2e/helpdesk/chats/attachment/test_sync_attachment.py index 25748331..e82b1c6a 100644 --- a/tests/e2e/helpdesk/chats/attachment/test_sync_attachment.py +++ b/tests/e2e/helpdesk/chats/attachment/test_sync_attachment.py @@ -8,7 +8,6 @@ pytestmark = [pytest.mark.flaky] -@pytest.mark.skip(reason="Unskip after MPT-19124 completed") def test_list_chat_attachments(chat_attachments_service, created_chat_attachment): result = chat_attachments_service.fetch_page(limit=1) @@ -16,20 +15,17 @@ def test_list_chat_attachments(chat_attachments_service, created_chat_attachment assert all(isinstance(attachment, ChatAttachment) for attachment in result) -@pytest.mark.skip(reason="Unskip after MPT-19124 completed") # noqa: AAA01 -def test_create_chat_attachment(created_chat_attachment, chat_attachment_data): +def test_create_chat_attachment(created_chat_attachment, chat_attachment_data): # noqa: AAA01 assert created_chat_attachment.id is not None assert created_chat_attachment.to_dict().get("name") == chat_attachment_data["name"] -@pytest.mark.skip(reason="Unskip after MPT-19124 completed") def test_get_chat_attachment(chat_attachments_service, created_chat_attachment): result = chat_attachments_service.get(created_chat_attachment.id) assert result.id == created_chat_attachment.id -@pytest.mark.skip(reason="Unskip after MPT-19124 completed") def test_update_chat_attachment(chat_attachments_service, created_chat_attachment, short_uuid): updated_name = f"e2e updated attachment - {short_uuid}" @@ -42,18 +38,18 @@ def test_update_chat_attachment(chat_attachments_service, created_chat_attachmen assert result.to_dict().get("name") == updated_name -@pytest.mark.skip(reason="Unskip after MPT-19124 completed") def test_download_chat_attachment(chat_attachments_service, created_chat_attachment): result = chat_attachments_service.download(created_chat_attachment.id, accept="application/pdf") assert result.file_contents is not None -@pytest.mark.skip(reason="Unskip after MPT-19124 completed") # noqa: AAA01 def test_delete_chat_attachment(chat_attachments_service, chat_attachment_data, pdf_fd): created = chat_attachments_service.create(chat_attachment_data, file=pdf_fd) - chat_attachments_service.delete(created.id) + result = chat_attachments_service.delete(created.id) + + assert result is None def test_get_chat_attachment_not_found(chat_attachments_service, invalid_chat_attachment_id): diff --git a/tests/e2e/helpdesk/chats/messages/conftest.py b/tests/e2e/helpdesk/chats/messages/conftest.py index 71949546..fb2d7a53 100644 --- a/tests/e2e/helpdesk/chats/messages/conftest.py +++ b/tests/e2e/helpdesk/chats/messages/conftest.py @@ -7,13 +7,13 @@ @pytest.fixture -def chat_messages_service(mpt_ops, chat_id): - return mpt_ops.helpdesk.chats.messages(chat_id) +def chat_messages_service(mpt_ops, created_chat): + return mpt_ops.helpdesk.chats.messages(created_chat.id) @pytest.fixture -def async_chat_messages_service(async_mpt_ops, chat_id): - return async_mpt_ops.helpdesk.chats.messages(chat_id) +def async_chat_messages_service(async_mpt_ops, created_chat): + return async_mpt_ops.helpdesk.chats.messages(created_chat.id) @pytest.fixture diff --git a/tests/e2e/helpdesk/conftest.py b/tests/e2e/helpdesk/conftest.py index dfefff60..24dc952d 100644 --- a/tests/e2e/helpdesk/conftest.py +++ b/tests/e2e/helpdesk/conftest.py @@ -48,3 +48,53 @@ async def async_created_disabled_queue(async_mpt_ops, async_created_queue): assert result.status == "Disabled" return result + + +@pytest.fixture(scope="session") +def invalid_case_id(): + return "CAS-0000-0000" + + +@pytest.fixture +def case_data(created_queue): + return { + "queue": {"id": created_queue.id}, + "chat": {"lastMessage": {"content": "E2E testing!!!"}}, + } + + +@pytest.fixture +def created_case(mpt_ops, case_data): + return mpt_ops.helpdesk.cases.create(case_data) + + +@pytest.fixture +def queried_case(mpt_ops, created_case): + return mpt_ops.helpdesk.cases.query(created_case.id, {"queryPrompt": "More details needed"}) + + +@pytest.fixture +def processed_case(mpt_ops, queried_case): + return mpt_ops.helpdesk.cases.process(queried_case.id) + + +@pytest.fixture +def created_chat(created_case): + return created_case.chat + + +@pytest.fixture +async def async_created_case(async_mpt_ops, case_data): + return await async_mpt_ops.helpdesk.cases.create(case_data) + + +@pytest.fixture +async def async_queried_case(async_mpt_ops, async_created_case): + return await async_mpt_ops.helpdesk.cases.query( + async_created_case.id, {"queryPrompt": "More details needed"} + ) + + +@pytest.fixture +async def async_processed_case(async_mpt_ops, async_queried_case): + return await async_mpt_ops.helpdesk.cases.process(async_queried_case.id)