-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
53 lines (40 loc) · 1.54 KB
/
conftest.py
File metadata and controls
53 lines (40 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import pytest
from mpt_api_client.exceptions import MPTAPIError
@pytest.fixture
def chat_attachments_service(mpt_ops, chat_id):
return mpt_ops.helpdesk.chats.attachments(chat_id)
@pytest.fixture
def async_chat_attachments_service(async_mpt_ops, chat_id):
return async_mpt_ops.helpdesk.chats.attachments(chat_id)
@pytest.fixture
def chat_attachment_data(short_uuid):
attachment_name = f"e2e attachment - {short_uuid}"
return {
"name": attachment_name,
"description": attachment_name,
}
@pytest.fixture
def created_chat_attachment(chat_attachments_service, chat_attachment_data, pdf_fd):
chat_attachment = chat_attachments_service.create(chat_attachment_data, file=pdf_fd)
yield chat_attachment
try:
chat_attachments_service.delete(chat_attachment.id)
except MPTAPIError as error:
print( # noqa: WPS421
f"TEARDOWN - Unable to delete chat attachment {chat_attachment.id}: {error.title}"
)
@pytest.fixture
async def async_created_chat_attachment(
async_chat_attachments_service, chat_attachment_data, pdf_fd
):
chat_attachment = await async_chat_attachments_service.create(chat_attachment_data, file=pdf_fd)
yield chat_attachment
try:
await async_chat_attachments_service.delete(chat_attachment.id)
except MPTAPIError as error:
print( # noqa: WPS421
f"TEARDOWN - Unable to delete chat attachment {chat_attachment.id}: {error.title}"
)
@pytest.fixture
def invalid_chat_attachment_id():
return "ATT-0000-0000-0000-0000"