1
0
fin-defs/test/test_data.py
Jon Michael Aanes a12fcacf77
All checks were successful
Python Ruff Code Quality / ruff (push) Successful in 22s
Run Python tests (through Pytest) / Test (push) Successful in 25s
Verify Python project can be installed, loaded and have version checked / Test (push) Successful in 22s
Code quality
2024-10-27 16:18:21 +01:00

28 lines
780 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, match='ticker was not in correct format:.*'):
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():
asset = fin_defs.Stock('NVO', fin_defs.EXCHANGES_BY_IDS['NYSE'])
assert str(asset) == 'stock:NVO.XNYS'