Test isocurrencies.
This commit is contained in:
parent
c912b676b4
commit
09b7a25f9d
2 changed files with 36 additions and 5 deletions
|
@ -90,13 +90,11 @@ def _parse(entry):
|
|||
except (IndexError, ValueError):
|
||||
minor_units = None
|
||||
|
||||
name_tags = entry.cssselect("CcyNm")
|
||||
if name_tags:
|
||||
name = None
|
||||
is_fund = None
|
||||
if name_tags := entry.cssselect("CcyNm"):
|
||||
name = name_tags[0].text
|
||||
is_fund = name_tags[0].attrib.get("IsFund", "").upper() in ["TRUE", "WAHR"]
|
||||
else:
|
||||
name = None
|
||||
is_fund = None
|
||||
|
||||
countries = [t.text for t in entry.cssselect("CtryNm")]
|
||||
|
||||
|
|
33
tests/pricehist/test_isocurrencies.py
Normal file
33
tests/pricehist/test_isocurrencies.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
from datetime import datetime
|
||||
|
||||
from pricehist import isocurrencies
|
||||
|
||||
|
||||
def test_current():
|
||||
currency = isocurrencies.by_code()["EUR"]
|
||||
assert currency.code == "EUR"
|
||||
assert currency.number == 978
|
||||
assert currency.minor_units == 2
|
||||
assert currency.name == "Euro"
|
||||
assert "GERMANY" in currency.countries
|
||||
assert "FRANCE" in currency.countries
|
||||
assert not currency.is_fund
|
||||
assert not currency.historical
|
||||
assert not currency.withdrawal_date
|
||||
|
||||
|
||||
def test_historical():
|
||||
currency = isocurrencies.by_code()["DEM"]
|
||||
assert currency.code == "DEM"
|
||||
assert currency.number == 276
|
||||
assert currency.minor_units is None
|
||||
assert currency.name == "Deutsche Mark"
|
||||
assert "GERMANY" in currency.countries
|
||||
assert not currency.is_fund
|
||||
assert currency.historical
|
||||
assert currency.withdrawal_date == "2002-03"
|
||||
|
||||
|
||||
def test_data_dates():
|
||||
assert datetime.strptime(isocurrencies.current_data_date(), "%Y-%m-%d")
|
||||
assert datetime.strptime(isocurrencies.historical_data_date(), "%Y-%m-%d")
|
Loading…
Add table
Reference in a new issue