1
0

Use SecretLoader for tests
Some checks failed
Test Python / Test (push) Failing after 24s

This commit is contained in:
Jon Michael Aanes 2024-07-08 00:48:27 +02:00
parent 2ec0f9ae17
commit ae3081381a
Signed by: Jmaa
SSH Key Fingerprint: SHA256:Ab0GfHGCblESJx7JRE4fj4bFy/KRpeLhi41y4pF3sNA
2 changed files with 6 additions and 14 deletions

View File

@ -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}'

View File

@ -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')