CapPaste: check the contents in can_post
For pastealacon, it is used to check for encoding compatibility.
This commit is contained in:
parent
56fe4448d3
commit
0d2148bd84
6 changed files with 32 additions and 22 deletions
|
|
@ -63,7 +63,7 @@ class PastebinBackend(BaseBackend, BasePasteBackend):
|
|||
def new_paste(self, *args, **kwargs):
|
||||
return PastebinPaste(*args, **kwargs)
|
||||
|
||||
def can_post(self, public=None, max_age=None):
|
||||
def can_post(self, contents, public=None, max_age=None):
|
||||
if max_age is not None:
|
||||
if self.get_closest_expiration(max_age) is None:
|
||||
return 0
|
||||
|
|
|
|||
|
|
@ -79,12 +79,14 @@ class PastebinTest(BackendTest):
|
|||
assert self.backend.get_paste('http://pastealacon.com/1') is None
|
||||
|
||||
def test_can_post(self):
|
||||
assert self.backend.can_post(public=None) > 0
|
||||
assert self.backend.can_post(public=True) > 0
|
||||
assert self.backend.can_post(public=False) > 0
|
||||
assert self.backend.can_post(public=True, max_age=600) > 0
|
||||
assert self.backend.can_post(public=True, max_age=3600*24) > 0
|
||||
assert self.backend.can_post(public=True, max_age=3600*24*3) > 0
|
||||
assert self.backend.can_post(public=True, max_age=False) > 0
|
||||
assert self.backend.can_post(public=None, max_age=False) > 0
|
||||
assert self.backend.can_post(public=True, max_age=3600*24*40) > 0
|
||||
assert self.backend.can_post('hello', public=None) > 0
|
||||
assert self.backend.can_post('hello', public=True) > 0
|
||||
assert self.backend.can_post('hello', public=False) > 0
|
||||
assert self.backend.can_post('hello', public=True, max_age=600) > 0
|
||||
assert self.backend.can_post('hello', public=True, max_age=3600*24) > 0
|
||||
assert self.backend.can_post('hello', public=True, max_age=3600*24*3) > 0
|
||||
assert self.backend.can_post('hello', public=True, max_age=False) > 0
|
||||
assert self.backend.can_post('hello', public=None, max_age=False) > 0
|
||||
assert self.backend.can_post('hello', public=True, max_age=3600*24*40) > 0
|
||||
assert self.backend.can_post(u'héhé', public=True) > 0
|
||||
assert self.backend.can_post(u'hello ♥', public=True) > 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue