Example #1
0
    def test_auto_error(self):
        resource = ResourceTestClass(self.fake_request(method='post'))
        self.check_ajax_error(resource.auto_error('some.error.code', 'error text'), 'some.error.code', content_type='application/json', encoding='utf-8')

        resource = ResourceTestClass(self.fake_request(method='get'))
        self.check_ajax_error(resource.auto_error('some.error.code', 'error text', response_type='json'), 'some.error.code', content_type='application/json', encoding='utf-8')

        resource = ResourceTestClass(self.fake_request(method='get', ajax=True))
        self.check_ajax_error(resource.auto_error('some.error.code', 'error text', response_type='json'), 'some.error.code', content_type='application/json', encoding='utf-8')