1
0

Improved tests

This commit is contained in:
Jon Michael Aanes 2024-09-01 18:05:05 +02:00
parent 74895720d6
commit aefece86d2
Signed by: Jmaa
SSH Key Fingerprint: SHA256:Ab0GfHGCblESJx7JRE4fj4bFy/KRpeLhi41y4pF3sNA

View File

@ -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'