Beispiel #1
0
    def test_interacts_successfully_with_istub(self):
        """
        The :obj:`IStringResponseStubs` is passed the correct parameters with
        which to evaluate the response, and the response is returned.
        """
        resource = StringStubbingResource(
            self._get_response_for((b'DELETE', 'http://what/a/thing', {
                b'page': [b'1']
            }, {
                b'x-header': [b'eh']
            }, b'datastr'), (418, {
                b'x-response': b'responseheader'
            }, b'response body')))

        stub = StubTreq(resource)

        d = stub.delete('http://what/a/thing',
                        headers={b'x-header': b'eh'},
                        params={b'page': b'1'},
                        data=b'datastr')
        resp = self.successResultOf(d)
        self.assertEqual(418, resp.code)
        self.assertEqual([b'responseheader'],
                         resp.headers.getRawHeaders(b'x-response'))
        self.assertEqual(b'response body',
                         self.successResultOf(stub.content(resp)))
Beispiel #2
0
    def test_interacts_successfully_with_istub(self):
        """
        The :obj:`IStringResponseStubs` is passed the correct parameters with
        which to evaluate the response, and the response is returned.
        """
        resource = StringStubbingResource(
            self._get_response_for(
                (b"DELETE", "http://what/a/thing", {b"page": [b"1"]}, {b"x-header": [b"eh"]}, b"datastr"),
                (418, {b"x-response": b"responseheader"}, b"response body"),
            )
        )

        stub = StubTreq(resource)

        d = stub.delete("http://what/a/thing", headers={b"x-header": b"eh"}, params={b"page": b"1"}, data=b"datastr")
        resp = self.successResultOf(d)
        self.assertEqual(418, resp.code)
        self.assertEqual([b"responseheader"], resp.headers.getRawHeaders(b"x-response"))
        self.assertEqual(b"response body", self.successResultOf(stub.content(resp)))
Beispiel #3
0
    def test_interacts_successfully_with_istub(self):
        """
        The :obj:`IStringResponseStubs` is passed the correct parameters with
        which to evaluate the response, and the response is returned.
        """
        resource = StringStubbingResource(self._get_response_for(
            ('DELETE', 'http://what/a/thing', {'page': ['1']},
             {'x-header': ['eh']}, 'datastr'),
            (418, {'x-response': 'responseheader'}, 'response body')))

        stub = StubTreq(resource)

        d = stub.delete('http://what/a/thing', headers={'x-header': 'eh'},
                        params={'page': '1'}, data='datastr')
        resp = self.successResultOf(d)
        self.assertEqual(418, resp.code)
        self.assertEqual(['responseheader'],
                         resp.headers.getRawHeaders('x-response'))
        self.assertEqual('response body',
                         self.successResultOf(stub.content(resp)))