Skip to content

Commit

Permalink
changes for get account when exist proxy (#78)
Browse files Browse the repository at this point in the history
* changes for get account when exist proxy

* add tests

* conver dict into Account

* dict comprrenhetion
  • Loading branch information
gregcastro authored and felipao-mx committed Nov 27, 2019
1 parent 694aecb commit 34779cc
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
14 changes: 11 additions & 3 deletions arcus/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,17 @@ def request(

@property
def accounts(self) -> Dict[str, Account]:
accounts_ = dict(primary=Account(**self.get('/account')))
if self.topup_key:
accounts_['topup'] = Account(**self.get('/account', topup=True))
if self.proxy:
accounts_dict = self.get('/account')
accounts_ = {
key: Account(**val) for key, val in accounts_dict.items()
}
else:
accounts_ = dict(primary=Account(**self.get('/account')))
if self.topup_key:
accounts_['topup'] = Account(
**self.get('/account', topup=True)
)
return accounts_

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion arcus/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.2.1' # pragma: no cover
__version__ = '1.2.2' # pragma: no cover
16 changes: 12 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,18 @@ def client_proxy():
m.get(
f'{proxy}/account',
json=dict(
name='Cuenca',
balance=60454.43,
minimum_balance=0.0,
currency='MXN',
primary=dict(
name='cuenca',
balance=63869.33,
minimum_balance=0.0,
currency='MXN',
),
topup=dict(
name='cuenca-tae',
balance=69720.0,
minimum_balance=0.0,
currency='MXN',
),
),
)
m.post(
Expand Down
10 changes: 10 additions & 0 deletions tests/resources/test_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ def test_get_account_info(client):
assert account.balance > account.minimum_balance


@pytest.mark.vcr
def test_get_topup_account_info(client_proxy):
accounts = client_proxy.get('/account', topup=True)
for account in accounts.values():
assert type(account) is dict
assert account['currency'] == 'MXN'
assert type(account['balance']) is float
assert account['balance'] > account['minimum_balance']


def test_get_account_info_proxy(client_proxy):
accounts = client_proxy.accounts
assert type(accounts) is dict
Expand Down

0 comments on commit 34779cc

Please sign in to comment.