示例#1
0
 def test_creates_client_cert_required_response(self):
     response_object1 = ResponseFactory.create('url',
                                               '60',
                                               meta='',
                                               raw_body=b'')
     response_object2 = ResponseFactory.create('url',
                                               '61',
                                               meta='',
                                               raw_body=b'')
     self.assertIsInstance(response_object1, ClientCertRequiredResponse)
     self.assertIsInstance(response_object2, ClientCertRequiredResponse)
示例#2
0
 def test_creates_temp_failure_response(self):
     response_object1 = ResponseFactory.create('url',
                                               '40',
                                               meta='',
                                               raw_body=b'')
     response_object2 = ResponseFactory.create('url',
                                               '44',
                                               meta='',
                                               raw_body=b'')
     self.assertIsInstance(response_object1, TempFailureResponse)
     self.assertIsInstance(response_object2, TempFailureResponse)
示例#3
0
 def test_creates_perm_failure_response(self):
     response_object1 = ResponseFactory.create('url',
                                               '50',
                                               meta='',
                                               raw_body=b'')
     response_object2 = ResponseFactory.create('url',
                                               '57',
                                               meta='',
                                               raw_body=b'')
     self.assertIsInstance(response_object1, PermFailureResponse)
     self.assertIsInstance(response_object2, PermFailureResponse)
示例#4
0
 def test_creates_input_response(self):
     response_object1 = ResponseFactory.create('url',
                                               '10',
                                               meta='Some input',
                                               raw_body=b'')
     response_object2 = ResponseFactory.create('url',
                                               '11',
                                               meta='',
                                               raw_body=b'')
     self.assertIsInstance(response_object1, InputResponse)
     self.assertIsInstance(response_object2, InputResponse)
示例#5
0
 def test_creates_redirect_response(self):
     response_object1 = ResponseFactory.create('url',
                                               '30',
                                               meta='',
                                               raw_body=b'')
     response_object2 = ResponseFactory.create('url',
                                               '31',
                                               meta='',
                                               raw_body=b'')
     self.assertIsInstance(response_object1, RedirectResponse)
     self.assertIsInstance(response_object2, RedirectResponse)
示例#6
0
 def setUp(self):
     self.response = ResponseFactory.create(
         'gemini://test.com/',
         RESPONSE_STATUSDETAIL_TEMP_FAILURE,
         meta=
         'The server had trouble processing your response. Please try again.'
     )
示例#7
0
 def setUp(self):
     self.response = ResponseFactory.create(
         'gemini://test.com/',
         RESPONSE_STATUSDETAIL_CLIENTCERT_REQUIRED,
         meta='Please create a client certificate for this request.',
         certificate='dummy cert object',
     )
示例#8
0
 def setUp(self):
     self.response = ResponseFactory.create(
         'gemini://test.com/',
         RESPONSE_STATUSDETAIL_PERM_FAILURE,
         meta='There was a permanent error on this page.',
         certificate='dummy cert object',
     )
示例#9
0
 def setUp(self):
     self.response = ResponseFactory.create(
         'gemini://test.com/',
         RESPONSE_STATUSDETAIL_REDIRECT_TEMPORARY,
         meta='gemini://test-new.com/',
         certificate='dummy cert object',
     )
示例#10
0
 def setUp(self):
     self.response = ResponseFactory.create(
         'gemini://test.com/',
         RESPONSE_STATUSDETAIL_INPUT,
         meta='Enter a username',
         certificate='dummy cert object',
     )
示例#11
0
 def setUp(self):
     self.response = ResponseFactory.create(
         'gemini://test.com/',
         RESPONSE_STATUSDETAIL_SUCCESS,
         meta='text/gemini; charset=utf-8',
         raw_body=b"This is a sample body\r\n\r\nHello",
         certificate='dummy cert object',
     )
示例#12
0
 def test_creates_error_response(self):
     response_object1 = ResponseFactory.create('url',
                                               '01',
                                               meta='',
                                               raw_body=b'')
     response_object2 = ResponseFactory.create('url',
                                               '08',
                                               meta='',
                                               raw_body=b'')
     response_object3 = ResponseFactory.create('url',
                                               '99',
                                               meta='',
                                               raw_body=b'')
     response_object4 = ResponseFactory.create('url',
                                               'ab',
                                               meta='',
                                               raw_body=b'')
     self.assertIsInstance(response_object1, ErrorResponse)
     self.assertIsInstance(response_object2, ErrorResponse)
     self.assertIsInstance(response_object3, ErrorResponse)
     self.assertIsInstance(response_object4, ErrorResponse)
示例#13
0
 def test_creates_success_response(self):
     response_object = ResponseFactory.create('url',
                                              '20',
                                              meta='text/gemini',
                                              raw_body=b'Some body')
     self.assertIsInstance(response_object, SuccessResponse)
示例#14
0
 def setUp(self):
     self.response = ResponseFactory.create('gemini://test.com/',
                                            '99',
                                            meta='THIS IS A BAD RESPONSE')
示例#15
0
 def setUp(self):
     self.response = ResponseFactory.create(
         'gemini://test.com/',
         RESPONSE_STATUSDETAIL_ERROR_DNS,
         meta='Could not find a host at test.com.')
示例#16
0
 def setUp(self):
     self.response = ResponseFactory.create('gemini://test.com/',
                                            RESPONSE_STATUSDETAIL_INPUT,
                                            meta='Enter a username')