Пример #1
0
 def test_handle_unsupported(self):
     for method in ('GET', 'POST', 'PUT', 'DELELTE', 'OPTIONS', 'HEAD'):
         view = MockRestView(request=MockRequest(method))
         responsedata = view.handle()
         errormsg = 'Method Not Allowed: {0}'.format(method)
         self.assertEquals(view.response.status, (405, errormsg))
         self.assertEquals(responsedata, {'error': errormsg})
Пример #2
0
 def test_response_400_bad_request(self):
     view = MockRestView(request=MockRequest('GET'))
     data = {'hello': 'world'}
     self.assertEquals(view.response_400_bad_request({'hello': 'world'}),
                       data)
     self.assertEquals(view.response.status, (400, 'Bad Request'))
Пример #3
0
 def test_response_405_method_not_allowed(self):
     view = MockRestView(request=MockRequest('GET'))
     self.assertEquals(view.response_405_method_not_allowed(),
                       {'error': 'Method Not Allowed: GET'})
     self.assertEquals(view.response.status, (405, 'Method Not Allowed: GET'))