1
0
fin-depo/test/test_nordnet.py
Jon Michael Aanes 836b3b2a35
All checks were successful
Python Ruff Code Quality / ruff (push) Successful in 22s
Run Python tests (through Pytest) / Test (push) Successful in 28s
Verify Python project can be installed, loaded and have version checked / Test (push) Successful in 23s
Code quality improvements
2024-11-01 11:30:22 +01:00

34 lines
752 B
Python

import pytest
import requests
import fin_depo
from . import secrets
needs_secrets = pytest.mark.skipif(
not secrets.NORDNET_USERNAME,
reason='Secret NORDNET_USERNAME required',
)
def print_pretty(depo: fin_depo.data.Depo):
for asset in depo.assets():
amount = depo.get_amount_of_asset(asset)
str_asset = str(asset)
print(f'{str_asset:15} : {amount:10}')
del asset, amount
@needs_secrets
def test_get_depo():
session = requests.Session()
fetcher = fin_depo.investbank_nordnet.NordnetDepoFetcher(
session,
secrets.NORDNET_USERNAME,
secrets.NORDNET_PASSWORD,
)
depo = fetcher.get_depo()
print_pretty(depo)
assert isinstance(depo, fin_depo.data.DepoGroup)