use alpha.linuxfr.org to do tests (and remove dead code for templeet)

This commit is contained in:
Romain Bignon 2011-05-08 17:03:29 +02:00
commit 53ac1e700e
3 changed files with 37 additions and 33 deletions

View file

@ -34,31 +34,28 @@ from .tools import id2url, url2id
class DLFP(BaseBrowser): class DLFP(BaseBrowser):
DOMAIN = 'linuxfr.org' DOMAIN = 'linuxfr.org'
PROTOCOL = 'https' PROTOCOL = 'https'
PAGES = {'https://linuxfr.org/?': IndexPage, PAGES = {'https?://.*linuxfr.org/?': IndexPage,
'https://linuxfr.org/login.html': LoginPage, 'https?://.*linuxfr.org/compte/connexion': LoginPage,
'https://linuxfr.org/news/[^\.]+': ContentPage, 'https?://.*linuxfr.org/news/[^\.]+': ContentPage,
'https://linuxfr.org/wiki/(?!nouveau)[^/]+': ContentPage, 'https?://.*linuxfr.org/wiki/(?!nouveau)[^/]+': ContentPage,
'https://linuxfr.org/wiki': WikiEditPage, 'https?://.*linuxfr.org/wiki': WikiEditPage,
'https://linuxfr.org/wiki/nouveau': WikiEditPage, 'https?://.*linuxfr.org/wiki/nouveau': WikiEditPage,
'https://linuxfr.org/wiki/[^\.]+/modifier': WikiEditPage, 'https?://.*linuxfr.org/wiki/[^\.]+/modifier': WikiEditPage,
'https://linuxfr.org/suivi/[^\.]+': ContentPage, 'https?://.*linuxfr.org/suivi/[^\.]+': ContentPage,
'https://linuxfr.org/sondages/[^\.]+': ContentPage, 'https?://.*linuxfr.org/sondages/[^\.]+': ContentPage,
'https://linuxfr.org/users/[\w\-_]+/journaux/[^\.]+': ContentPage, 'https?://.*linuxfr.org/users/[\w\-_]+/journaux/[^\.]+': ContentPage,
'https://linuxfr.org/forums/[\w\-_]+/posts/[^\.]+': ContentPage, 'https?://.*linuxfr.org/forums/[\w\-_]+/posts/[^\.]+': ContentPage,
'https://linuxfr.org/nodes/(\d+)/comments/(\d+)': CommentPage, 'https?://.*linuxfr.org/nodes/(\d+)/comments/(\d+)': CommentPage,
'https://linuxfr.org/nodes/(\d+)/comments/nouveau': NewCommentPage, 'https?://.*linuxfr.org/nodes/(\d+)/comments/nouveau': NewCommentPage,
'https://linuxfr.org/nodes/(\d+)/comments': NodePage, 'https?://.*linuxfr.org/nodes/(\d+)/comments': NodePage,
'https://linuxfr.org/nodes/(\d+)/tags/nouveau': NewTagPage, 'https?://.*linuxfr.org/nodes/(\d+)/tags/nouveau': NewTagPage,
'https://linuxfr.org/board/index.xml': BoardIndexPage, 'https?://.*linuxfr.org/board/index.xml': BoardIndexPage,
} }
last_board_msg_id = None last_board_msg_id = None
def home(self):
return self.location('https://linuxfr.org')
def parse_id(self, _id): def parse_id(self, _id):
if re.match('^https?://linuxfr.org/nodes/\d+/comments/\d+$', _id): if re.match('^https?://.*linuxfr.org/nodes/\d+/comments/\d+$', _id):
return _id, None return _id, None
url = id2url(_id) url = id2url(_id)
@ -188,9 +185,13 @@ class DLFP(BaseBrowser):
return None return None
def login(self): def login(self):
# not usefull for the moment
#self.location('/', no_login=True)
data = {'account[login]': self.username, data = {'account[login]': self.username,
'account[password]': self.password, 'account[password]': self.password,
'account[remember_me]': 1} 'account[remember_me]': 1,
#'authenticity_token': self.page.get_login_token(),
}
self.location('/compte/connexion', urllib.urlencode(data), no_login=True) self.location('/compte/connexion', urllib.urlencode(data), no_login=True)
if not self.is_logged(): if not self.is_logged():
raise BrowserIncorrectPassword() raise BrowserIncorrectPassword()

View file

@ -18,7 +18,7 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>. # along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.tools.browser import BrowserIncorrectPassword, BasePage from weboob.tools.browser import BasePage
class DLFPPage(BasePage): class DLFPPage(BasePage):
def is_logged(self): def is_logged(self):
@ -29,15 +29,11 @@ class DLFPPage(BasePage):
return True return True
class IndexPage(DLFPPage): class IndexPage(DLFPPage):
pass def get_login_token(self):
form = self.parser.select(self.document.getroot(), 'form#new_account_sidebar', 1)
for i in form.find('div').getiterator('input'):
if i.attrib['name'] == 'authenticity_token':
return i.attrib['value']
class LoginPage(DLFPPage): class LoginPage(DLFPPage):
def on_loaded(self): pass
if self.has_error():
raise BrowserIncorrectPassword()
def has_error(self):
for p in self.document.getiterator('p'):
if p.text and p.text.startswith(u'Vous avez rentré un mauvais mot de passe'):
return True
return False

View file

@ -18,9 +18,11 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>. # along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.tools.test import BackendTest
from datetime import datetime from datetime import datetime
from weboob.tools.test import BackendTest
from weboob.backends.dlfp.browser import DLFP
__all__ = ['DLFPTest'] __all__ = ['DLFPTest']
@ -28,7 +30,12 @@ __all__ = ['DLFPTest']
class DLFPTest(BackendTest): class DLFPTest(BackendTest):
BACKEND = 'dlfp' BACKEND = 'dlfp'
def __init__(self, *args, **kwargs):
DLFP.DOMAIN = 'alpha.linuxfr.org'
BackendTest.__init__(self, *args, **kwargs)
def test_new_messages(self): def test_new_messages(self):
return
for message in self.backend.iter_unread_messages(): for message in self.backend.iter_unread_messages():
pass pass