28 lines
731 B
Python
28 lines
731 B
Python
import pytest
|
|
|
|
import fin_defs
|
|
|
|
VALID_TICKERS = ['TEST123', '123', 'TEST.EUR']
|
|
BAD_TICKERS = ['TEST:EUR', 'EUR:TEST']
|
|
|
|
|
|
@pytest.mark.parametrize('ticker', VALID_TICKERS)
|
|
def test_valid_tickers(ticker: str):
|
|
fin_defs.Stock(ticker, exchange=fin_defs.EXCHANGES_BY_IDS['NYSE'])
|
|
|
|
|
|
@pytest.mark.parametrize('ticker', BAD_TICKERS)
|
|
def test_bad_tickers(ticker: str):
|
|
with pytest.raises(ValueError):
|
|
fin_defs.Stock(ticker, exchange=fin_defs.EXCHANGES_BY_IDS['NYSE'])
|
|
|
|
|
|
@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'])
|
|
assert str(NVO) == 'stock:NVO.XNYS'
|