def test_request_string_response(self): predefined_response = StringResponse({'Foo': 'Bar', 'Status': 200}, {}) client = MockClient(responses=[ predefined_response, ]) url = '/some/url' response = client.get(url) self.assertEqual(response.content, '{}') self.assertEqual(response.status_code, 200) self.assertEqual(response['Foo'], 'Bar') self.assertEqual(response.request.uri, url)
def test_request_string_response(self): predefined_response = StringResponse( {'Foo': 'Bar', 'Status': 200}, {} ) client = MockClient(responses=[predefined_response,]) url = '/some/url' response = client.get(url) self.assertEqual(response.content, '{}') self.assertEqual(response.status_code, 200) self.assertEqual(response['Foo'], 'Bar') self.assertEqual(response.request.uri, url)
def test_request_mock_response(self): obj = {} predefined_response = MockResponse({'Foo': 'Bar', 'Status': 200}, obj) client = MockClient(responses=[ predefined_response, ]) url = '/some/url' response = client.get(url) self.assertEqual(response.content, obj) self.assertEqual(response.status_code, 200) self.assertEqual(response['Foo'], 'Bar') self.assertEqual(response.request.uri, url)
def test_request_file_response(self): predefined_response = FileResponse( {'Foo': 'Bar', 'Content-Type': 'text/python', 'Status': 200}, '%s' % __file__ ) client = MockClient(responses=[predefined_response,]) url = '/some/url' response = client.get(url) self.assertTrue(self.__class__.__name__ in response.content) self.assertEqual(response.status_code, 200) self.assertEqual(response['Content-Type'], 'text/python') self.assertEqual(response['Foo'], 'Bar') self.assertEqual(response.request.uri, url)
def test_request_mock_response(self): obj = {} predefined_response = MockResponse( {'Foo': 'Bar', 'Status': 200}, obj ) client = MockClient(responses=[predefined_response,]) url = '/some/url' response = client.get(url) self.assertEqual(response.content, obj) self.assertEqual(response.status_code, 200) self.assertEqual(response['Foo'], 'Bar') self.assertEqual(response.request.uri, url)
def test_request_file_response(self): predefined_response = FileResponse( { 'Foo': 'Bar', 'Content-Type': 'text/python', 'Status': 200 }, '%s' % __file__) client = MockClient(responses=[ predefined_response, ]) url = '/some/url' response = client.get(url) self.assertTrue(self.__class__.__name__ in response.content) self.assertEqual(response.status_code, 200) self.assertEqual(response['Content-Type'], 'text/python') self.assertEqual(response['Foo'], 'Bar') self.assertEqual(response.request.uri, url)