From 8836b79ea95a1f22dcc60eabde655e17088a7216 Mon Sep 17 00:00:00 2001 From: Guillaume Risbourg Date: Mon, 7 Oct 2019 13:27:23 +0200 Subject: [PATCH] [fortuneo] Added ActionNeeded when site ask for user infos When checking for investments for PEA, the website ask the user to update its infos if they are too old. Added ActionNeeded in that case. --- modules/fortuneo/pages/accounts_list.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/fortuneo/pages/accounts_list.py b/modules/fortuneo/pages/accounts_list.py index 40cfc79fb2..1302458dbf 100644 --- a/modules/fortuneo/pages/accounts_list.py +++ b/modules/fortuneo/pages/accounts_list.py @@ -71,6 +71,15 @@ class PeaHistoryPage(LoggedPage, HTMLPage): COL_PERF = 6 COL_WEIGHT = 7 + def on_load(self): + err_msgs = [ + "vos informations personnelles n'ayant pas été modifiées récemment, nous vous remercions de bien vouloir les compléter", + "nous vous remercions de mettre à jour et/ou de compléter vos informations personnelles", + ] + text = CleanText('//div[@class="block_cadre"]//div/p')(self.doc) + if any(err_msg in text for err_msg in err_msgs): + raise ActionNeeded(text) + def get_investments(self, account): if account is not None: # the balance is highly dynamic, fetch it along with the investments to grab a snapshot @@ -503,18 +512,18 @@ def get_list(self): break investment_page = None - if account.type in {Account.TYPE_PEA, Account.TYPE_MARKET, Account.TYPE_LIFE_INSURANCE}: + if account.type in (Account.TYPE_PEA, Account.TYPE_MARKET, Account.TYPE_LIFE_INSURANCE): account._investment_link = Link('./ul/li/a[contains(@id, "portefeuille")]')(cpt) - investment_page = self.browser.open(account._investment_link).page + investment_page = self.browser.location(account._investment_link).page balance = investment_page.get_balance(account.type) - if account.type in {Account.TYPE_PEA, Account.TYPE_MARKET}: + if account.type in (Account.TYPE_PEA, Account.TYPE_MARKET): self.browser.investments[account.id] = list(self.browser.open(account._investment_link).page.get_investments(account)) else: balance = page.get_balance() if account.type is not Account.TYPE_LOAN: account.coming = page.get_coming() - if account.type in {Account.TYPE_PEA, Account.TYPE_MARKET}: + if account.type in (Account.TYPE_PEA, Account.TYPE_MARKET): account.currency = investment_page.get_currency() elif balance: account.currency = account.get_currency(balance) -- GitLab