support repositories to manage backends (closes #747)
This commit is contained in:
parent
ef16a5b726
commit
14a7a1d362
410 changed files with 1079 additions and 297 deletions
3
modules/bouygues/__init__.py
Normal file
3
modules/bouygues/__init__.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
from .backend import BouyguesBackend
|
||||
|
||||
__all__ = ['BouyguesBackend']
|
||||
52
modules/bouygues/backend.py
Normal file
52
modules/bouygues/backend.py
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright(C) 2010-2011 Christophe Benz
|
||||
#
|
||||
# This file is part of weboob.
|
||||
#
|
||||
# weboob is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# weboob is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from __future__ import with_statement
|
||||
|
||||
from weboob.capabilities.messages import CantSendMessage, ICapMessages, ICapMessagesPost
|
||||
from weboob.tools.backend import BaseBackend, BackendConfig
|
||||
from weboob.tools.value import ValueBackendPassword, Value
|
||||
|
||||
from .browser import BouyguesBrowser
|
||||
|
||||
|
||||
__all__ = ['BouyguesBackend']
|
||||
|
||||
|
||||
class BouyguesBackend(BaseBackend, ICapMessages, ICapMessagesPost):
|
||||
NAME = 'bouygues'
|
||||
MAINTAINER = 'Christophe Benz'
|
||||
EMAIL = 'christophe.benz@gmail.com'
|
||||
VERSION = '0.a'
|
||||
DESCRIPTION = 'Bouygues french mobile phone provider'
|
||||
LICENSE = 'AGPLv3+'
|
||||
CONFIG = BackendConfig(Value('login', label='Login'),
|
||||
ValueBackendPassword('password', label='Password'))
|
||||
BROWSER = BouyguesBrowser
|
||||
ACCOUNT_REGISTER_PROPERTIES = None
|
||||
|
||||
def create_default_browser(self):
|
||||
return self.create_browser(self.config['login'].get(), self.config['password'].get())
|
||||
|
||||
def post_message(self, message):
|
||||
if not message.content.strip():
|
||||
raise CantSendMessage(u'Message content is empty.')
|
||||
with self.browser:
|
||||
self.browser.post_message(message)
|
||||
62
modules/bouygues/browser.py
Normal file
62
modules/bouygues/browser.py
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright(C) 2010-2011 Christophe Benz
|
||||
#
|
||||
# This file is part of weboob.
|
||||
#
|
||||
# weboob is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# weboob is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from .pages.compose import ComposeFrame, ComposePage, ConfirmPage, SentPage
|
||||
from .pages.login import LoginPage, LoginSASPage
|
||||
|
||||
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
|
||||
|
||||
|
||||
__all__ = ['BouyguesBrowser']
|
||||
|
||||
|
||||
class BouyguesBrowser(BaseBrowser):
|
||||
DOMAIN = 'www.bouyguestelecom.fr'
|
||||
PAGES = {
|
||||
'http://www.espaceclient.bouyguestelecom.fr/ECF/jsf/client/envoiSMS/viewEnvoiSMS.jsf': ComposePage,
|
||||
'http://www.mobile.service.bbox.bouyguestelecom.fr/services/SMSIHD/sendSMS.phtml': ComposeFrame,
|
||||
'http://www.mobile.service.bbox.bouyguestelecom.fr/services/SMSIHD/confirmSendSMS.phtml': ConfirmPage,
|
||||
'https://www.espaceclient.bouyguestelecom.fr/ECF/jsf/submitLogin.jsf': LoginPage,
|
||||
'https://www.espaceclient.bouyguestelecom.fr/ECF/SasUnifie': LoginSASPage,
|
||||
'http://www.mobile.service.bbox.bouyguestelecom.fr/services/SMSIHD/resultSendSMS.phtml': SentPage,
|
||||
}
|
||||
|
||||
def home(self):
|
||||
self.location('http://www.espaceclient.bouyguestelecom.fr/ECF/jsf/client/envoiSMS/viewEnvoiSMS.jsf')
|
||||
|
||||
def is_logged(self):
|
||||
return 'code' not in [form.name for form in self.forms()]
|
||||
|
||||
def login(self):
|
||||
self.location('https://www.espaceclient.bouyguestelecom.fr/ECF/jsf/submitLogin.jsf', no_login=True)
|
||||
self.page.login(self.username, self.password)
|
||||
assert self.is_on_page(LoginSASPage)
|
||||
self.page.login()
|
||||
if not self.is_logged():
|
||||
raise BrowserIncorrectPassword()
|
||||
|
||||
def post_message(self, message):
|
||||
if not self.is_on_page(ComposeFrame):
|
||||
self.home()
|
||||
self.location('http://www.mobile.service.bbox.bouyguestelecom.fr/services/SMSIHD/sendSMS.phtml')
|
||||
self.page.post_message(message)
|
||||
assert self.is_on_page(ConfirmPage)
|
||||
self.page.confirm()
|
||||
assert self.is_on_page(SentPage)
|
||||
BIN
modules/bouygues/favicon.png
Normal file
BIN
modules/bouygues/favicon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.1 KiB |
0
modules/bouygues/pages/__init__.py
Normal file
0
modules/bouygues/pages/__init__.py
Normal file
53
modules/bouygues/pages/compose.py
Normal file
53
modules/bouygues/pages/compose.py
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright(C) 2010-2011 Christophe Benz
|
||||
#
|
||||
# This file is part of weboob.
|
||||
#
|
||||
# weboob is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# weboob is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import re
|
||||
|
||||
from weboob.capabilities.messages import CantSendMessage
|
||||
from weboob.tools.browser import BasePage
|
||||
|
||||
|
||||
__all__ = ['ComposeFrame', 'ComposePage', 'ConfirmPage', 'SentPage']
|
||||
|
||||
|
||||
class ComposeFrame(BasePage):
|
||||
phone_regex = re.compile('^(\+33|0033|0)(6|7)(\d{8})$')
|
||||
|
||||
def post_message(self, message):
|
||||
receiver = message.thread.id
|
||||
if self.phone_regex.match(receiver) is None:
|
||||
raise CantSendMessage(u'Invalid receiver: %s' % receiver)
|
||||
self.browser.select_form(nr=0)
|
||||
self.browser['fieldMsisdn'] = receiver
|
||||
self.browser['fieldMessage'] = message.content.encode('utf-8')
|
||||
self.browser.submit()
|
||||
|
||||
|
||||
class ComposePage(BasePage):
|
||||
pass
|
||||
|
||||
|
||||
class ConfirmPage(BasePage):
|
||||
def confirm(self):
|
||||
self.browser.location('http://www.mobile.service.bbox.bouyguestelecom.fr/services/SMSIHD/resultSendSMS.phtml')
|
||||
|
||||
|
||||
class SentPage(BasePage):
|
||||
pass
|
||||
38
modules/bouygues/pages/login.py
Normal file
38
modules/bouygues/pages/login.py
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright(C) 2010-2011 Christophe Benz
|
||||
#
|
||||
# This file is part of weboob.
|
||||
#
|
||||
# weboob is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# weboob is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from weboob.tools.browser import BasePage
|
||||
|
||||
|
||||
__all__ = ['LoginPage', 'LoginSASPage']
|
||||
|
||||
|
||||
class LoginPage(BasePage):
|
||||
def login(self, login, password):
|
||||
self.browser.select_form(name='code')
|
||||
self.browser['j_username'] = login
|
||||
self.browser['j_password'] = password
|
||||
self.browser.submit()
|
||||
|
||||
|
||||
class LoginSASPage(BasePage):
|
||||
def login(self):
|
||||
self.browser.select_form(name='redirect')
|
||||
self.browser.submit()
|
||||
27
modules/bouygues/test.py
Normal file
27
modules/bouygues/test.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright(C) 2010-2011 Christophe Benz
|
||||
#
|
||||
# This file is part of weboob.
|
||||
#
|
||||
# weboob is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# weboob is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from weboob.tools.test import BackendTest
|
||||
|
||||
class BouyguesTest(BackendTest):
|
||||
BACKEND = 'bouygues'
|
||||
|
||||
def test_bouygues(self):
|
||||
pass
|
||||
Loading…
Add table
Add a link
Reference in a new issue