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
|
|
@ -29,6 +29,9 @@ class PastePage(BasePage):
|
|||
'id("content_left")//div[@class="paste_box_info"]', 1, 'xpath')
|
||||
paste.title = self.parser.select(header,
|
||||
'//div[@class="paste_box_line1"]//h1', 1, 'xpath').text
|
||||
paste.contents = self.parser.select(self.document.getroot(),
|
||||
'//textarea[@id="paste_code"]', 1, 'xpath').text
|
||||
return paste
|
||||
|
||||
def get_id(self):
|
||||
"""
|
||||
|
|
@ -41,6 +44,6 @@ class PastePage(BasePage):
|
|||
class PostPage(BasePage):
|
||||
def post(self, paste):
|
||||
self.browser.select_form(name='myform')
|
||||
self.browser['paste_code'] = paste.contents
|
||||
self.browser['paste_name'] = paste.title
|
||||
self.browser['paste_code'] = paste.contents.encode(self.browser.ENCODING)
|
||||
self.browser['paste_name'] = paste.title.encode(self.browser.ENCODING)
|
||||
self.browser.submit()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue