コード例 #1
0
 def test_no_return_args(self):
     st = stub("/hello").and_return()
     resp_partial = RequestCollection.find(st.request)
     resp = resp_partial(st.request)
     self.assertEqual(resp.body, b'')
コード例 #2
0
 def test_set_response_code_in_stub(self):
     st = stub("/hello").and_return(code=418)
     resp_partial = RequestCollection.find(st.request)
     resp = resp_partial(st.request)
     self.assertEqual(resp.code, 418)
コード例 #3
0
 def test_stub_with_method(self):
     st = stub("/hello", method="POST").and_return(body=b"anything")
     resp_partial = RequestCollection.find(st.request)
     self.assertNotEqual(resp_partial, None)
コード例 #4
0
 def test_return_with_body_json(self):
     st = stub("/hello").and_return(body_json={'name': 'somebody'})
     resp_partial = RequestCollection.find(st.request)
     resp = resp_partial(st.request)
     self.assertEqual(
         json.loads(resp.body.decode()).get('name'), 'somebody')
コード例 #5
0
 def test_set_response_code_in_stub(self):
     st = stub("/hello").and_return(code=418)
     resp_partial = RequestCollection.find(st.request)
     resp = resp_partial(st.request)
     self.assertEqual(resp.code, 418)
コード例 #6
0
 def test_stub_no_return_doesnt_add_to_collection(self):
     st = stub("/hello")
     self.assertNotEqual(st.request, None)
     resp_partial = RequestCollection.find(st.request)
     self.assertEqual(resp_partial, None)
コード例 #7
0
 def test_return_with_body_json(self):
     st = stub("/hello").and_return(body_json={'name': 'somebody'})
     resp_partial = RequestCollection.find(st.request)
     resp = resp_partial(st.request)
     self.assertEqual(json.loads(resp.body).get('name'), 'somebody')
コード例 #8
0
 def test_no_return_args(self):
     st = stub("/hello").and_return()
     resp_partial = RequestCollection.find(st.request)
     resp = resp_partial(st.request)
     self.assertEqual(resp.body, '') 
コード例 #9
0
 def test_stub_with_method(self):
     st = stub("/hello", method="POST").and_return(body="anything")
     resp_partial = RequestCollection.find(st.request)
     self.assertNotEqual(resp_partial, None)
コード例 #10
0
 def test_stub_no_return_doesnt_add_to_collection(self):
     st = stub("/hello")
     self.assertNotEqual(st.request, None)
     resp_partial = RequestCollection.find(st.request)
     self.assertEqual(resp_partial, None)
コード例 #11
0
 def test_no_body(self):
     st = stub("/hello").and_return(body=None)
     resp_partial = RequestCollection.find(st.request)
     resp = resp_partial(st.request, 200)
     self.assertEqual(resp.body, '') 
コード例 #12
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)
コード例 #13
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)