-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ Добавил поддержку различной meta-информации по валютам расчётов и …
…покрыл тестами текущее поведение класса Currency
- Loading branch information
Showing
3 changed files
with
61 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import pytest | ||
|
||
from investments.currency import Currency | ||
|
||
|
||
@pytest.mark.parametrize('search_value,res', [ | ||
('$', Currency.USD), | ||
('EUR', Currency.EUR), | ||
('RUR', Currency.RUB), | ||
('RUB', Currency.RUB), | ||
('₽', Currency.RUB), | ||
]) | ||
def test_parse(search_value: str, res: Currency): | ||
assert Currency.parse(search_value) is res | ||
|
||
|
||
def test_parse_failure(): | ||
with pytest.raises(ValueError): | ||
assert Currency.parse('invalid') | ||
|
||
|
||
@pytest.mark.parametrize('currency,expected_repr', [ | ||
(Currency.USD, '$'), | ||
(Currency.RUB, '₽'), | ||
]) | ||
def test_repr(currency: Currency, expected_repr: str): | ||
assert str(currency) == expected_repr | ||
|
||
|
||
@pytest.mark.parametrize('currency,expected', [ | ||
(Currency.USD, '840'), | ||
(Currency.RUB, '643'), | ||
]) | ||
def test_iso_numeric_code(currency: Currency, expected: str): | ||
assert currency.iso_numeric_code == expected |