Example #1
0
 def test_should_return_resource_from_response_with_no_json_data(
         self, from_header):
     self._response.json = Mock(side_effect=ValueError())
     returned_resource = from_response(Resource, self._response, self._auth)
     self.assertEqual(returned_resource.url, 'http://example.com')
     self.assertEqual(returned_resource.auth, self._auth)
     self.assertEqual(returned_resource.data, {})
Example #2
0
 def test_should_return_resource_from_response(self, from_header):
     self._response.json = Mock(return_value={})
     self._response.status_code = 200
     returned_resource = from_response(Resource, self._response, self._auth)
     self.assertEqual(returned_resource.url, 'http://example.com')
     self.assertEqual(returned_resource.auth, self._auth)
     self.assertEqual(returned_resource.data, {})
     self.assertEqual(returned_resource.response.status_code, 200)
Example #3
0
 def test_should_obtain_schema_from_header(self, from_header):
     self._response.json = Mock(side_effect=ValueError())
     from_response(Resource, self._response, self._auth)
     from_header.assert_called_with(self._response.headers, self._auth)