Improved tests
This commit is contained in:
parent
74895720d6
commit
aefece86d2
|
@ -2,13 +2,18 @@ import pytest
|
||||||
|
|
||||||
import fin_defs
|
import fin_defs
|
||||||
|
|
||||||
BAD_TICKERS = ['TEST123', '123', 'TEST.EUR', 'TEST:EUR', 'EUR:TEST']
|
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)
|
@pytest.mark.parametrize('ticker', BAD_TICKERS)
|
||||||
def test_bad_tickers(ticker):
|
def test_bad_tickers(ticker: str):
|
||||||
with pytest.raises(Exception) as e:
|
with pytest.raises(ValueError):
|
||||||
fin_defs.Stock(ticker)
|
fin_defs.Stock(ticker,exchange=fin_defs.EXCHANGES_BY_IDS['NYSE'])
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('ticker', BAD_TICKERS)
|
@pytest.mark.parametrize('ticker', BAD_TICKERS)
|
||||||
|
@ -18,4 +23,4 @@ def test_crypto_tickers(ticker):
|
||||||
|
|
||||||
def test_str():
|
def test_str():
|
||||||
NVO = fin_defs.Stock('NVO', fin_defs.EXCHANGES_BY_IDS['NYSE'])
|
NVO = fin_defs.Stock('NVO', fin_defs.EXCHANGES_BY_IDS['NYSE'])
|
||||||
assert str(NVO) == 'NVO.XNYS'
|
assert str(NVO) == 'stock:NVO.XNYS'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user