diff --git a/fin_depo/investbank_nordnet.py b/fin_depo/investbank_nordnet.py index ca9020b..83100d8 100644 --- a/fin_depo/investbank_nordnet.py +++ b/fin_depo/investbank_nordnet.py @@ -62,6 +62,10 @@ class NordnetDepoFetcher: self.password = password self.is_logged_in = False + assert self.username is not None, 'Username is missing' + assert self.password is not None, 'Password is missing' + + def get_json(self, url: str, params: dict[str, str | int] = {}) -> dict: if not url.startswith(API_ROOT): msg = f'Given url must be located below API ROOT: {url}' diff --git a/test/secrets.py b/test/secrets.py index db07318..d6b6dea 100644 --- a/test/secrets.py +++ b/test/secrets.py @@ -1,18 +1,6 @@ -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 +from secret_loader import SecretLoader +load_secret = SecretLoader().load NORDNET_USERNAME = load_secret('NORDNET_USERNAME') NORDNET_PASSWORD = load_secret('NORDNET_PASSWORD')