def test_unknown_code(self):
     self.assertEqual((503, None),
                      http_codes.process_status_code(status_code=999,
                                                     reason=None))
     self.assertEqual((503, 'My reason'),
                      http_codes.process_status_code(status_code=999,
                                                     reason='My reason'))
Exemple #2
0
 def test_python_unsupported_code(self):
     if 429 in httplib.responses:
         self.skipTest('current python version is supported new HTTP codes')
     self.assertEqual((429, 'Too Many Requests'),
                      process_status_code(status_code=429, reason=None))
     self.assertEqual((429, 'My reason'),
                      process_status_code(status_code=429,
                                          reason='My reason'))
    def test_python_maybe_unsupported_code(self):
        self.assertEqual(
            (429, 'Too Many Requests'),
            http_codes.process_status_code(status_code=429,
                                           reason='Too Many Requests'))

        self.assertEqual((429, 'My reason'),
                         http_codes.process_status_code(status_code=429,
                                                        reason='My reason'))
Exemple #4
0
    def __init__(self, status_code, log_message=None, *args, **kwargs):
        headers = kwargs.pop('headers', {})
        for data in ('text', 'xml', 'json'):
            setattr(self, data, kwargs.pop(data, None))

        status_code, kwargs['reason'] = process_status_code(status_code, kwargs.get('reason'))
        super(HTTPError, self).__init__(status_code, log_message, *args, **kwargs)
        self.headers = headers
Exemple #5
0
    def __init__(self, status_code, log_message=None, *args, **kwargs):
        headers = kwargs.pop('headers', {})
        for data in ('text', 'xml', 'json'):
            setattr(self, data, kwargs.pop(data, None))

        status_code, kwargs['reason'] = process_status_code(status_code, kwargs.get('reason'))
        super(HTTPError, self).__init__(status_code, log_message, *args, **kwargs)
        self.headers = headers
 def test_python_supported_code(self):
     self.assertEqual((404, None),
                      http_codes.process_status_code(status_code=404))
     self.assertEqual((404, 'My reason'),
                      http_codes.process_status_code(status_code=404,
                                                     reason='My reason'))
Exemple #7
0
 def set_status(self, status_code, reason=None):
     status_code, reason = process_status_code(status_code, reason)
     super(BaseHandler, self).set_status(status_code, reason=reason)
 def test_python_supported_code(self):
     self.assertEqual((404, None), process_status_code(status_code=404, reason=None))
     self.assertEqual((404, 'My reason'), process_status_code(status_code=404, reason='My reason'))
 def test_unknown_code(self):
     self.assertEqual((503, None), process_status_code(status_code=999, reason=None))
     self.assertEqual((503, None), process_status_code(status_code=999, reason='My reason'))
 def test_python_unsupported_code(self):
     if 429 in httplib.responses:
         self.skipTest('current python version is supported new HTTP codes')
     self.assertEqual((429, 'Too Many Requests'), process_status_code(status_code=429, reason=None))
     self.assertEqual((429, 'My reason'), process_status_code(status_code=429, reason='My reason'))
Exemple #11
0
 def set_status(self, status_code, reason=None):
     status_code, reason = process_status_code(status_code, reason)
     super(BaseHandler, self).set_status(status_code, reason=reason)