1
0
fin-defs/test/test_data.py

27 lines
728 B
Python
Raw Normal View History

2024-05-27 21:03:16 +00:00
import pytest
import fin_defs
2024-09-01 16:05:05 +00:00
VALID_TICKERS = ['TEST123', '123', 'TEST.EUR']
BAD_TICKERS = ['TEST:EUR', 'EUR:TEST']
2024-05-27 21:03:16 +00:00
2024-09-01 16:05:05 +00:00
@pytest.mark.parametrize('ticker', VALID_TICKERS)
def test_valid_tickers(ticker: str):
fin_defs.Stock(ticker,exchange=fin_defs.EXCHANGES_BY_IDS['NYSE'])
2024-05-27 21:03:16 +00:00
@pytest.mark.parametrize('ticker', BAD_TICKERS)
2024-09-01 16:05:05 +00:00
def test_bad_tickers(ticker: str):
with pytest.raises(ValueError):
fin_defs.Stock(ticker,exchange=fin_defs.EXCHANGES_BY_IDS['NYSE'])
2024-05-27 21:03:16 +00:00
@pytest.mark.parametrize('ticker', BAD_TICKERS)
def test_crypto_tickers(ticker):
fin_defs.CryptoCurrency(ticker, 'not-known')
def test_str():
NVO = fin_defs.Stock('NVO', fin_defs.EXCHANGES_BY_IDS['NYSE'])
2024-09-01 16:05:05 +00:00
assert str(NVO) == 'stock:NVO.XNYS'