Skip to content

Commit f68f705

Browse files
committed
test(helpdesk): refactor fixtures and unskip chat attachment tests
1 parent b800126 commit f68f705

File tree

5 files changed

+62
-70
lines changed

5 files changed

+62
-70
lines changed
Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +0,0 @@
1-
import pytest
2-
3-
4-
@pytest.fixture(scope="session")
5-
def invalid_case_id():
6-
return "CAS-0000-0000"
7-
8-
9-
@pytest.fixture
10-
def case_factory(short_uuid, created_queue):
11-
def factory(
12-
title: str = "E2E Created Helpdesk Case",
13-
description: str = "E2E Created Helpdesk Case Description",
14-
):
15-
return {
16-
"queue": {"id": created_queue.id},
17-
"chat": {"lastMessage": {"content": "E2E testing!!!"}},
18-
}
19-
20-
return factory
21-
22-
23-
@pytest.fixture
24-
def created_case(mpt_ops, case_factory):
25-
return mpt_ops.helpdesk.cases.create(case_factory())
26-
27-
28-
@pytest.fixture
29-
def queried_case(mpt_ops, created_case):
30-
return mpt_ops.helpdesk.cases.query(created_case.id, {"queryPrompt": "More details needed"})
31-
32-
33-
@pytest.fixture
34-
def processed_case(mpt_ops, queried_case):
35-
return mpt_ops.helpdesk.cases.process(queried_case.id)
36-
37-
38-
@pytest.fixture
39-
async def async_created_case(async_mpt_ops, case_factory):
40-
return await async_mpt_ops.helpdesk.cases.create(case_factory())
41-
42-
43-
@pytest.fixture
44-
async def async_queried_case(async_mpt_ops, async_created_case):
45-
return await async_mpt_ops.helpdesk.cases.query(
46-
async_created_case.id, {"queryPrompt": "More details needed"}
47-
)
48-
49-
50-
@pytest.fixture
51-
async def async_processed_case(async_mpt_ops, async_queried_case):
52-
return await async_mpt_ops.helpdesk.cases.process(async_queried_case.id)

tests/e2e/helpdesk/chats/attachment/conftest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55

66
@pytest.fixture
7-
def chat_attachments_service(mpt_ops, chat_id):
8-
return mpt_ops.helpdesk.chats.attachments(chat_id)
7+
def chat_attachments_service(mpt_ops, created_chat):
8+
return mpt_ops.helpdesk.chats.attachments(created_chat.id)
99

1010

1111
@pytest.fixture
12-
def async_chat_attachments_service(async_mpt_ops, chat_id):
13-
return async_mpt_ops.helpdesk.chats.attachments(chat_id)
12+
def async_chat_attachments_service(async_mpt_ops, created_chat):
13+
return async_mpt_ops.helpdesk.chats.attachments(created_chat.id)
1414

1515

1616
@pytest.fixture

tests/e2e/helpdesk/chats/attachment/test_async_attachment.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,24 @@
88
pytestmark = [pytest.mark.flaky]
99

1010

11-
@pytest.mark.skip(reason="Unskip after MPT-19124 completed")
1211
async def test_list_chat_attachments(async_chat_attachments_service, async_created_chat_attachment):
1312
result = await async_chat_attachments_service.fetch_page(limit=1)
1413

1514
assert len(result) > 0
1615
assert all(isinstance(attachment, ChatAttachment) for attachment in result)
1716

1817

19-
@pytest.mark.skip(reason="Unskip after MPT-19124 completed") # noqa: AAA01
20-
def test_create_chat_attachment(async_created_chat_attachment, chat_attachment_data):
18+
def test_create_chat_attachment(async_created_chat_attachment, chat_attachment_data): # noqa: AAA01
2119
assert async_created_chat_attachment.id is not None
2220
assert async_created_chat_attachment.to_dict().get("name") == chat_attachment_data["name"]
2321

2422

25-
@pytest.mark.skip(reason="Unskip after MPT-19124 completed")
2623
async def test_get_chat_attachment(async_chat_attachments_service, async_created_chat_attachment):
2724
result = await async_chat_attachments_service.get(async_created_chat_attachment.id)
2825

2926
assert result.id == async_created_chat_attachment.id
3027

3128

32-
@pytest.mark.skip(reason="Unskip after MPT-19124 completed")
3329
async def test_update_chat_attachment(
3430
async_chat_attachments_service, async_created_chat_attachment, short_uuid
3531
):
@@ -44,7 +40,6 @@ async def test_update_chat_attachment(
4440
assert result.to_dict().get("name") == updated_name
4541

4642

47-
@pytest.mark.skip(reason="Unskip after MPT-19124 completed")
4843
async def test_download_chat_attachment(
4944
async_chat_attachments_service, async_created_chat_attachment
5045
):
@@ -56,7 +51,6 @@ async def test_download_chat_attachment(
5651
assert result.file_contents is not None
5752

5853

59-
@pytest.mark.skip(reason="Unskip after MPT-19124 completed")
6054
async def test_delete_chat_attachment(async_chat_attachments_service, chat_attachment_data, pdf_fd):
6155
created = await async_chat_attachments_service.create(chat_attachment_data, file=pdf_fd)
6256

tests/e2e/helpdesk/chats/attachment/test_sync_attachment.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,24 @@
88
pytestmark = [pytest.mark.flaky]
99

1010

11-
@pytest.mark.skip(reason="Unskip after MPT-19124 completed")
1211
def test_list_chat_attachments(chat_attachments_service, created_chat_attachment):
1312
result = chat_attachments_service.fetch_page(limit=1)
1413

1514
assert len(result) > 0
1615
assert all(isinstance(attachment, ChatAttachment) for attachment in result)
1716

1817

19-
@pytest.mark.skip(reason="Unskip after MPT-19124 completed") # noqa: AAA01
20-
def test_create_chat_attachment(created_chat_attachment, chat_attachment_data):
18+
def test_create_chat_attachment(created_chat_attachment, chat_attachment_data): # noqa: AAA01
2119
assert created_chat_attachment.id is not None
2220
assert created_chat_attachment.to_dict().get("name") == chat_attachment_data["name"]
2321

2422

25-
@pytest.mark.skip(reason="Unskip after MPT-19124 completed")
2623
def test_get_chat_attachment(chat_attachments_service, created_chat_attachment):
2724
result = chat_attachments_service.get(created_chat_attachment.id)
2825

2926
assert result.id == created_chat_attachment.id
3027

3128

32-
@pytest.mark.skip(reason="Unskip after MPT-19124 completed")
3329
def test_update_chat_attachment(chat_attachments_service, created_chat_attachment, short_uuid):
3430
updated_name = f"e2e updated attachment - {short_uuid}"
3531

@@ -42,14 +38,12 @@ def test_update_chat_attachment(chat_attachments_service, created_chat_attachmen
4238
assert result.to_dict().get("name") == updated_name
4339

4440

45-
@pytest.mark.skip(reason="Unskip after MPT-19124 completed")
4641
def test_download_chat_attachment(chat_attachments_service, created_chat_attachment):
4742
result = chat_attachments_service.download(created_chat_attachment.id, accept="application/pdf")
4843

4944
assert result.file_contents is not None
5045

5146

52-
@pytest.mark.skip(reason="Unskip after MPT-19124 completed") # noqa: AAA01
5347
def test_delete_chat_attachment(chat_attachments_service, chat_attachment_data, pdf_fd):
5448
created = chat_attachments_service.create(chat_attachment_data, file=pdf_fd)
5549

tests/e2e/helpdesk/conftest.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,59 @@ async def async_created_disabled_queue(async_mpt_ops, async_created_queue):
4848
assert result.status == "Disabled"
4949

5050
return result
51+
52+
53+
@pytest.fixture(scope="session")
54+
def invalid_case_id():
55+
return "CAS-0000-0000"
56+
57+
58+
@pytest.fixture
59+
def case_factory(short_uuid, created_queue):
60+
def factory(
61+
title: str = "E2E Created Helpdesk Case",
62+
description: str = "E2E Created Helpdesk Case Description",
63+
):
64+
return {
65+
"queue": {"id": created_queue.id},
66+
"chat": {"lastMessage": {"content": "E2E testing!!!"}},
67+
}
68+
69+
return factory
70+
71+
72+
@pytest.fixture
73+
def created_case(mpt_ops, case_factory):
74+
return mpt_ops.helpdesk.cases.create(case_factory())
75+
76+
77+
@pytest.fixture
78+
def queried_case(mpt_ops, created_case):
79+
return mpt_ops.helpdesk.cases.query(created_case.id, {"queryPrompt": "More details needed"})
80+
81+
82+
@pytest.fixture
83+
def processed_case(mpt_ops, queried_case):
84+
return mpt_ops.helpdesk.cases.process(queried_case.id)
85+
86+
87+
@pytest.fixture
88+
def created_chat(created_case):
89+
return created_case.chat
90+
91+
92+
@pytest.fixture
93+
async def async_created_case(async_mpt_ops, case_factory):
94+
return await async_mpt_ops.helpdesk.cases.create(case_factory())
95+
96+
97+
@pytest.fixture
98+
async def async_queried_case(async_mpt_ops, async_created_case):
99+
return await async_mpt_ops.helpdesk.cases.query(
100+
async_created_case.id, {"queryPrompt": "More details needed"}
101+
)
102+
103+
104+
@pytest.fixture
105+
async def async_processed_case(async_mpt_ops, async_queried_case):
106+
return await async_mpt_ops.helpdesk.cases.process(async_queried_case.id)

0 commit comments

Comments
 (0)