mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-18 17:00:24 +00:00
test_web test_bad_method: remove a client.getPage
Add WebErrorMixin.assertHTTPError, to replace (getPage + shouldHTTPError)
This commit is contained in:
parent
bee05e883c
commit
202a9714c4
@ -1,6 +1,8 @@
|
||||
import os, random, struct
|
||||
import treq
|
||||
from zope.interface import implementer
|
||||
from twisted.internet import defer
|
||||
from twisted.internet.defer import inlineCallbacks, returnValue
|
||||
from twisted.internet.interfaces import IPullProducer
|
||||
from twisted.python import failure
|
||||
from twisted.application import service
|
||||
@ -509,6 +511,18 @@ class WebErrorMixin:
|
||||
d.addBoth(self._shouldHTTPError, which, _validate)
|
||||
return d
|
||||
|
||||
@inlineCallbacks
|
||||
def assertHTTPError(self, url, code, response_substring,
|
||||
method="get", persistent=False,
|
||||
**args):
|
||||
response = yield treq.request(method, url, persistent=persistent,
|
||||
**args)
|
||||
body = yield response.content()
|
||||
self.assertEquals(response.code, code)
|
||||
if response_substring is not None:
|
||||
self.assertIn(response_substring, body)
|
||||
returnValue(body)
|
||||
|
||||
class ErrorMixin(WebErrorMixin):
|
||||
def explain_error(self, f):
|
||||
if f.check(defer.FirstError):
|
||||
|
@ -4437,13 +4437,12 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
|
||||
return d
|
||||
|
||||
|
||||
@inlineCallbacks
|
||||
def test_bad_method(self):
|
||||
url = self.webish_url + self.public_url + "/foo/bar.txt"
|
||||
d = self.shouldHTTPError("bad_method",
|
||||
501, "Not Implemented",
|
||||
"I don't know how to treat a BOGUS request.",
|
||||
client.getPage, url, method="BOGUS")
|
||||
return d
|
||||
yield self.assertHTTPError(url, 501,
|
||||
"I don't know how to treat a BOGUS request.",
|
||||
method="BOGUS")
|
||||
|
||||
def test_short_url(self):
|
||||
url = self.webish_url + "/uri"
|
||||
|
Loading…
x
Reference in New Issue
Block a user