data-xexe/tests/tests_unit/test_currency_pair.py

47 lines
1.2 KiB
Python
Raw Normal View History

2025-05-26 14:50:21 +02:00
from money.currency import Currency
from xexe.currency_pair import CurrencyPair
def test_create_currency_pair_normal_works_fine():
a_pair: CurrencyPair = CurrencyPair(
from_currency=Currency["USD"], to_currency=Currency["EUR"]
)
assert (a_pair.from_currency == "USD", a_pair.to_currency == "EUR")
def test_create_currency_pair_with_same_currency_works():
same_curr_pair: CurrencyPair = CurrencyPair(
from_currency=Currency["USD"], to_currency=Currency["USD"]
)
assert (same_curr_pair.from_currency == "USD", same_curr_pair.to_currency == "USD")
2025-05-26 15:03:08 +02:00
def test_reverse_pair_works_fine():
2025-05-26 14:50:21 +02:00
a_pair: CurrencyPair = CurrencyPair(
from_currency=Currency["USD"], to_currency=Currency["EUR"]
)
reverse_pair: CurrencyPair = a_pair.get_reverse_pair()
assert (
isinstance(reverse_pair, CurrencyPair),
reverse_pair.from_currency == "EUR",
reverse_pair.to_currency == "USD",
)
2025-05-26 15:03:08 +02:00
def test_pair_equality_works():
a_pair: CurrencyPair = CurrencyPair(
from_currency=Currency["USD"], to_currency=Currency["EUR"]
)
reverse_pair: CurrencyPair = a_pair.get_reverse_pair()
assert a_pair == a_pair and a_pair != reverse_pair