Commit d817fd74 authored by Maxime Gasselin's avatar Maxime Gasselin Committed by Romain Bignon

[cmso] Allows inexistant json transfer keys

For some accounts some json keys are absent, we have to handle it to
avoid iter_account and iter_recipient crash.

Closes: 18008@sibi
parent db1ce527
......@@ -175,8 +175,7 @@ class CmsoParBrowser(LoginBrowser, StatesMixin):
self.page.check_response()
for key in self.page.get_keys():
for a in self.page.iter_accounts(key=key):
if a.id in accounts_eligibilite_debit:
a._eligible_debit = accounts_eligibilite_debit[a.id]
a._eligible_debit = accounts_eligibilite_debit.get(a.id, False)
# Can have duplicate account, avoid them
if a._index not in seen:
self.accounts_list.append(a)
......@@ -187,8 +186,7 @@ class CmsoParBrowser(LoginBrowser, StatesMixin):
page = self.accounts.go(data=json.dumps({}), type='epargne', headers=self.json_headers)
for key in page.get_keys():
for a in page.iter_savings(key=key, numbers=numbers):
if a.id in accounts_eligibilite_debit:
a._eligible_debit = accounts_eligibilite_debit[a.id]
a._eligible_debit = accounts_eligibilite_debit.get(a.id, False)
if a._index in seen:
acc = seen[a._index]
self.accounts_list.remove(acc)
......
......@@ -72,23 +72,26 @@ class TransferInfoPage(LoggedPage, JsonPage):
ret = {}
ret.update({
d[key]: d[value]
d[key]: d.get(value)
for d in self.doc['listCompteTitulaireCotitulaire']
})
ret.update({
d[key]: d[value]
d[key]: d.get(value)
for p in self.doc['listCompteMandataire'].values()
for d in p
})
ret.update({
d[key]: d[value]
d[key]: d.get(value)
for p in self.doc['listCompteLegalRep'].values()
for d in p
})
return ret
def get_numbers(self):
return self.get_transfer_info('numbers')
transfer_numbers = self.get_transfer_info('numbers')
for key, value in transfer_numbers.items():
assert value, "The 'numeroContratSouscrit' associated with the account index: %s is empty" % key
return transfer_numbers
def get_eligibilite_debit(self):
return self.get_transfer_info('eligibilite_debit')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment