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
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ dev = [
"freezegun==1.5.*",
"ipdb==0.13.*",
"ipython==9.*",
"mypy==2.1.*",
"mypy==2.1.*",
"pre-commit==4.6.*",
"pyfakefs==6.2.*",
"pyfakefs==6.2.*",
"pytest==9.1.*",
"pytest-asyncio==1.4.*",
"pytest-cov==7.1.*",
Expand All @@ -46,11 +46,12 @@ dev = [
"pytest-rerunfailures==16.3.*",
"pytest-xdist==3.8.*",
"responses==0.26.*",
"respx==0.23.*",
"respx==0.23.*",
"ruff==0.15.*", # force ruff version to have same formatting everywhere
"typing-extensions==4.15.*",
"wemake-python-styleguide==1.6.*",
"types-python-dateutil==2.9.*",
"iso4217==1.16.*",
]

[tool.hatch.build.targets.sdist]
Expand Down
26 changes: 22 additions & 4 deletions tests/e2e/exchange/currencies/conftest.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
import logging
import secrets
import string

import pytest
from iso4217 import Currency

from mpt_api_client.exceptions import MPTAPIError

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)

CURRENCY_CODE_LENGTH = 3
CURRENCY_CODE_ALPHABET = string.ascii_uppercase
ISO_CURRENCY_CODES = frozenset(currency.code for currency in Currency)


def _random_currency_code():
while True:
letters = (secrets.choice(CURRENCY_CODE_ALPHABET) for _ in range(CURRENCY_CODE_LENGTH))
code = "".join(letters)
if code not in ISO_CURRENCY_CODES:
return code

Comment thread
coderabbitai[bot] marked this conversation as resolved.

@pytest.fixture
def currencies_service(mpt_ops):
Expand All @@ -22,8 +40,8 @@ def currency_id(e2e_config):

@pytest.fixture
def currency_data(short_uuid):
digit_to_alpha = str.maketrans(string.digits, "GHIJKLMNOP")
code = short_uuid[:3].translate(digit_to_alpha).upper()
code = _random_currency_code()
logger.info("e2e generated currency code: %s", code)
return {
"name": f"e2e - please delete {short_uuid}",
"code": code,
Expand All @@ -40,7 +58,7 @@ def created_currency(currencies_service, currency_data, logo_fd):
try:
currencies_service.delete(currency.id)
except MPTAPIError as error:
print(f"TEARDOWN - Unable to delete currency {currency.id}: {error.title}") # noqa: WPS421
logger.warning("TEARDOWN - Unable to delete currency %s: %s", currency.id, error.title)


@pytest.fixture
Expand All @@ -52,4 +70,4 @@ async def async_created_currency(async_currencies_service, currency_data, logo_f
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
logger.warning("TEARDOWN - Unable to delete currency %s: %s", currency.id, error.title)
11 changes: 11 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading