Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions mpt_api_client/resources/helpdesk/chat_answer_parameters.py

This file was deleted.

24 changes: 0 additions & 24 deletions mpt_api_client/resources/helpdesk/chat_answers.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
from mpt_api_client.http import AsyncService, Service, mixins
from mpt_api_client.models import Model, ResourceData
from mpt_api_client.resources.helpdesk.chat_answer_parameters import (
AsyncChatAnswerParametersService,
ChatAnswerParametersService,
)


class ChatAnswer(Model):
Expand Down Expand Up @@ -45,16 +41,6 @@ def validate(self, resource_id: str, resource_data: ResourceData | None = None)
"""Validate answer."""
return self._resource(resource_id).post("validate", json=resource_data)

def parameters(self, answer_id: str) -> ChatAnswerParametersService: # noqa: WPS110
"""Return chat answer parameters service."""
return ChatAnswerParametersService(
http_client=self.http_client,
endpoint_params={
"chat_id": self.endpoint_params["chat_id"],
"answer_id": answer_id,
},
)


class AsyncChatAnswersService(
mixins.AsyncCreateMixin[ChatAnswer],
Expand Down Expand Up @@ -98,13 +84,3 @@ async def validate(
) -> ChatAnswer:
"""Validate answer."""
return await self._resource(resource_id).post("validate", json=resource_data)

def parameters(self, answer_id: str) -> AsyncChatAnswerParametersService: # noqa: WPS110
"""Return async chat answer parameters service."""
return AsyncChatAnswerParametersService(
http_client=self.http_client,
endpoint_params={
"chat_id": self.endpoint_params["chat_id"],
"answer_id": answer_id,
},
)
33 changes: 26 additions & 7 deletions tests/e2e/helpdesk/chats/answers/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,28 @@


@pytest.fixture
def chat_answers_service(mpt_ops, chat_id):
return mpt_ops.helpdesk.chats.answers(chat_id)
def chat_answers_service(mpt_ops, created_chat):
return mpt_ops.helpdesk.chats.answers(created_chat.id)


@pytest.fixture
def async_chat_answers_service(async_mpt_ops, chat_id):
return async_mpt_ops.helpdesk.chats.answers(chat_id)
def async_chat_answers_service(async_mpt_ops, created_chat):
return async_mpt_ops.helpdesk.chats.answers(created_chat.id)


@pytest.fixture
def chat_answer_data(short_uuid):
def chat_answer_data(short_uuid, created_published_form):
return {
"name": f"e2e answer {short_uuid}",
"form": created_published_form.to_dict(),
}


@pytest.fixture
def async_chat_answer_data(short_uuid, async_created_published_form):
return {
"name": f"e2e answer {short_uuid}",
"form": async_created_published_form.to_dict(),
}


Expand All @@ -30,13 +39,23 @@ def created_chat_answer(chat_answers_service, chat_answer_data):


@pytest.fixture
async def async_created_chat_answer(async_chat_answers_service, chat_answer_data):
def submitted_chat_answer(chat_answers_service, created_chat_answer):
return chat_answers_service.submit(created_chat_answer.id)


@pytest.fixture
async def async_created_chat_answer(async_chat_answers_service, async_chat_answer_data):
async with async_create_fixture_resource_and_delete(
async_chat_answers_service, chat_answer_data
async_chat_answers_service, async_chat_answer_data
) as chat_answer:
yield chat_answer


@pytest.fixture
async def async_submitted_chat_answer(async_chat_answers_service, async_created_chat_answer):
return await async_chat_answers_service.submit(async_created_chat_answer.id)


@pytest.fixture(scope="session")
def invalid_chat_answer_id():
return "ANS-0000-0000"
Empty file.
16 changes: 0 additions & 16 deletions tests/e2e/helpdesk/chats/answers/parameters/conftest.py

This file was deleted.

This file was deleted.

This file was deleted.

10 changes: 4 additions & 6 deletions tests/e2e/helpdesk/chats/answers/test_async_answers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
from mpt_api_client.exceptions import MPTAPIError
from mpt_api_client.resources.helpdesk.chat_answers import ChatAnswer

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


async def test_get_chat_answer(async_chat_answers_service, async_created_chat_answer):
Expand All @@ -17,6 +14,7 @@ async def test_get_chat_answer(async_chat_answers_service, async_created_chat_an
assert isinstance(result, ChatAnswer)


@pytest.mark.usefixtures("async_created_chat_answer")
async def test_list_chat_answers(async_chat_answers_service):
result = await async_chat_answers_service.fetch_page(limit=1)

Expand Down Expand Up @@ -64,8 +62,8 @@ async def test_validate_chat_answer(async_chat_answers_service, async_created_ch
assert isinstance(result, ChatAnswer)


async def test_accept_chat_answer(async_chat_answers_service, async_created_chat_answer):
result = await async_chat_answers_service.accept(async_created_chat_answer.id)
async def test_accept_chat_answer(async_chat_answers_service, async_submitted_chat_answer):
result = await async_chat_answers_service.accept(async_submitted_chat_answer.id)

assert isinstance(result, ChatAnswer)

Expand Down
10 changes: 4 additions & 6 deletions tests/e2e/helpdesk/chats/answers/test_sync_answers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
from mpt_api_client.exceptions import MPTAPIError
from mpt_api_client.resources.helpdesk.chat_answers import ChatAnswer

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


def test_get_chat_answer(chat_answers_service, created_chat_answer):
Expand All @@ -17,6 +14,7 @@ def test_get_chat_answer(chat_answers_service, created_chat_answer):
assert result.id == created_chat_answer.id


@pytest.mark.usefixtures("created_chat_answer")
def test_list_chat_answers(chat_answers_service):
result = chat_answers_service.fetch_page(limit=1)

Expand Down Expand Up @@ -59,8 +57,8 @@ def test_validate_chat_answer(chat_answers_service, created_chat_answer):
assert isinstance(result, ChatAnswer)


def test_accept_chat_answer(chat_answers_service, created_chat_answer):
result = chat_answers_service.accept(created_chat_answer.id)
def test_accept_chat_answer(chat_answers_service, submitted_chat_answer):
result = chat_answers_service.accept(submitted_chat_answer.id)

assert isinstance(result, ChatAnswer)

Expand Down
37 changes: 37 additions & 0 deletions tests/e2e/helpdesk/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,40 @@ async def async_queried_case(async_mpt_ops, async_created_case):
@pytest.fixture
async def async_processed_case(async_mpt_ops, async_queried_case):
return await async_mpt_ops.helpdesk.cases.process(async_queried_case.id)


@pytest.fixture
def form_data(short_uuid):
return {
"name": f"E2E Helpdesk Form {short_uuid}",
"description": "E2E Created Helpdesk Form",
}


@pytest.fixture(scope="session")
def invalid_form_id():
return "FRM-0000-0000"


@pytest.fixture
def created_form(mpt_ops, form_data):
with create_fixture_resource_and_delete(mpt_ops.helpdesk.forms, form_data) as form:
yield form


@pytest.fixture
def created_published_form(mpt_ops, created_form):
return mpt_ops.helpdesk.forms.publish(created_form.id)


@pytest.fixture
async def async_created_form(async_mpt_ops, form_data):
async with async_create_fixture_resource_and_delete(
async_mpt_ops.helpdesk.forms, form_data
) as form:
yield form


@pytest.fixture
async def async_created_published_form(async_mpt_ops, async_created_form):
return await async_mpt_ops.helpdesk.forms.publish(async_created_form.id)
45 changes: 0 additions & 45 deletions tests/e2e/helpdesk/forms/conftest.py

This file was deleted.

Loading