Skip to content

Commit 34779cc

Browse files
gregcastrofelipao-mx
authored andcommitted
changes for get account when exist proxy (#78)
* changes for get account when exist proxy * add tests * conver dict into Account * dict comprrenhetion
1 parent 694aecb commit 34779cc

File tree

4 files changed

+34
-8
lines changed

4 files changed

+34
-8
lines changed

arcus/client.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,17 @@ def request(
106106

107107
@property
108108
def accounts(self) -> Dict[str, Account]:
109-
accounts_ = dict(primary=Account(**self.get('/account')))
110-
if self.topup_key:
111-
accounts_['topup'] = Account(**self.get('/account', topup=True))
109+
if self.proxy:
110+
accounts_dict = self.get('/account')
111+
accounts_ = {
112+
key: Account(**val) for key, val in accounts_dict.items()
113+
}
114+
else:
115+
accounts_ = dict(primary=Account(**self.get('/account')))
116+
if self.topup_key:
117+
accounts_['topup'] = Account(
118+
**self.get('/account', topup=True)
119+
)
112120
return accounts_
113121

114122
@staticmethod

arcus/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.2.1' # pragma: no cover
1+
__version__ = '1.2.2' # pragma: no cover

tests/conftest.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,18 @@ def client_proxy():
1818
m.get(
1919
f'{proxy}/account',
2020
json=dict(
21-
name='Cuenca',
22-
balance=60454.43,
23-
minimum_balance=0.0,
24-
currency='MXN',
21+
primary=dict(
22+
name='cuenca',
23+
balance=63869.33,
24+
minimum_balance=0.0,
25+
currency='MXN',
26+
),
27+
topup=dict(
28+
name='cuenca-tae',
29+
balance=69720.0,
30+
minimum_balance=0.0,
31+
currency='MXN',
32+
),
2533
),
2634
)
2735
m.post(

tests/resources/test_accounts.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ def test_get_account_info(client):
1919
assert account.balance > account.minimum_balance
2020

2121

22+
@pytest.mark.vcr
23+
def test_get_topup_account_info(client_proxy):
24+
accounts = client_proxy.get('/account', topup=True)
25+
for account in accounts.values():
26+
assert type(account) is dict
27+
assert account['currency'] == 'MXN'
28+
assert type(account['balance']) is float
29+
assert account['balance'] > account['minimum_balance']
30+
31+
2232
def test_get_account_info_proxy(client_proxy):
2333
accounts = client_proxy.accounts
2434
assert type(accounts) is dict

0 commit comments

Comments
 (0)