1
0
fin-depo/test/test_nordnet.py

33 lines
722 B
Python
Raw Normal View History

2024-06-20 21:00:22 +00:00
import pytest
2024-06-20 21:01:11 +00:00
import requests
2024-06-04 20:14:58 +00:00
2024-07-21 09:09:49 +00:00
import fin_depo
2024-06-04 20:15:21 +00:00
2024-06-20 21:00:22 +00:00
from . import secrets
2024-06-04 20:14:58 +00:00
2024-06-20 21:00:22 +00:00
needs_secrets = pytest.mark.skipif(
not secrets.NORDNET_USERNAME,
reason='Secret NORDNET_USERNAME required',
)
2024-06-20 21:01:11 +00:00
2024-07-21 09:09:49 +00:00
def print_pretty(depo: fin_depo.data.Depo):
2024-07-18 23:24:59 +00:00
for asset in depo.assets():
amount = depo.get_amount_of_asset(asset)
print(f'{str(asset):15} : {amount:10}')
del asset, amount
2024-06-20 21:00:22 +00:00
@needs_secrets
2024-06-04 20:14:58 +00:00
def test_get_depo():
session = requests.Session()
2024-07-21 09:09:49 +00:00
fetcher = fin_depo.investbank_nordnet.NordnetDepoFetcher(
2024-06-04 20:15:21 +00:00
session,
2024-06-20 21:00:22 +00:00
secrets.NORDNET_USERNAME,
secrets.NORDNET_PASSWORD,
2024-06-04 20:14:58 +00:00
)
2024-07-18 22:53:14 +00:00
depo = fetcher.get_depo()
2024-07-18 23:24:59 +00:00
print_pretty(depo)
2024-07-21 09:09:49 +00:00
assert isinstance(depo, fin_depo.data.DepoGroup)