Commit a0c79c18 authored by Christophe Francois's avatar Christophe Francois Committed by Vincent A

[cmes] Handle new action needed

parent b53e50ba
......@@ -23,7 +23,7 @@ from datetime import datetime
from dateutil.relativedelta import relativedelta
from weboob.browser import LoginBrowser, URL, need_login
from weboob.exceptions import BrowserIncorrectPassword
from weboob.exceptions import BrowserIncorrectPassword, ActionNeeded
from .pages import (
LoginPage, AccountsPage, OperationsListPage, OperationPage, ActionNeededPage,
InvestmentPage, InvestmentDetailsPage, AssetManagementPage,
......@@ -36,7 +36,8 @@ class CmesBrowser(LoginBrowser):
login = URL(r'(?P<client_space>.*)fr/identification/authentification.html', LoginPage)
action_needed = URL(
r'(?P<subsite>.*)(?P<client_space>.*)fr/epargnants/premiers-pas/saisir-vos-coordonnees.*',
r'(?P<subsite>.*)(?P<client_space>.*)fr/epargnants/premiers-pas/saisir-vos-coordonnees',
r'(?P<subsite>.*)(?P<client_space>.*)fr/epargnants/premiers-pas/vos-services',
r'(?P<subsite>.*)(?P<client_space>.*)fr/epargnants/conditions-generales-d-utilisation/index.html',
ActionNeededPage
)
......@@ -81,6 +82,24 @@ class CmesBrowser(LoginBrowser):
@need_login
def iter_accounts(self):
self.accounts.go(subsite=self.subsite, client_space=self.client_space)
if self.action_needed.is_here():
# Sometimes the page is skippable
skip_url = self.page.get_skip_url()
if skip_url:
self.location(skip_url)
else:
msg = self.page.get_message()
if any((
"Merci de renseigner votre adresse e-mail" in msg,
"Merci de renseigner votre numéro de téléphone mobile" in msg,
"Veuillez accepter les conditions générales d'utilisation" in msg,
"Vos services" in msg,
)):
raise ActionNeeded(msg)
else:
raise AssertionError('Unhandled action needed: %s' % msg)
return self.page.iter_accounts()
@need_login
......
......@@ -31,7 +31,6 @@ from weboob.browser.filters.html import Link
from weboob.capabilities.bank import Account, NotAvailable
from weboob.capabilities.wealth import Investment, Pocket
from weboob.tools.capabilities.bank.transactions import FrenchTransaction
from weboob.exceptions import ActionNeeded
class Transaction(FrenchTransaction):
......@@ -57,25 +56,11 @@ class LoginPage(HTMLPage):
class ActionNeededPage(HTMLPage, LoggedPage):
def on_load(self):
# Need to update mail. Try to skip
msg = "Merci de renseigner votre adresse e-mail"
if CleanText('//p[@role="heading" and contains(text(), "%s")]' % msg)(self.doc):
url = Link('//a[contains(., "PASSER CETTE ETAPE")]', default=None)(self.doc)
if url:
self.browser.location(url)
else:
raise ActionNeeded(msg)
# Mobile phone update can not be skipped
msg = "Merci de renseigner votre numéro de téléphone mobile"
if CleanText('//p[@role="heading" and contains(text(), "%s")]' % msg)(self.doc):
raise ActionNeeded(msg)
def get_message(self):
return CleanText('//p[@role="heading"]')(self.doc)
# CGU, can not bypass
msg = "Veuillez accepter les conditions générales d'utilisation"
if CleanText('//p[@role="heading" and contains(text(), "%s")]' % msg)(self.doc):
raise ActionNeeded(msg)
def get_skip_url(self):
return Link('//a[contains(., "PASSER CETTE ETAPE")]', default=None)(self.doc)
ACCOUNTS_TYPES = {
......
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