Files
@ 17ff9a8b71d5
Branch filter:
Location: NPO-Accounting/oxrlib/tests/test_Rate.py - annotation
17ff9a8b71d5
1019 B
text/x-python
setup.py: Add oxrlib.commands package.
a1811663115e 9d4723824592 a1811663115e a1811663115e a1811663115e a1811663115e a1811663115e a1811663115e a1811663115e a1811663115e 9d4723824592 9d4723824592 9d4723824592 a1811663115e a1811663115e a1811663115e a1811663115e a1811663115e a1811663115e a1811663115e a1811663115e a1811663115e a1811663115e a1811663115e a1811663115e a1811663115e a1811663115e 9d4723824592 9d4723824592 9d4723824592 9d4723824592 | import datetime
import decimal
import io
import json
from . import relpath
import oxrlib.rate
import pytest
HIST1_AED_RATE = decimal.Decimal('3.67246')
HIST1_ALL_RATE = decimal.Decimal('144.529793')
@pytest.fixture
def historical1_rate():
with open(relpath('historical1.json').as_posix()) as rate_file:
return oxrlib.rate.Rate.from_json_file(rate_file)
def test_rate_from_json(historical1_rate):
assert historical1_rate.base == 'USD'
assert historical1_rate.timestamp == datetime.datetime(2001, 2, 16, 12, 0, 0)
def test_serialize(historical1_rate):
with open(relpath('historical1.json').as_posix()) as rate_file:
expected = json.load(rate_file)
assert expected == historical1_rate.serialize()
def test_convert(historical1_rate):
assert historical1_rate.convert(2, 'USD', 'ALL') == (2 * HIST1_ALL_RATE)
assert historical1_rate.convert(10, 'AED', 'USD') == (10 / HIST1_AED_RATE)
assert historical1_rate.convert(1, 'AED', 'ALL') == (HIST1_ALL_RATE / HIST1_AED_RATE)
|