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-18 23:24:59 +00:00
|
|
|
from fin_depo import data, investbank_nordnet
|
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-18 23:24:59 +00:00
|
|
|
def print_pretty(depo: data.Depo):
|
|
|
|
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-18 22:53:14 +00:00
|
|
|
fetcher = 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-06-04 20:14:58 +00:00
|
|
|
assert depo is not None
|