pastebin: Convert to browser2, fix some little things

Stop testing public posts, this has been failing for a long time.
Retrieve the date, though it isn't in the capability yet.
Move most of the code in browser.py now that it is cleaner and simpler.

Some more improvements should be coming, but it is already in a much
better state than it was.
This commit is contained in:
Laurent Bachelier 2014-06-17 00:45:59 +02:00
commit 3010ae7a70
5 changed files with 131 additions and 194 deletions

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright(C) 2011 Laurent Bachelier
# Copyright(C) 2011-2014 Laurent Bachelier
#
# This file is part of weboob.
#
@ -17,9 +17,9 @@
# 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
from weboob.capabilities.base import NotLoaded
from weboob.capabilities.paste import PasteNotFound
from weboob.tools.test import BackendTest
class PastebinTest(BackendTest):
@ -34,6 +34,7 @@ class PastebinTest(BackendTest):
assert p.page_url == 'http://pastebin.com/7HmXwzyt'
assert p.contents == u'prout'
assert p.public is True
assert p._date.year == 2011
# raw method
p = self.backend.get_paste(_id)
@ -44,13 +45,16 @@ class PastebinTest(BackendTest):
assert p.public is NotLoaded
def test_post(self):
p = self.backend.new_paste(None, title=u'ouiboube', contents=u'Weboob Test', public=True)
# we cannot test public pastes, as the website sometimes forces them as private
# there seems to be a very low post per day limit, even when logged in
p = self.backend.new_paste(None, title=u'ouiboube', contents=u'Weboob Test', public=False)
self.backend.post_paste(p, max_age=600)
assert p.id
assert not p.id.startswith('http://')
self.backend.fill_paste(p, ['title'])
assert p.title == u'ouiboube'
assert p.id in p.page_url
assert p.public is True
assert p.public is False
def test_specialchars(self):
# post a paste and get the contents through the HTML response