コード例 #1
0
    def test_post_and_get_are_different(self):
        req = HTTPRequest("/hello")
        resp_partial = functools.partial(HTTPResponse,
                buffer=StringIO("response value"))
        RequestCollection.add(req, resp_partial)

        AsyncHTTPStubClient().fetch("/hello", self.stop, method="POST")
        response = self.wait()
        self.assertEqual(response.code, 404)
コード例 #2
0
    def test_post_and_get_are_different(self):
        req = HTTPRequest("/hello")
        resp_partial = functools.partial(HTTPResponse,
                                         buffer=StringIO("response value"))
        RequestCollection.add(req, resp_partial)

        AsyncHTTPStubClient().fetch("/hello", self.stop, method="POST")
        response = self.wait()
        self.assertEqual(response.code, 404)
コード例 #3
0
 def test_fetch_string_converts_to_request_object(self):
     req = HTTPRequest("/hello")
     resp_partial = functools.partial(HTTPResponse,
             buffer=StringIO("response value"))
     RequestCollection.add(req, resp_partial)
     client = AsyncHTTPStubClient()
     client.fetch("/hello", self.stop)
     response = self.wait()
     self.assertEqual(response.code, 200)
     self.assertEqual(response.body, "response value")
コード例 #4
0
 def test_fetch_string_converts_to_request_object(self):
     req = HTTPRequest("/hello")
     resp_partial = functools.partial(HTTPResponse,
                                      code=200,
                                      buffer=StringIO("response value"))
     RequestCollection.add(req, resp_partial)
     client = AsyncHTTPStubClient()
     client.fetch("/hello", self.stop)
     response = self.wait()
     self.assertEqual(response.code, 200)
     self.assertEqual(response.body, "response value")
コード例 #5
0
 def test_reset(self):
     req = HTTPRequest("http://www.example.com:8000/hello")
     RequestCollection.add(req, "response val")
     RequestCollection.reset()
     self.assertEqual(len(RequestCollection._requests), 0)
コード例 #6
0
 def test_remove(self):
     req = HTTPRequest("http://www.example.com:8000/hello")
     RequestCollection.add(req, "response val")
     RequestCollection.remove(req)
     val = RequestCollection.find(req)
     self.assertEqual(val, None)
コード例 #7
0
 def test_add_with_absolute_url(self):
     req = HTTPRequest("http://www.example.com:8000/hello")
     RequestCollection.add(req, "response val")
     val = RequestCollection._requests["/hello"]["GET"][0]
     self.assertEqual(val, "response val")
コード例 #8
0
 def test_add(self):
     req = HTTPRequest("/hello")
     RequestCollection.add(req, "response val")
     val = RequestCollection._requests["/hello"]["GET"][0]
     self.assertEqual(val, "response val")
コード例 #9
0
 def test_reset(self):
     req = HTTPRequest("http://www.example.com:8000/hello")
     RequestCollection.add(req, "response val")
     RequestCollection.reset()
     self.assertEqual(len(RequestCollection._requests), 0)
コード例 #10
0
 def test_remove(self):
     req = HTTPRequest("http://www.example.com:8000/hello")
     RequestCollection.add(req, "response val")
     RequestCollection.remove(req)
     val = RequestCollection.find(req)
     self.assertEqual(val, None)
コード例 #11
0
 def test_add_with_absolute_url(self):
     req = HTTPRequest("http://www.example.com:8000/hello")
     RequestCollection.add(req, "response val")
     val = RequestCollection._requests["/hello"]["GET"][0]
     self.assertEqual(val, "response val")
コード例 #12
0
 def test_add(self):
     req = HTTPRequest("/hello")
     RequestCollection.add(req, "response val")
     val = RequestCollection._requests["/hello"]["GET"][0]
     self.assertEqual(val, "response val")