pastebin: Handle limit exceeded warning
And skip if found in tests
This commit is contained in:
parent
2f33157e4f
commit
b92b1227d2
2 changed files with 25 additions and 5 deletions
|
|
@ -22,9 +22,9 @@ import re
|
|||
|
||||
from weboob.capabilities.paste import BasePaste, PasteNotFound
|
||||
from weboob.tools.browser2 import HTMLPage, LoginBrowser, need_login, URL
|
||||
from weboob.tools.browser2.elements import ItemElement
|
||||
from weboob.tools.browser2.filters import Attr, Base, CleanText, DateTime, Env, Filter, FilterError, RawText
|
||||
from weboob.tools.browser2.page import method, RawPage
|
||||
from weboob.tools.browser2.elements import ItemElement
|
||||
from weboob.tools.exceptions import BrowserHTTPNotFound, BrowserIncorrectPassword, BrowserUnavailable
|
||||
|
||||
|
||||
|
|
@ -76,8 +76,8 @@ class PastePage(BasePastebinPage):
|
|||
obj_title = Base(Env('header')) & CleanText('.//div[@class="paste_box_line1"]//h1')
|
||||
obj_contents = RawText('//textarea[@id="paste_code"]')
|
||||
obj_public = Base(Env('header')) \
|
||||
& Attr('.//div[@class="paste_box_line1"]//img', 'title') \
|
||||
& CleanVisibility()
|
||||
& Attr('.//div[@class="paste_box_line1"]//img', 'title') \
|
||||
& CleanVisibility()
|
||||
obj__date = Base(Env('header')) & Attr('.//div[@class="paste_box_line2"]/span[1]', 'title') & DateTime()
|
||||
|
||||
|
||||
|
|
@ -95,6 +95,11 @@ class PostPage(BasePastebinPage):
|
|||
form.submit()
|
||||
|
||||
|
||||
class WarningPage(BasePastebinPage):
|
||||
def __init__(self, *args, **kwargs):
|
||||
raise LimitExceeded()
|
||||
|
||||
|
||||
class UserPage(BasePastebinPage):
|
||||
pass
|
||||
|
||||
|
|
@ -103,9 +108,14 @@ class BadAPIRequest(BrowserUnavailable):
|
|||
pass
|
||||
|
||||
|
||||
class LimitExceeded(BrowserUnavailable):
|
||||
pass
|
||||
|
||||
|
||||
class PastebinBrowser(LoginBrowser):
|
||||
BASEURL = 'http://pastebin.com/'
|
||||
|
||||
warning = URL('warning\.php\?p=(?P<id>\d+)', WarningPage)
|
||||
api = URL('api/api_post\.php', RawPage)
|
||||
apilogin = URL('api/api_login\.php', RawPage)
|
||||
login = URL('login', LoginPage)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue