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
13 changes: 8 additions & 5 deletions e2e_config.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
"commerce.agreement.subscription.line.id": "ALI-0078-7880-7436-0001",
"commerce.assets.agreement.id": "AGR-2473-3299-1721",
"commerce.assets.agreement.line.id": "ALI-9320-4904-7940-0001",
"commerce.assets.id": "AST-0625-6526-6154",
"commerce.assets.order.id": "ORD-7707-7765-8445",
"commerce.assets.draft.order.agreement.id": "AGR-9320-4904-7940",
"commerce.assets.draft.order.id": "ORD-9272-6817-2305",
"commerce.assets.id": "AST-0625-6526-6154",
"commerce.assets.order.id": "ORD-7707-7765-8445",
"commerce.assets.product.item.id": "ITM-1767-7355-0002",
"commerce.assets.product.template.id": "",
"commerce.authorization.id": "AUT-0031-2873",
Expand All @@ -55,13 +55,16 @@
"commerce.product.item.id": "ITM-1767-7355-0001",
"commerce.product.listing.id": "LST-5489-0806",
"commerce.product.template.id": "TPL-1767-7355-0002",
"commerce.user.id": "USR-4303-2348",
"commerce.subscription.agreement.id": "AGR-2473-3299-1721",
"commerce.subscription.id": "SUB-3678-1831-2188",
"commerce.subscription.product.item.id": "ITM-1767-7355-0001",
"commerce.user.id": "USR-4303-2348",
"exchange.currency.id": "CUR-6831",
"helpdesk.channel.id": "CHL-5064-0262-3671",
"helpdesk.chat.id": "CHT-5064-0262-3671",
"notifications.batch.attachment.id": "ATT-7183-1965-7758",
"notifications.batch.id": "MST-3638-2460-4825",
"notifications.category.id": "NTC-6157-0397",
"notifications.subscriber.id": "NTS-0829-7123-7123",
"notifications.message.id": "MSG-0000-6215-1019-0139"
"notifications.message.id": "MSG-0000-6215-1019-0139",
"notifications.subscriber.id": "NTS-0829-7123-7123"
}
Empty file.
Empty file.
55 changes: 55 additions & 0 deletions tests/e2e/exchange/currencies/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import string

import pytest

from mpt_api_client.exceptions import MPTAPIError


@pytest.fixture
def currencies_service(mpt_ops):
return mpt_ops.exchange.currencies


@pytest.fixture
def async_currencies_service(async_mpt_ops):
return async_mpt_ops.exchange.currencies


@pytest.fixture(scope="session")
def currency_id(e2e_config):
return e2e_config["exchange.currency.id"]


@pytest.fixture
def currency_data(short_uuid):
digit_to_alpha = str.maketrans(string.digits, "GHIJKLMNOP")
code = short_uuid[:3].translate(digit_to_alpha).upper()
return {
"name": f"e2e - please delete {short_uuid}",
"code": code,
"precision": 2,
}


@pytest.fixture
def created_currency(currencies_service, currency_data, logo_fd):
currency = currencies_service.create(currency_data, file=logo_fd)

yield currency

try:
currencies_service.delete(currency.id)
except MPTAPIError as error:
print(f"TEARDOWN - Unable to delete currency {currency.id}: {error.title}") # noqa: WPS421
Comment thread
albertsola marked this conversation as resolved.


@pytest.fixture
async def async_created_currency(async_currencies_service, currency_data, logo_fd):
currency = await async_currencies_service.create(currency_data, file=logo_fd)

yield currency

try:
await async_currencies_service.delete(currency.id)
except MPTAPIError as error:
print(f"TEARDOWN - Unable to delete currency {currency.id}: {error.title}") # noqa: WPS421
54 changes: 54 additions & 0 deletions tests/e2e/exchange/currencies/test_async_currencies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import pytest

from mpt_api_client.exceptions import MPTAPIError
from mpt_api_client.models import FileModel
from tests.e2e.helper import assert_async_service_filter_with_iterate

pytestmark = [pytest.mark.flaky]


def test_create_currency(async_created_currency, currency_data):
result = async_created_currency.code

assert result == currency_data["code"]


async def test_get_currency(async_currencies_service, currency_id):
result = await async_currencies_service.get(currency_id)

assert result.id == currency_id


async def test_get_currency_not_found(async_currencies_service):
bogus_id = "CUR-0000-0000"

with pytest.raises(MPTAPIError, match=r"404 Not Found"):
await async_currencies_service.get(bogus_id)


async def test_update_currency(
async_currencies_service, async_created_currency, logo_fd, short_uuid
):
update_data = {"name": f"e2e - please delete {short_uuid}"}

result = await async_currencies_service.update(
async_created_currency.id, update_data, file=logo_fd
)
Comment thread
albertsola marked this conversation as resolved.

assert result.name == update_data["name"]


async def test_delete_currency(async_currencies_service, async_created_currency):
await async_currencies_service.delete(async_created_currency.id) # act


async def test_filter_currencies(async_currencies_service, currency_id):
await assert_async_service_filter_with_iterate(
async_currencies_service, currency_id, None
) # act


async def test_download_icon(async_currencies_service, async_created_currency):
result = await async_currencies_service.download_icon(async_created_currency.id)

assert isinstance(result, FileModel)
48 changes: 48 additions & 0 deletions tests/e2e/exchange/currencies/test_sync_currencies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import pytest

from mpt_api_client.exceptions import MPTAPIError
from mpt_api_client.models import FileModel
from tests.e2e.helper import assert_service_filter_with_iterate

pytestmark = [pytest.mark.flaky]


def test_create_currency(created_currency, currency_data):
result = created_currency.code

assert result == currency_data["code"]


def test_get_currency(currencies_service, currency_id):
result = currencies_service.get(currency_id)

assert result.id == currency_id


def test_get_currency_not_found(currencies_service):
bogus_id = "CUR-0000-0000"

with pytest.raises(MPTAPIError, match=r"404 Not Found"):
currencies_service.get(bogus_id)


def test_update_currency(currencies_service, created_currency, logo_fd, short_uuid):
update_data = {"name": f"e2e - please delete {short_uuid}"}

result = currencies_service.update(created_currency.id, update_data, file=logo_fd)

Comment thread
albertsola marked this conversation as resolved.
assert result.name == update_data["name"]


def test_delete_currency(currencies_service, created_currency):
currencies_service.delete(created_currency.id) # act


def test_filter_currencies(currencies_service, currency_id):
assert_service_filter_with_iterate(currencies_service, currency_id, None) # act


def test_download_icon(currencies_service, created_currency):
result = currencies_service.download_icon(created_currency.id)

assert isinstance(result, FileModel)