Commit 548e7c58 authored by Jerome Berthier's avatar Jerome Berthier Committed by Romain Bignon

[cmes] add a class attribute client_space to build urls

It is needed for the child epsens, which overwrites this attribute.
parent 59b5f750
...@@ -30,16 +30,18 @@ class CmesBrowserNew(LoginBrowser): ...@@ -30,16 +30,18 @@ class CmesBrowserNew(LoginBrowser):
login = URL('r(?P<client_space>.*)fr/identification/authentification.html', LoginPage) login = URL('r(?P<client_space>.*)fr/identification/authentification.html', LoginPage)
accounts = URL(r'(?P<subsite>.*)espace-client/fr/epargnants/mon-epargne/situation-financiere-detaillee/index.html', accounts = URL(r'(?P<subsite>.*)(?P<client_space>.*)fr/epargnants/mon-epargne/situation-financiere-detaillee/index.html',
r'(?P<subsite>.*)espace-client/fr/epargnants/tableau-de-bord/index.html', r'(?P<subsite>.*)(?P<client_space>.*)fr/epargnants/tableau-de-bord/index.html',
NewAccountsPage) NewAccountsPage)
operations_list = URL(r'(?P<subsite>.*)espace-client/fr/epargnants/operations/index.html', operations_list = URL(r'(?P<subsite>.*)(?P<client_space>.*)fr/epargnants/operations/index.html',
OperationsListPage) OperationsListPage)
operation = URL(r'(?P<subsite>.*)espace-client/fr/epargnants/operations/consulter-une-operation/index.html\?param_=(?P<idx>\d+)', operation = URL(r'(?P<subsite>.*)(?P<client_space>.*)fr/epargnants/operations/consulter-une-operation/index.html\?param_=(?P<idx>\d+)',
OperationPage) OperationPage)
client_space = 'espace-client/'
def __init__(self, username, password, website, subsite="", *args, **kwargs): def __init__(self, username, password, website, subsite="", *args, **kwargs):
super(LoginBrowser, self).__init__(*args, **kwargs) super(LoginBrowser, self).__init__(*args, **kwargs)
self.BASEURL = website self.BASEURL = website
...@@ -52,7 +54,7 @@ class CmesBrowserNew(LoginBrowser): ...@@ -52,7 +54,7 @@ class CmesBrowserNew(LoginBrowser):
return 'IdSes' in self.session.cookies return 'IdSes' in self.session.cookies
def do_login(self): def do_login(self):
self.login.go() self.login.go(client_space=self.client_space)
self.page.login(self.username, self.password) self.page.login(self.username, self.password)
if self.login.is_here(): if self.login.is_here():
...@@ -60,7 +62,7 @@ class CmesBrowserNew(LoginBrowser): ...@@ -60,7 +62,7 @@ class CmesBrowserNew(LoginBrowser):
@need_login @need_login
def iter_accounts(self): def iter_accounts(self):
self.accounts.go(subsite=self.subsite) self.accounts.go(subsite=self.subsite, client_space=self.client_space)
return self.page.iter_accounts() return self.page.iter_accounts()
@need_login @need_login
...@@ -70,9 +72,9 @@ class CmesBrowserNew(LoginBrowser): ...@@ -70,9 +72,9 @@ class CmesBrowserNew(LoginBrowser):
@need_login @need_login
def iter_history(self, account): def iter_history(self, account):
self.operations_list.stay_or_go(subsite=self.subsite) self.operations_list.stay_or_go(subsite=self.subsite, client_space=self.client_space)
for idx in self.page.get_operations_idx(): for idx in self.page.get_operations_idx():
tr = self.operation.go(subsite=self.subsite, idx=idx).get_transaction() tr = self.operation.go(subsite=self.subsite, client_space=self.client_space, idx=idx).get_transaction()
if account.label == tr._account_label: if account.label == tr._account_label:
yield tr yield tr
......
...@@ -95,7 +95,6 @@ class NewAccountsPage(LoggedPage, HTMLPage): ...@@ -95,7 +95,6 @@ class NewAccountsPage(LoggedPage, HTMLPage):
row.xpath('//div[contains(@id, "dv::s::%s")]' % id_diff[0].rsplit(':', 1)[0])[0] if id_diff else None, row.xpath('//div[contains(@id, "dv::s::%s")]' % id_diff[0].rsplit(':', 1)[0])[0] if id_diff else None,
) )
def iter_investment(self, account): def iter_investment(self, account):
for row, elem_repartition, elem_pocket, elem_diff in self.iter_invest_rows(account=account): for row, elem_repartition, elem_pocket, elem_diff in self.iter_invest_rows(account=account):
inv = Investment() inv = Investment()
...@@ -109,12 +108,12 @@ class NewAccountsPage(LoggedPage, HTMLPage): ...@@ -109,12 +108,12 @@ class NewAccountsPage(LoggedPage, HTMLPage):
is_mirrored = '%' in row.text_content() is_mirrored = '%' in row.text_content()
if not is_mirrored: if not is_mirrored:
inv.diff = MyDecimal('.//td[3]', default=NotAvailable)(row) inv.diff = MyDecimal('.//td[3]')(row)
if elem_diff is not None: if elem_diff is not None:
inv.diff_ratio = Eval(lambda x: x / 100, inv.diff_ratio = Eval(lambda x: x / 100,
MyDecimal(Regexp(CleanText('.'), r'([+-]?[\d\s]+[\d,]+)\s*%')))(elem_diff) MyDecimal(Regexp(CleanText('.'), r'([+-]?[\d\s]+[\d,]+)\s*%')))(elem_diff)
else: else:
inv.diff = MyDecimal('.', defaut=NotAvailable)(elem_diff) inv.diff = MyDecimal('.')(elem_diff)
if elem_diff is not None: if elem_diff is not None:
inv.diff_ratio = Eval(lambda x: x / 100, inv.diff_ratio = Eval(lambda x: x / 100,
MyDecimal(Regexp(CleanText('.//td[3]'), r'([+-]?[\d\s]+[\d,]+)\s*%')))(row) MyDecimal(Regexp(CleanText('.//td[3]'), r'([+-]?[\d\s]+[\d,]+)\s*%')))(row)
......
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