def test_get_spec_raises_when_endpoint_not_found(self):
     """
     get_spec() raises UndefinedSchemaError
     """
     self.raw_schema['resources'][0]['resources'][0]['relativeUri'] = '/-'
     with self.assertRaises(UndefinedSchemaError):
         get_spec(self.parsed_data, self.raw_schema)
 def test_get_spec_raises_when_resource_not_found(self):
     """
     get_spec() raises UndefinedSchemaError
     """
     req_path_info = '/api/v5/not_test/'
     request_info = Data(
         path=req_path_info,
         method=self.method,
         request=Request(self.request_data, self.query_data),
         response=self.dummy_response,
     )
     with self.assertRaises(UndefinedSchemaError):
         get_spec(request_info, self.raw_schema)
 def test_get_spec_raises_when_method_not_found(self):
     """
     get_spec() raises UndefinedSchemaError
     """
     method = 'YAR'
     request_info = Data(
         path=self.req_path_info,
         method=method,
         request=Request(self.request_data, self.query_data),
         response=self.dummy_response,
     )
     with self.assertRaises(UndefinedSchemaError):
         get_spec(request_info, self.raw_schema)
 def test_validate_response_against_schema_raises_response_undefined(self):
     """
     validate_response_against_schema() raises UndefinedSchemaError
     """
     self.raw_schema['resources'][0]['resources'][0]\
         ['methods'][1]['responses'] = {}
     spec = get_spec(self.parsed_data, self.raw_schema)
     with self.assertRaises(UndefinedSchemaError):
         validate_response_against_schema(self.parsed_data, spec)
 def test_get_spec_found_with_extended_path(self):
     req_path_info = '/api/v5/test/fake_id:1234567890/extended'
     method = 'long'
     request_info = Data(
         path=req_path_info,
         method=method,
         request=Request(self.request_data, self.query_data),
         response=self.dummy_response,
     )
     spec = get_spec(request_info, self.raw_schema)
     self.assertEqual(spec['method'], method)
 def test_get_spec_success_without_endpoint_path(self):
     req_path_info = '/api/v5/test'
     method = 'short'
     request_info = Data(
         path=req_path_info,
         method=method,
         request=Request(self.request_data, self.query_data),
         response=self.dummy_response,
     )
     spec = get_spec(request_info, self.raw_schema)
     self.assertEqual(spec['method'], method)
 def setUp(self):
     super(RequestValidatorTestCase, self).setUp()
     self.req_path_info = '/api/v5/test/'
     self.method = 'post'
     self.request_data = {'x': 'data'}
     self.query_data = {'required_param': 'a string', 'optional_param': 1}
     self.dummy_response = Response(response_data={}, status_code=200)
     self.parsed_data = Data(
         path=self.req_path_info,
         method=self.method,
         request=Request(self.request_data, self.query_data),
         response=self.dummy_response,
     )
     self.spec = get_spec(self.parsed_data, self.raw_schema)
 def setUp(self):
     super(ResponseValidatorTestCase, self).setUp()
     self.req_path_info = '/api/v5/test/'
     self.method = 'post'
     self.dummy_request = Request(request_data={}, query_data={})
     self.response_data = {'data': {'uni': 'ΒΆ'}}
     self.status_code = 200
     self.parsed_data = Data(
         path=self.req_path_info,
         method=self.method,
         request=self.dummy_request,
         response=Response(response_data=self.response_data,
                           status_code=self.status_code),
     )
     self.spec = get_spec(self.parsed_data, self.raw_schema)