Skip to content

Commit 33dbc10

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

File tree

6 files changed

+66
-76
lines changed

6 files changed

+66
-76
lines changed

tests/e2e/helpdesk/cases/conftest.py

Lines changed: 0 additions & 52 deletions
This file was deleted.

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: 4 additions & 8 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,11 +51,12 @@ 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

63-
await async_chat_attachments_service.delete(created.id)
57+
result = await async_chat_attachments_service.delete(created.id)
58+
59+
assert result is None
6460

6561

6662
async def test_get_chat_attachment_not_found(

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

Lines changed: 4 additions & 8 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,18 +38,18 @@ 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

56-
chat_attachments_service.delete(created.id)
50+
result = chat_attachments_service.delete(created.id)
51+
52+
assert result is None
5753

5854

5955
def test_get_chat_attachment_not_found(chat_attachments_service, invalid_chat_attachment_id):

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

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

88

99
@pytest.fixture
10-
def chat_messages_service(mpt_ops, chat_id):
11-
return mpt_ops.helpdesk.chats.messages(chat_id)
10+
def chat_messages_service(mpt_ops, created_chat):
11+
return mpt_ops.helpdesk.chats.messages(created_chat.id)
1212

1313

1414
@pytest.fixture
15-
def async_chat_messages_service(async_mpt_ops, chat_id):
16-
return async_mpt_ops.helpdesk.chats.messages(chat_id)
15+
def async_chat_messages_service(async_mpt_ops, created_chat):
16+
return async_mpt_ops.helpdesk.chats.messages(created_chat.id)
1717

1818

1919
@pytest.fixture

tests/e2e/helpdesk/conftest.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,53 @@ 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_data(created_queue):
60+
return {
61+
"queue": {"id": created_queue.id},
62+
"chat": {"lastMessage": {"content": "E2E testing!!!"}},
63+
}
64+
65+
66+
@pytest.fixture
67+
def created_case(mpt_ops, case_data):
68+
return mpt_ops.helpdesk.cases.create(case_data)
69+
70+
71+
@pytest.fixture
72+
def queried_case(mpt_ops, created_case):
73+
return mpt_ops.helpdesk.cases.query(created_case.id, {"queryPrompt": "More details needed"})
74+
75+
76+
@pytest.fixture
77+
def processed_case(mpt_ops, queried_case):
78+
return mpt_ops.helpdesk.cases.process(queried_case.id)
79+
80+
81+
@pytest.fixture
82+
def created_chat(created_case):
83+
return created_case.chat
84+
85+
86+
@pytest.fixture
87+
async def async_created_case(async_mpt_ops, case_data):
88+
return await async_mpt_ops.helpdesk.cases.create(case_data)
89+
90+
91+
@pytest.fixture
92+
async def async_queried_case(async_mpt_ops, async_created_case):
93+
return await async_mpt_ops.helpdesk.cases.query(
94+
async_created_case.id, {"queryPrompt": "More details needed"}
95+
)
96+
97+
98+
@pytest.fixture
99+
async def async_processed_case(async_mpt_ops, async_queried_case):
100+
return await async_mpt_ops.helpdesk.cases.process(async_queried_case.id)

0 commit comments

Comments
 (0)