1
0

Compare commits

...

2 Commits

Author SHA1 Message Date
a816adacbb
Ruff
All checks were successful
Test Python / Test (push) Successful in 22s
2024-06-20 23:01:41 +02:00
0cc223f0f4
Fixed tests 2024-06-20 23:01:41 +02:00
3 changed files with 29 additions and 5 deletions

View File

@ -1 +1 @@
__version__ = '0.1.12' __version__ = '0.1.12'

18
test/secrets.py Normal file
View File

@ -0,0 +1,18 @@
import logging
logger = logging.getLogger(__name__)
def load_secret(env_key: str) -> str:
filepath = f'./secrets/{env_key.lower()}'
try:
with open(filepath) as f:
return f.read().strip()
logger.info('Loaded secret: %s', env_key)
except Exception:
logger.exception("Could not load %s file '%s'", env_key, filepath)
return None
NORDNET_USERNAME = load_secret('NORDNET_USERNAME')
NORDNET_PASSWORD = load_secret('NORDNET_PASSWORD')

View File

@ -1,17 +1,23 @@
import pytest
import requests import requests
from fin_depo import investbank_nordnet from fin_depo import investbank_nordnet
SECRET_USERNAME = None from . import secrets
SECRET_PASSWORD = None
needs_secrets = pytest.mark.skipif(
not secrets.NORDNET_USERNAME,
reason='Secret NORDNET_USERNAME required',
)
@needs_secrets
def test_get_depo(): def test_get_depo():
session = requests.Session() session = requests.Session()
nordnet = investbank_nordnet.NordnetDepoFetcher( nordnet = investbank_nordnet.NordnetDepoFetcher(
session, session,
SECRET_USERNAME, secrets.NORDNET_USERNAME,
SECRET_PASSWORD, secrets.NORDNET_PASSWORD,
) )
depo = nordnet.get_depo() depo = nordnet.get_depo()