-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_async_links.py
More file actions
53 lines (34 loc) · 1.74 KB
/
test_async_links.py
File metadata and controls
53 lines (34 loc) · 1.74 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
from http import HTTPStatus
import pytest
from mpt_api_client.exceptions import MPTAPIError
from mpt_api_client.resources.helpdesk.chat_links import ChatLink
pytestmark = [pytest.mark.flaky]
async def test_list_chat_links(async_created_chat_link_service):
result = await async_created_chat_link_service.fetch_page(limit=1)
assert len(result) > 0
assert all(isinstance(link, ChatLink) for link in result)
def test_create_chat_link(async_created_chat_link, chat_link_data): # noqa: AAA01
assert isinstance(async_created_chat_link, ChatLink)
assert async_created_chat_link.to_dict().get("uri") == chat_link_data["uri"]
async def test_update_chat_link_name(async_chat_links_service, async_created_chat_link, short_uuid):
new_name = f"e2e updated link - {short_uuid}"
result = await async_chat_links_service.update(
async_created_chat_link.id,
{"name": new_name},
)
assert isinstance(result, ChatLink)
assert result.to_dict().get("name") == new_name
async def test_delete_chat_link(async_chat_links_service, async_created_chat_link):
result = async_created_chat_link
await async_chat_links_service.delete(result.id)
async def test_update_chat_link_not_found(async_chat_links_service, invalid_chat_link_id):
with pytest.raises(MPTAPIError) as error:
await async_chat_links_service.update(
invalid_chat_link_id,
{"name": "updated name"},
)
assert error.value.status_code == HTTPStatus.NOT_FOUND
async def test_delete_chat_link_not_found(async_chat_links_service, invalid_chat_link_id):
with pytest.raises(MPTAPIError) as error:
await async_chat_links_service.delete(invalid_chat_link_id)
assert error.value.status_code == HTTPStatus.NOT_FOUND