"""Test currency util.""" import pytest from ledger.constants.error import ERROR_UNKNOWN_CURRENCY from ledger.utils.currency import currency_exists, validate_currency def test_currency_exists(): """Test currency_exists.""" assert currency_exists('USD') assert not currency_exists(1) assert currency_exists('EUR') assert currency_exists('usd') def test_validate_currency(): """Test currency validation.""" valid_currency = validate_currency('EUR') assert valid_currency is None with pytest.raises(Exception, match=ERROR_UNKNOWN_CURRENCY.format(code='NYC')): validate_currency('NYC')