Commit 1dfa6b25 authored by Quentin Defenouillere's avatar Quentin Defenouillere Committed by Romain Bignon

[caissedepargne] Handle inactive accounts

Inactive accounts have no link and if we try to click for history or
investments, it returns a BrowserUnavailable.
So we must verify if they are inactive before trying requests.
parent 6f0e0d91
......@@ -536,6 +536,9 @@ class CaisseEpargne(LoginBrowser, StatesMixin):
self.page.go_history(account._info)
if account.type in (Account.TYPE_LIFE_INSURANCE, Account.TYPE_PERP):
if self.page.is_account_inactive(account.id):
self.logger.warning('Account %s %s is inactive.' % (account.label, account.id))
return iter([])
if "MILLEVIE" in account.label:
self.page.go_life_insurance(account)
label = account.label.split()[-1]
......@@ -627,6 +630,9 @@ class CaisseEpargne(LoginBrowser, StatesMixin):
return
elif account.type in (Account.TYPE_LIFE_INSURANCE, Account.TYPE_CAPITALISATION):
if self.page.is_account_inactive(account.id):
self.logger.warning('Account %s %s is inactive.' % (account.label, account.id))
return
if "MILLEVIE" in account.label:
self.page.go_life_insurance(account)
label = account.label.split()[-1]
......
......@@ -281,6 +281,9 @@ class IndexPage(LoggedPage, HTMLPage):
info['acc_type'] = Account.TYPE_MARKET
return info
def is_account_inactive(self, account_id):
return self.doc.xpath('//tr[td[contains(text(), $id)]][@class="Inactive"]', id=account_id)
def _add_account(self, accounts, link, label, account_type, balance):
info = self._get_account_info(link, accounts)
if info is None:
......
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