Fixed tests
This commit is contained in:
parent
d2cdef2bfa
commit
0cc223f0f4
18
test/secrets.py
Normal file
18
test/secrets.py
Normal 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')
|
|
@ -1,17 +1,23 @@
|
||||||
import requests
|
import requests
|
||||||
|
import pytest
|
||||||
|
|
||||||
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()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user