Skip to content

Commit e20527f

Browse files
authored
Merge pull request #250
MPT-19124 add TODOs and FIXMEs for improving e2e assertions
2 parents 59d7853 + 988e468 commit e20527f

33 files changed

+228
-60
lines changed

e2e_config.test.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"commerce.product.template.id": "TPL-1767-7355-0002",
5858
"commerce.user.id": "USR-4303-2348",
5959
"helpdesk.chat.id": "CHT-5064-0262-3671",
60+
"helpdesk.channel.id": "CHL-5064-0262-3671",
6061
"commerce.subscription.agreement.id": "AGR-2473-3299-1721",
6162
"commerce.subscription.id": "SUB-3678-1831-2188",
6263
"commerce.subscription.product.item.id": "ITM-1767-7355-0001",

tests/e2e/helpdesk/cases/test_async_cases.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
from http import HTTPStatus
2+
13
import pytest
24

35
from mpt_api_client.exceptions import MPTAPIError
6+
from mpt_api_client.resources.helpdesk.cases import Case
47

58
pytestmark = [pytest.mark.flaky]
69

@@ -12,13 +15,13 @@ async def test_get_case(async_mpt_ops, async_created_case):
1215
assert result.id == async_created_case.id
1316

1417

15-
@pytest.mark.skip(reason="Unskip after MPT-19124 completed")
1618
async def test_list_cases(async_mpt_ops):
1719
limit = 1
1820

1921
result = await async_mpt_ops.helpdesk.cases.fetch_page(limit=limit)
2022

2123
assert len(result) > 0
24+
assert all(isinstance(case, Case) for case in result)
2225

2326

2427
@pytest.mark.skip(reason="Unskip after MPT-19124 completed")
@@ -65,7 +68,7 @@ async def test_complete_case(async_mpt_ops, async_created_case):
6568
assert result is not None
6669

6770

68-
@pytest.mark.skip(reason="Unskip after MPT-19124 completed")
6971
async def test_not_found(async_mpt_ops, invalid_case_id):
70-
with pytest.raises(MPTAPIError):
72+
with pytest.raises(MPTAPIError) as error:
7173
await async_mpt_ops.helpdesk.cases.get(invalid_case_id)
74+
assert error.value.status_code == HTTPStatus.NOT_FOUND

tests/e2e/helpdesk/cases/test_sync_cases.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
from http import HTTPStatus
2+
13
import pytest
24

35
from mpt_api_client.exceptions import MPTAPIError
6+
from mpt_api_client.resources.helpdesk.cases import Case
47

58
pytestmark = [pytest.mark.flaky]
69

@@ -12,13 +15,13 @@ def test_get_case(mpt_ops, created_case):
1215
assert result.id == created_case.id
1316

1417

15-
@pytest.mark.skip(reason="Unskip after MPT-19124 completed")
1618
def test_list_cases(mpt_ops):
1719
limit = 1
1820

1921
result = mpt_ops.helpdesk.cases.fetch_page(limit=limit)
2022

2123
assert len(result) > 0
24+
assert all(isinstance(case, Case) for case in result)
2225

2326

2427
@pytest.mark.skip(reason="Unskip after MPT-19124 completed")
@@ -65,7 +68,8 @@ def test_complete_case(mpt_ops, created_case):
6568
assert result is not None
6669

6770

68-
@pytest.mark.skip(reason="Unskip after MPT-19124 completed")
6971
def test_not_found(mpt_ops, invalid_case_id):
70-
with pytest.raises(MPTAPIError):
72+
with pytest.raises(MPTAPIError) as error:
7173
mpt_ops.helpdesk.cases.get(invalid_case_id)
74+
75+
assert error.value.status_code == HTTPStatus.NOT_FOUND

tests/e2e/helpdesk/channels/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
@pytest.fixture
1010
def channel_id(e2e_config):
11-
return e2e_config["helpdesk.channel.id"]
11+
return e2e_config["helpdesk.channel.id"] # FIXME: seed data
1212

1313

1414
@pytest.fixture
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-

tests/e2e/helpdesk/channels/messages/test_async_messages.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
from http import HTTPStatus
2+
13
import pytest
24

35
from mpt_api_client.exceptions import MPTAPIError
6+
from mpt_api_client.resources.helpdesk.chat_messages import ChatMessage
47

58
pytestmark = [pytest.mark.flaky]
69

@@ -10,9 +13,11 @@ async def test_list_channel_messages(async_channel_messages_service):
1013
result = await async_channel_messages_service.fetch_page(limit=1)
1114

1215
assert len(result) > 0
16+
assert all(isinstance(message, ChatMessage) for message in result)
1317

1418

1519
@pytest.mark.skip(reason="Unskip after MPT-19124 completed")
1620
async def test_list_channel_messages_not_found(async_mpt_ops, invalid_channel_id):
17-
with pytest.raises(MPTAPIError, match=r"404 Not Found"):
21+
with pytest.raises(MPTAPIError) as error:
1822
await async_mpt_ops.helpdesk.channels.messages(invalid_channel_id).fetch_page(limit=1)
23+
assert error.value.status_code == HTTPStatus.NOT_FOUND

tests/e2e/helpdesk/channels/messages/test_sync_messages.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
from http import HTTPStatus
2+
13
import pytest
24

35
from mpt_api_client.exceptions import MPTAPIError
6+
from mpt_api_client.resources.helpdesk.chat_messages import ChatMessage
47

58
pytestmark = [pytest.mark.flaky]
69

@@ -10,9 +13,12 @@ def test_list_channel_messages(channel_messages_service):
1013
result = channel_messages_service.fetch_page(limit=1)
1114

1215
assert len(result) > 0
16+
assert all(isinstance(message, ChatMessage) for message in result)
1317

1418

1519
@pytest.mark.skip(reason="Unskip after MPT-19124 completed")
1620
def test_list_channel_messages_not_found(mpt_ops, invalid_channel_id):
17-
with pytest.raises(MPTAPIError, match=r"404 Not Found"):
21+
with pytest.raises(MPTAPIError) as error:
1822
mpt_ops.helpdesk.channels.messages(invalid_channel_id).fetch_page(limit=1)
23+
24+
assert error.value.status_code == HTTPStatus.NOT_FOUND
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
from http import HTTPStatus
2+
13
import pytest
24

35
from mpt_api_client.exceptions import MPTAPIError
6+
from mpt_api_client.resources.helpdesk.channels import Channel
47

5-
pytestmark = [pytest.mark.flaky]
8+
pytestmark = [pytest.mark.flaky, pytest.mark.skip(reason="Unskip after MPT-19124 completed")]
69

710

8-
@pytest.mark.skip(reason="Unskip after MPT-19124 completed")
911
async def test_get_channel(async_mpt_ops, channel_id):
1012
service = async_mpt_ops.helpdesk.channels
1113

@@ -14,23 +16,21 @@ async def test_get_channel(async_mpt_ops, channel_id):
1416
assert result.id == channel_id
1517

1618

17-
@pytest.mark.skip(reason="Unskip after MPT-19124 completed")
1819
async def test_list_channels(async_mpt_ops):
1920
service = async_mpt_ops.helpdesk.channels
2021

2122
result = await service.fetch_page(limit=1)
2223

2324
assert len(result) > 0
25+
assert all(isinstance(channel, Channel) for channel in result)
2426

2527

26-
@pytest.mark.skip(reason="Unskip after MPT-19124 completed")
2728
def test_create_channel(async_created_channel):
2829
result = async_created_channel
2930

3031
assert result.id is not None
3132

3233

33-
@pytest.mark.skip(reason="Unskip after MPT-19124 completed")
3434
async def test_update_channel(async_mpt_ops, async_created_channel, short_uuid):
3535
service = async_mpt_ops.helpdesk.channels
3636
new_name = f"E2E Updated Channel {short_uuid}"
@@ -41,7 +41,6 @@ async def test_update_channel(async_mpt_ops, async_created_channel, short_uuid):
4141
assert result.to_dict().get("name") == new_name
4242

4343

44-
@pytest.mark.skip(reason="Unskip after MPT-19124 completed")
4544
async def test_delete_channel(async_mpt_ops, async_created_channel):
4645
result = async_created_channel
4746

@@ -51,5 +50,6 @@ async def test_delete_channel(async_mpt_ops, async_created_channel):
5150
async def test_not_found(async_mpt_ops, invalid_channel_id):
5251
service = async_mpt_ops.helpdesk.channels
5352

54-
with pytest.raises(MPTAPIError):
53+
with pytest.raises(MPTAPIError) as error:
5554
await service.get(invalid_channel_id)
55+
assert error.value.status_code == HTTPStatus.NOT_FOUND
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
from http import HTTPStatus
2+
13
import pytest
24

35
from mpt_api_client.exceptions import MPTAPIError
6+
from mpt_api_client.resources.helpdesk.channels import Channel
47

5-
pytestmark = [pytest.mark.flaky]
8+
pytestmark = [pytest.mark.flaky, pytest.mark.skip(reason="Unskip after MPT-19124 completed")]
69

710

8-
@pytest.mark.skip(reason="Unskip after MPT-19124 completed")
911
def test_get_channel(mpt_ops, channel_id):
1012
service = mpt_ops.helpdesk.channels
1113

@@ -14,23 +16,21 @@ def test_get_channel(mpt_ops, channel_id):
1416
assert result.id == channel_id
1517

1618

17-
@pytest.mark.skip(reason="Unskip after MPT-19124 completed")
1819
def test_list_channels(mpt_ops):
1920
service = mpt_ops.helpdesk.channels
2021

2122
result = service.fetch_page(limit=1)
2223

2324
assert len(result) > 0
25+
assert all(isinstance(channel, Channel) for channel in result)
2426

2527

26-
@pytest.mark.skip(reason="Unskip after MPT-19124 completed")
2728
def test_create_channel(created_channel):
2829
result = created_channel
2930

3031
assert result.id is not None
3132

3233

33-
@pytest.mark.skip(reason="Unskip after MPT-19124 completed")
3434
def test_update_channel(mpt_ops, created_channel, short_uuid):
3535
service = mpt_ops.helpdesk.channels
3636
new_name = f"E2E Updated Channel {short_uuid}"
@@ -41,7 +41,6 @@ def test_update_channel(mpt_ops, created_channel, short_uuid):
4141
assert result.to_dict().get("name") == new_name
4242

4343

44-
@pytest.mark.skip(reason="Unskip after MPT-19124 completed")
4544
def test_delete_channel(mpt_ops, created_channel):
4645
result = created_channel
4746

@@ -51,5 +50,7 @@ def test_delete_channel(mpt_ops, created_channel):
5150
def test_not_found(mpt_ops, invalid_channel_id):
5251
service = mpt_ops.helpdesk.channels
5352

54-
with pytest.raises(MPTAPIError):
53+
with pytest.raises(MPTAPIError) as error:
5554
service.get(invalid_channel_id)
55+
56+
assert error.value.status_code == HTTPStatus.NOT_FOUND

tests/e2e/helpdesk/chats/answers/parameters/test_async_parameters.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
from http import HTTPStatus
2+
13
import pytest
24

35
from mpt_api_client.exceptions import MPTAPIError
6+
from mpt_api_client.resources.helpdesk.chat_answer_parameters import ChatAnswerParameter
47

58
pytestmark = [
69
pytest.mark.flaky,
@@ -11,7 +14,8 @@
1114
async def test_list_chat_answer_parameters(async_chat_answer_parameters_service):
1215
result = await async_chat_answer_parameters_service.fetch_page(limit=20)
1316

14-
assert len(result) >= 0
17+
assert len(result) > 0
18+
assert all(isinstance(parameter, ChatAnswerParameter) for parameter in result)
1519

1620

1721
async def test_iterate_chat_answer_parameters(async_chat_answer_parameters_service):
@@ -24,5 +28,6 @@ async def test_iterate_chat_answer_parameters(async_chat_answer_parameters_servi
2428
async def test_not_found(async_mpt_ops, chat_id):
2529
service = async_mpt_ops.helpdesk.chats.answers(chat_id).parameters("ANS-0000-0000")
2630

27-
with pytest.raises(MPTAPIError):
31+
with pytest.raises(MPTAPIError) as error:
2832
await service.fetch_page(limit=20)
33+
assert error.value.status_code == HTTPStatus.NOT_FOUND

0 commit comments

Comments
 (0)