24 lines
630 B
Python
24 lines
630 B
Python
![]() |
import datetime
|
||
|
import io
|
||
|
import json
|
||
|
|
||
|
from . import relpath
|
||
|
|
||
|
import oxrlib.rate
|
||
|
import pytest
|
||
|
|
||
|
@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()
|
||
|
|