From aefece86d20594217cc96688b4bce299a7d9a05f Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Sun, 1 Sep 2024 18:05:05 +0200 Subject: [PATCH] Improved tests --- test/test_data.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/test/test_data.py b/test/test_data.py index 7545960..1de3225 100644 --- a/test/test_data.py +++ b/test/test_data.py @@ -2,13 +2,18 @@ import pytest 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) -def test_bad_tickers(ticker): - with pytest.raises(Exception) as e: - fin_defs.Stock(ticker) +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) @@ -18,4 +23,4 @@ def test_crypto_tickers(ticker): def test_str(): NVO = fin_defs.Stock('NVO', fin_defs.EXCHANGES_BY_IDS['NYSE']) - assert str(NVO) == 'NVO.XNYS' + assert str(NVO) == 'stock:NVO.XNYS'