1
0

Expose data in __init__
All checks were successful
Test Python / Test (push) Successful in 27s

This commit is contained in:
Jon Michael Aanes 2024-07-21 11:09:49 +02:00
parent 5a7c1f3a65
commit 677e2af74c
Signed by: Jmaa
SSH Key Fingerprint: SHA256:Ab0GfHGCblESJx7JRE4fj4bFy/KRpeLhi41y4pF3sNA
5 changed files with 34 additions and 18 deletions

View File

@ -37,7 +37,14 @@ __all__ = [
'defi_partisia_blockchain', 'defi_partisia_blockchain',
'investbank_nordnet', 'investbank_nordnet',
'__version__', '__version__',
'data',
] ]
from . import defi_kraken, defi_kucoin, defi_partisia_blockchain, investbank_nordnet from . import (
data,
defi_kraken,
defi_kucoin,
defi_partisia_blockchain,
investbank_nordnet,
)
from ._version import __version__ from ._version import __version__

View File

@ -1,7 +1,7 @@
import pytest import pytest
import requests import requests
from fin_depo import defi_kraken import fin_depo
from . import secrets from . import secrets
@ -14,10 +14,10 @@ needs_secrets = pytest.mark.skipif(
@needs_secrets @needs_secrets
def test_get_depo(): def test_get_depo():
session = requests.Session() session = requests.Session()
fetcher = defi_kraken.KrakenDepoFetcher( fetcher = fin_depo.defi_kraken.KrakenDepoFetcher(
secrets.KRAKEN_KEY, secrets.KRAKEN_KEY,
secrets.KRAKEN_SECRET, secrets.KRAKEN_SECRET,
) )
depo = fetcher.get_depo() depo = fetcher.get_depo()
assert depo is not None assert isinstance(depo, fin_depo.data.DepoSingle)

View File

@ -3,7 +3,7 @@ from decimal import Decimal
import fin_defs import fin_defs
import pytest import pytest
from fin_depo import defi_kucoin import fin_depo
from . import secrets from . import secrets
@ -14,26 +14,29 @@ needs_secrets = pytest.mark.skipif(
reason='Secret kucoin_USERNAME required', reason='Secret kucoin_USERNAME required',
) )
defi_kucoin.logger.setLevel('INFO') fin_depo.defi_kucoin.logger.setLevel('INFO')
@needs_secrets @needs_secrets
def test_get_depo(): def test_get_depo():
"""Can inspect kucoin depository.""" """Can inspect kucoin depository."""
fetcher = defi_kucoin.KucoinDepoFetcher( fetcher = fin_depo.defi_kucoin.KucoinDepoFetcher(
secrets.KUCOIN_KEY, secrets.KUCOIN_KEY,
secrets.KUCOIN_SECRET, secrets.KUCOIN_SECRET,
secrets.KUCOIN_PASS, secrets.KUCOIN_PASS,
) )
depo = fetcher.get_depo() depo = fetcher.get_depo()
assert depo is not None
assert isinstance(depo, fin_depo.data.DepoGroup)
for nested_depo in depo.nested:
assert isinstance(nested_depo, fin_depo.data.DepoSingle)
@needs_secrets @needs_secrets
def test_place_market_order_requires_allow_trades(): def test_place_market_order_requires_allow_trades():
"""Client fails if allow_trades is not enabled when doing market orders.""" """Client fails if allow_trades is not enabled when doing market orders."""
fetcher = defi_kucoin.KucoinDepoFetcher( fetcher = fin_depo.defi_kucoin.KucoinDepoFetcher(
secrets.KUCOIN_KEY, secrets.KUCOIN_KEY,
secrets.KUCOIN_SECRET, secrets.KUCOIN_SECRET,
secrets.KUCOIN_PASS, secrets.KUCOIN_PASS,
@ -49,7 +52,7 @@ def test_place_market_order_requires_allow_trades():
@needs_secrets @needs_secrets
def test_place_buy_side_order(): def test_place_buy_side_order():
"""Client can place buy side market orders.""" """Client can place buy side market orders."""
fetcher = defi_kucoin.KucoinDepoFetcher( fetcher = fin_depo.defi_kucoin.KucoinDepoFetcher(
secrets.KUCOIN_KEY, secrets.KUCOIN_KEY,
secrets.KUCOIN_SECRET, secrets.KUCOIN_SECRET,
secrets.KUCOIN_PASS, secrets.KUCOIN_PASS,
@ -83,7 +86,7 @@ def test_place_buy_side_order():
@needs_secrets @needs_secrets
def test_place_sell_side_order(): def test_place_sell_side_order():
"""Client can place sell side market orders.""" """Client can place sell side market orders."""
fetcher = defi_kucoin.KucoinDepoFetcher( fetcher = fin_depo.defi_kucoin.KucoinDepoFetcher(
secrets.KUCOIN_KEY, secrets.KUCOIN_KEY,
secrets.KUCOIN_SECRET, secrets.KUCOIN_SECRET,
secrets.KUCOIN_PASS, secrets.KUCOIN_PASS,

View File

@ -1,7 +1,7 @@
import pytest import pytest
import requests import requests
from fin_depo import data, investbank_nordnet import fin_depo
from . import secrets from . import secrets
@ -11,7 +11,7 @@ needs_secrets = pytest.mark.skipif(
) )
def print_pretty(depo: data.Depo): def print_pretty(depo: fin_depo.data.Depo):
for asset in depo.assets(): for asset in depo.assets():
amount = depo.get_amount_of_asset(asset) amount = depo.get_amount_of_asset(asset)
print(f'{str(asset):15} : {amount:10}') print(f'{str(asset):15} : {amount:10}')
@ -21,7 +21,7 @@ def print_pretty(depo: data.Depo):
@needs_secrets @needs_secrets
def test_get_depo(): def test_get_depo():
session = requests.Session() session = requests.Session()
fetcher = investbank_nordnet.NordnetDepoFetcher( fetcher = fin_depo.investbank_nordnet.NordnetDepoFetcher(
session, session,
secrets.NORDNET_USERNAME, secrets.NORDNET_USERNAME,
secrets.NORDNET_PASSWORD, secrets.NORDNET_PASSWORD,
@ -29,4 +29,4 @@ def test_get_depo():
depo = fetcher.get_depo() depo = fetcher.get_depo()
print_pretty(depo) print_pretty(depo)
assert depo is not None assert isinstance(depo, fin_depo.data.DepoGroup)

View File

@ -1,22 +1,28 @@
import fin_defs import fin_defs
import requests import requests
from fin_depo import defi_partisia_blockchain import fin_depo
def test_get_depo(): def test_get_depo():
session = requests.Session() session = requests.Session()
fetcher = defi_partisia_blockchain.PartisiaBlockchainAccountDepoFetcher( fetcher = fin_depo.defi_partisia_blockchain.PartisiaBlockchainAccountDepoFetcher(
session, session,
'00f3a778fbcf663e4f0d47b41aa4ec51e0f9d39d60', '00f3a778fbcf663e4f0d47b41aa4ec51e0f9d39d60',
) )
depo = fetcher.get_depo() depo = fetcher.get_depo()
assert depo is not None
# Check layout
assert isinstance(depo, fin_depo.data.DepoGroup)
assert depo.name == 'Partisia Blockchain' assert depo.name == 'Partisia Blockchain'
assert depo.updated_time is not None assert depo.updated_time is not None
assert isinstance(depo.nested[0], fin_depo.data.DepoSingle)
assert depo.nested[0].name == 'Native' assert depo.nested[0].name == 'Native'
assert depo.nested[0].updated_time == depo.updated_time assert depo.nested[0].updated_time == depo.updated_time
assert isinstance(depo.nested[0], fin_depo.data.DepoSingle)
assert depo.nested[1].name == 'Bring Your Own Coin' assert depo.nested[1].name == 'Bring Your Own Coin'
assert depo.nested[1].updated_time == depo.updated_time assert depo.nested[1].updated_time == depo.updated_time