several fixes to run successfully tests
This commit is contained in:
parent
832e5d9683
commit
abb24b9954
9 changed files with 80 additions and 76 deletions
|
|
@ -23,7 +23,10 @@ from logging import warning
|
|||
|
||||
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
|
||||
from weboob.capabilities.bank import TransferError, Transfer
|
||||
from bnporc import pages
|
||||
from .pages import AccountsList, AccountHistory, ChangePasswordPage, \
|
||||
AccountComing, AccountPrelevement, TransferPage, \
|
||||
TransferConfirmPage, TransferCompletePage, \
|
||||
LoginPage, ConfirmPage
|
||||
from .errors import PasswordExpired
|
||||
|
||||
|
||||
|
|
@ -34,18 +37,18 @@ class BNPorc(BaseBrowser):
|
|||
DOMAIN = 'www.secure.bnpparibas.net'
|
||||
PROTOCOL = 'https'
|
||||
ENCODING = None # refer to the HTML encoding
|
||||
PAGES = {'.*identifiant=DOSSIER_Releves_D_Operation.*': pages.AccountsList,
|
||||
'.*SAF_ROP.*': pages.AccountHistory,
|
||||
'.*Action=SAF_CHM.*': pages.ChangePasswordPage,
|
||||
'.*NS_AVEDT.*': pages.AccountComing,
|
||||
'.*NS_AVEDP.*': pages.AccountPrelevement,
|
||||
'.*NS_VIRDF.*': pages.TransferPage,
|
||||
'.*NS_VIRDC.*': pages.TransferConfirmPage,
|
||||
'.*/NS_VIRDA\?stp=(?P<id>\d+).*': pages.TransferCompletePage,
|
||||
'.*Action=DSP_VGLOBALE.*': pages.LoginPage,
|
||||
'.*type=homeconnex.*': pages.LoginPage,
|
||||
'.*layout=HomeConnexion.*': pages.ConfirmPage,
|
||||
'.*SAF_CHM_VALID.*': pages.ConfirmPage,
|
||||
PAGES = {'.*identifiant=DOSSIER_Releves_D_Operation.*': AccountsList,
|
||||
'.*SAF_ROP.*': AccountHistory,
|
||||
'.*Action=SAF_CHM.*': ChangePasswordPage,
|
||||
'.*NS_AVEDT.*': AccountComing,
|
||||
'.*NS_AVEDP.*': AccountPrelevement,
|
||||
'.*NS_VIRDF.*': TransferPage,
|
||||
'.*NS_VIRDC.*': TransferConfirmPage,
|
||||
'.*/NS_VIRDA\?stp=(?P<id>\d+).*': TransferCompletePage,
|
||||
'.*Action=DSP_VGLOBALE.*': LoginPage,
|
||||
'.*type=homeconnex.*': LoginPage,
|
||||
'.*layout=HomeConnexion.*': ConfirmPage,
|
||||
'.*SAF_CHM_VALID.*': ConfirmPage,
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
|
@ -57,31 +60,31 @@ class BNPorc(BaseBrowser):
|
|||
self.location('https://www.secure.bnpparibas.net/banque/portail/particulier/HomeConnexion?type=homeconnex')
|
||||
|
||||
def is_logged(self):
|
||||
return not self.is_on_page(pages.LoginPage)
|
||||
return not self.is_on_page(LoginPage)
|
||||
|
||||
def login(self):
|
||||
assert isinstance(self.username, basestring)
|
||||
assert isinstance(self.password, basestring)
|
||||
assert self.password.isdigit()
|
||||
|
||||
if not self.is_on_page(pages.LoginPage):
|
||||
if not self.is_on_page(LoginPage):
|
||||
self.location('https://www.secure.bnpparibas.net/banque/portail/particulier/HomeConnexion?type=homeconnex')
|
||||
|
||||
self.page.login(self.username, self.password)
|
||||
self.location('/NSFR?Action=DSP_VGLOBALE', no_login=True)
|
||||
|
||||
if self.is_on_page(pages.LoginPage):
|
||||
if self.is_on_page(LoginPage):
|
||||
raise BrowserIncorrectPassword()
|
||||
|
||||
def change_password(self, new_password):
|
||||
assert new_password.isdigit() and len(new_password) == 6
|
||||
|
||||
self.location('https://www.secure.bnpparibas.net/SAF_CHM?Action=SAF_CHM')
|
||||
assert self.is_on_page(pages.ChangePasswordPage)
|
||||
assert self.is_on_page(ChangePasswordPage)
|
||||
|
||||
self.page.change_password(self.password, new_password)
|
||||
|
||||
if not self.is_on_page(pages.ConfirmPage):
|
||||
if not self.is_on_page(ConfirmPage):
|
||||
self.logger.error('Oops, unable to change password')
|
||||
return
|
||||
|
||||
|
|
@ -105,7 +108,7 @@ class BNPorc(BaseBrowser):
|
|||
|
||||
@check_expired_password
|
||||
def get_accounts_list(self):
|
||||
if not self.is_on_page(pages.AccountsList):
|
||||
if not self.is_on_page(AccountsList):
|
||||
self.location('/NSFR?Action=DSP_VGLOBALE')
|
||||
|
||||
return self.page.get_list()
|
||||
|
|
@ -113,7 +116,7 @@ class BNPorc(BaseBrowser):
|
|||
def get_account(self, id):
|
||||
assert isinstance(id, basestring)
|
||||
|
||||
if not self.is_on_page(pages.AccountsList):
|
||||
if not self.is_on_page(AccountsList):
|
||||
self.location('/NSFR?Action=DSP_VGLOBALE')
|
||||
|
||||
l = self.page.get_list()
|
||||
|
|
@ -124,30 +127,30 @@ class BNPorc(BaseBrowser):
|
|||
return None
|
||||
|
||||
def get_history(self, account):
|
||||
if not self.is_on_page(pages.AccountHistory) or self.page.account.id != account.id:
|
||||
if not self.is_on_page(AccountHistory) or self.page.account.id != account.id:
|
||||
self.location('/SAF_ROP?ch4=%s' % account.link_id)
|
||||
return self.page.get_operations()
|
||||
|
||||
def get_coming_operations(self, account):
|
||||
if not self.is_on_page(pages.AccountComing) or self.page.account.id != account.id:
|
||||
if not self.is_on_page(AccountComing) or self.page.account.id != account.id:
|
||||
self.location('/NS_AVEDT?ch4=%s' % account.link_id)
|
||||
return self.page.get_operations()
|
||||
|
||||
def get_transfer_accounts(self):
|
||||
if not self.is_on_page(pages.TransferPage):
|
||||
if not self.is_on_page(TransferPage):
|
||||
self.location('/NS_VIRDF')
|
||||
|
||||
assert self.is_on_page(pages.TransferPage)
|
||||
assert self.is_on_page(TransferPage)
|
||||
return self.page.get_accounts()
|
||||
|
||||
def transfer(self, from_id, to_id, amount, reason=None):
|
||||
if not self.is_on_page(pages.TransferPage):
|
||||
if not self.is_on_page(TransferPage):
|
||||
self.location('/NS_VIRDF')
|
||||
|
||||
accounts = self.page.get_accounts()
|
||||
self.page.transfer(from_id, to_id, amount, reason)
|
||||
|
||||
if not self.is_on_page(pages.TransferCompletePage):
|
||||
if not self.is_on_page(TransferCompletePage):
|
||||
raise TransferError('An error occured during transfer')
|
||||
|
||||
transfer = Transfer(self.page.get_id())
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
|
||||
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
|
||||
from boursorama import pages
|
||||
from .pages import LoginPage, AccountsList, AccountHistory
|
||||
|
||||
from datetime import date
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
|
@ -34,9 +34,9 @@ class Boursorama(BaseBrowser):
|
|||
PROTOCOL = 'https'
|
||||
ENCODING = None # refer to the HTML encoding
|
||||
PAGES = {
|
||||
'.*connexion.phtml.*': pages.LoginPage,
|
||||
'.*/comptes/synthese.phtml': pages.AccountsList,
|
||||
'.*/comptes/banque/detail/mouvements.phtml.*': pages.AccountHistory,
|
||||
'.*connexion.phtml.*': LoginPage,
|
||||
'.*/comptes/synthese.phtml': AccountsList,
|
||||
'.*/comptes/banque/detail/mouvements.phtml.*': AccountHistory,
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
|
@ -46,23 +46,23 @@ class Boursorama(BaseBrowser):
|
|||
self.location('https://' + self.DOMAIN + '/connexion.phtml')
|
||||
|
||||
def is_logged(self):
|
||||
return not self.is_on_page(pages.LoginPage)
|
||||
return not self.is_on_page(LoginPage)
|
||||
|
||||
def login(self):
|
||||
assert isinstance(self.username, basestring)
|
||||
assert isinstance(self.password, basestring)
|
||||
assert self.password.isdigit()
|
||||
|
||||
if not self.is_on_page(pages.LoginPage):
|
||||
if not self.is_on_page(LoginPage):
|
||||
self.location('https://' + self.DOMAIN + '/connexion.phtml')
|
||||
|
||||
self.page.login(self.username, self.password)
|
||||
|
||||
if self.is_on_page(pages.LoginPage):
|
||||
if self.is_on_page(LoginPage):
|
||||
raise BrowserIncorrectPassword()
|
||||
|
||||
def get_accounts_list(self):
|
||||
if not self.is_on_page(pages.AccountsList):
|
||||
if not self.is_on_page(AccountsList):
|
||||
self.location('/comptes/synthese.phtml')
|
||||
|
||||
return self.page.get_list()
|
||||
|
|
@ -70,7 +70,7 @@ class Boursorama(BaseBrowser):
|
|||
def get_account(self, id):
|
||||
assert isinstance(id, basestring)
|
||||
|
||||
if not self.is_on_page(pages.AccountsList):
|
||||
if not self.is_on_page(AccountsList):
|
||||
self.location('/comptes/synthese.phtml')
|
||||
|
||||
l = self.page.get_list()
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
|
||||
from weboob.capabilities.bank import Transfer, TransferError
|
||||
from cragr import pages
|
||||
from .pages import LoginPage, AccountsList
|
||||
import mechanize
|
||||
from datetime import datetime
|
||||
import re
|
||||
|
|
@ -36,13 +36,13 @@ class Cragr(BaseBrowser):
|
|||
|
||||
def __init__(self, website, *args, **kwargs):
|
||||
self.DOMAIN = website
|
||||
self.PAGES = {'https://[^/]+/': pages.LoginPage,
|
||||
'https://[^/]+/.*\.c.*': pages.AccountsList,
|
||||
'https://[^/]+/login/process%s' % self.SESSION_REGEXP: pages.AccountsList,
|
||||
'https://[^/]+/accounting/listAccounts': pages.AccountsList,
|
||||
'https://[^/]+/accounting/listOperations': pages.AccountsList,
|
||||
'https://[^/]+/accounting/showAccountDetail.+': pages.AccountsList,
|
||||
'https://[^/]+/accounting/showMoreAccountOperations.*': pages.AccountsList,
|
||||
self.PAGES = {'https://[^/]+/': LoginPage,
|
||||
'https://[^/]+/.*\.c.*': AccountsList,
|
||||
'https://[^/]+/login/process%s' % self.SESSION_REGEXP: AccountsList,
|
||||
'https://[^/]+/accounting/listAccounts': AccountsList,
|
||||
'https://[^/]+/accounting/listOperations': AccountsList,
|
||||
'https://[^/]+/accounting/showAccountDetail.+': AccountsList,
|
||||
'https://[^/]+/accounting/showMoreAccountOperations.*': AccountsList,
|
||||
}
|
||||
BaseBrowser.__init__(self, *args, **kwargs)
|
||||
|
||||
|
|
@ -75,7 +75,7 @@ class Cragr(BaseBrowser):
|
|||
|
||||
self.is_logging = True
|
||||
# Are we on the good page?
|
||||
if not self.is_on_page(pages.LoginPage):
|
||||
if not self.is_on_page(LoginPage):
|
||||
self.logger.debug('going to login page')
|
||||
BaseBrowser.home(self)
|
||||
self.logger.debug('attempting to log in')
|
||||
|
|
@ -95,21 +95,21 @@ class Cragr(BaseBrowser):
|
|||
Ensure we are both logged and on the accounts list.
|
||||
"""
|
||||
self.logger.debug('accounts list page required')
|
||||
if self.is_on_page(pages.AccountsList) and self.page.is_accounts_list():
|
||||
if self.is_on_page(AccountsList) and self.page.is_accounts_list():
|
||||
self.logger.debug('already on accounts list')
|
||||
return
|
||||
|
||||
# simply go to http(s)://the.doma.in/
|
||||
BaseBrowser.home(self)
|
||||
|
||||
if self.is_on_page(pages.LoginPage):
|
||||
if self.is_on_page(LoginPage):
|
||||
if not self.is_logged():
|
||||
# So, we are not logged on the login page -- what about logging ourselves?
|
||||
self.login()
|
||||
# we assume we are logged in
|
||||
# for some regions, we may stay on the login page once we're
|
||||
# logged in, without being redirected...
|
||||
if self.is_on_page(pages.LoginPage):
|
||||
if self.is_on_page(LoginPage):
|
||||
# ... so we have to move by ourselves
|
||||
self.move_to_accounts_list()
|
||||
|
||||
|
|
@ -254,6 +254,6 @@ class Cragr(BaseBrowser):
|
|||
return transfer
|
||||
|
||||
#def get_coming_operations(self, account):
|
||||
# if not self.is_on_page(pages.AccountComing) or self.page.account.id != account.id:
|
||||
# if not self.is_on_page(AccountComing) or self.page.account.id != account.id:
|
||||
# self.location('/NS_AVEEC?ch4=%s' % account.link_id)
|
||||
# return self.page.get_operations()
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ from datetime import datetime
|
|||
|
||||
from weboob.tools.browser import BrokenPageError
|
||||
from weboob.tools.misc import local2utc
|
||||
from dlfp.tools import url2id
|
||||
from ..tools import url2id
|
||||
|
||||
from .index import DLFPPage
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
from datetime import datetime
|
||||
|
||||
from weboob.tools.test import BackendTest
|
||||
from dlfp.browser import DLFP
|
||||
from .browser import DLFP
|
||||
|
||||
|
||||
__all__ = ['DLFPTest']
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@
|
|||
|
||||
|
||||
from weboob.tools.browser import BaseBrowser
|
||||
from ing import pages
|
||||
from .pages import AccountsList, LoginPage, LoginPage2, \
|
||||
AccountHistoryCC, AccountHistoryLA
|
||||
|
||||
|
||||
__all__ = ['Ing']
|
||||
|
|
@ -29,11 +30,11 @@ class Ing(BaseBrowser):
|
|||
DOMAIN = 'secure.ingdirect.fr'
|
||||
PROTOCOL = 'https'
|
||||
ENCODING = None # refer to the HTML encoding
|
||||
PAGES = {'.*displayTRAccountSummary.*': pages.AccountsList,
|
||||
'.*displayLogin.jsf': pages.LoginPage,
|
||||
'.*displayLogin.jsf.*': pages.LoginPage2,
|
||||
'.*accountDetail.jsf.*': pages.AccountHistoryCC,
|
||||
'.*displayTRHistoriqueLA.*': pages.AccountHistoryLA
|
||||
PAGES = {'.*displayTRAccountSummary.*': AccountsList,
|
||||
'.*displayLogin.jsf': LoginPage,
|
||||
'.*displayLogin.jsf.*': LoginPage2,
|
||||
'.*accountDetail.jsf.*': AccountHistoryCC,
|
||||
'.*displayTRHistoriqueLA.*': AccountHistoryLA
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
|
@ -44,7 +45,7 @@ class Ing(BaseBrowser):
|
|||
self.location('https://secure.ingdirect.fr/public/displayLogin.jsf')
|
||||
|
||||
def is_logged(self):
|
||||
return not self.is_on_page(pages.LoginPage)
|
||||
return not self.is_on_page(LoginPage)
|
||||
|
||||
def login(self):
|
||||
assert isinstance(self.username, basestring)
|
||||
|
|
@ -53,14 +54,14 @@ class Ing(BaseBrowser):
|
|||
assert self.password.isdigit()
|
||||
assert self.birthday.isdigit()
|
||||
|
||||
if not self.is_on_page(pages.LoginPage):
|
||||
if not self.is_on_page(LoginPage):
|
||||
self.location('https://secure.ingdirect.fr/public/displayLogin.jsf')
|
||||
|
||||
self.page.prelogin(self.username, self.birthday)
|
||||
self.page.login(self.password)
|
||||
|
||||
def get_accounts_list(self):
|
||||
if not self.is_on_page(pages.AccountsList):
|
||||
if not self.is_on_page(AccountsList):
|
||||
self.location('/general?command=displayTRAccountSummary')
|
||||
|
||||
return self.page.get_list()
|
||||
|
|
@ -68,7 +69,7 @@ class Ing(BaseBrowser):
|
|||
def get_account(self, id):
|
||||
assert isinstance(id, basestring)
|
||||
|
||||
if not self.is_on_page(pages.AccountsList):
|
||||
if not self.is_on_page(AccountsList):
|
||||
self.location('/general?command=displayTRAccountSummary')
|
||||
|
||||
l = self.page.get_list()
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
|
||||
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
|
||||
from societegenerale import pages
|
||||
from .pages import LoginPage, AccountsList
|
||||
|
||||
|
||||
__all__ = ['SocieteGenerale']
|
||||
|
|
@ -31,9 +31,9 @@ class SocieteGenerale(BaseBrowser):
|
|||
PROTOCOL = 'https'
|
||||
ENCODING = None # refer to the HTML encoding
|
||||
PAGES = {
|
||||
'https://particuliers.societegenerale.fr/.*': pages.LoginPage,
|
||||
'.*restitution/cns_listeprestation.html': pages.AccountsList,
|
||||
# '.*restitution/cns_detailCav.html.*': pages.AccountHistory,
|
||||
'https://particuliers.societegenerale.fr/.*': LoginPage,
|
||||
'.*restitution/cns_listeprestation.html': AccountsList,
|
||||
# '.*restitution/cns_detailCav.html.*': AccountHistory,
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
|
@ -43,23 +43,23 @@ class SocieteGenerale(BaseBrowser):
|
|||
self.location('https://' + self.DOMAIN_LOGIN + '/index.html')
|
||||
|
||||
def is_logged(self):
|
||||
return not self.is_on_page(pages.LoginPage)
|
||||
return not self.is_on_page(LoginPage)
|
||||
|
||||
def login(self):
|
||||
assert isinstance(self.username, basestring)
|
||||
assert isinstance(self.password, basestring)
|
||||
assert self.password.isdigit()
|
||||
|
||||
if not self.is_on_page(pages.LoginPage):
|
||||
if not self.is_on_page(LoginPage):
|
||||
self.location('https://' + self.DOMAIN_LOGIN + '/index.html')
|
||||
|
||||
self.page.login(self.username, self.password)
|
||||
|
||||
if self.is_on_page(pages.LoginPage):
|
||||
if self.is_on_page(LoginPage):
|
||||
raise BrowserIncorrectPassword()
|
||||
|
||||
def get_accounts_list(self):
|
||||
if not self.is_on_page(pages.AccountsList):
|
||||
if not self.is_on_page(AccountsList):
|
||||
self.location('/restitution/cns_listeprestation.html')
|
||||
|
||||
return self.page.get_list()
|
||||
|
|
@ -67,7 +67,7 @@ class SocieteGenerale(BaseBrowser):
|
|||
def get_account(self, id):
|
||||
assert isinstance(id, basestring)
|
||||
|
||||
if not self.is_on_page(pages.AccountsList):
|
||||
if not self.is_on_page(AccountsList):
|
||||
self.location('/restitution/cns_listeprestation.html')
|
||||
|
||||
l = self.page.get_list()
|
||||
|
|
@ -80,7 +80,7 @@ class SocieteGenerale(BaseBrowser):
|
|||
def get_history(self, account):
|
||||
raise NotImplementedError()
|
||||
|
||||
if not self.is_on_page(pages.AccountHistory) or self.page.account.id != account.id:
|
||||
if not self.is_on_page(AccountHistory) or self.page.account.id != account.id:
|
||||
self.location(account.link_id)
|
||||
return self.page.get_operations()
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
from logging import error
|
||||
|
||||
from weboob.tools.browser import BasePage, BrowserUnavailable
|
||||
from societegenerale.captcha import Captcha, TileError
|
||||
from ..captcha import Captcha, TileError
|
||||
from lxml import etree
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ "$1" != "" ]; then
|
||||
nosetests -sv $(dirname $0)/../weboob/backends/$1
|
||||
nosetests -sv $(dirname $0)/../modules/$1
|
||||
else
|
||||
find $(dirname $0)/../weboob -name test.py | xargs nosetests -sv
|
||||
find $(dirname $0)/../weboob $(dirname $0)/../modules -name test.py | xargs nosetests -sv
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue