pastebin backend: various fixes and enhancements
* Get the contents from the HTML page, eliminating one request * Fix encoding support (everything is unicode) for all three Browser methods * Enhance test
This commit is contained in:
parent
e597ea8844
commit
51d4b87ebb
4 changed files with 44 additions and 14 deletions
|
|
@ -17,23 +17,42 @@
|
|||
# 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 .paste import PastebinPaste
|
||||
from weboob.capabilities.base import NotLoaded
|
||||
|
||||
class PastebinTest(BackendTest):
|
||||
BACKEND = 'pastebin'
|
||||
|
||||
def test_get_paste(self):
|
||||
# html method
|
||||
p = self.backend.get_paste('7HmXwzyt')
|
||||
self.backend.fillobj(p, ('title', 'contents'))
|
||||
self.backend.fillobj(p, ['title'])
|
||||
assert p.title == 'plop'
|
||||
assert p.page_url == 'http://pastebin.com/7HmXwzyt'
|
||||
assert p.contents == 'prout'
|
||||
|
||||
# raw method
|
||||
p = self.backend.get_paste('7HmXwzyt')
|
||||
self.backend.fillobj(p, ['contents'])
|
||||
assert p.title is NotLoaded
|
||||
assert p.page_url == 'http://pastebin.com/7HmXwzyt'
|
||||
assert p.contents == 'prout'
|
||||
|
||||
def test_post(self):
|
||||
p = PastebinPaste(None, title='ouiboube', contents='Weboob Test')
|
||||
self.backend.post_paste(p)
|
||||
assert p.id
|
||||
assert p.title == 'ouiboube'
|
||||
assert p.id in p.page_url
|
||||
|
||||
def test_specialchars(self):
|
||||
# post a paste and get the contents through the HTML response
|
||||
p1 = PastebinPaste(None, title='ouiboube', contents=u'Weboob <test>¿¡')
|
||||
self.backend.post_paste(p1)
|
||||
assert p1.id
|
||||
|
||||
# this should use the raw method to get the contents
|
||||
p2 = self.backend.get_paste(p1.id)
|
||||
self.backend.fillobj(p2, ['contents'])
|
||||
assert p2.contents == p1.contents
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue