Exemplo n.º 1
0
 def response_callback(request):
     request.prepare_for_send()
     self.assertTrue(request.url_info.url.endswith('robots.txt'))
     response = Response(500, 'Oops')
     response.request = request
     checker.web_client.session_obj.done_value = True
     return response
Exemplo n.º 2
0
 def response_callback(request):
     request.prepare_for_send()
     self.assertTrue(request.url_info.url.endswith('robots.txt'))
     response = Response(200, 'OK')
     response.request = request
     response.body = io.StringIO('User-agent:*\nDisallow: /\n')
     checker.web_client.session_obj.done_value = True
     return response
Exemplo n.º 3
0
        def response_callback_3(request):
            request.prepare_for_send()
            self.assertEqual('http://www.example.net/robots.txt',
                             request.url_info.url)

            response = Response(200, 'OK')
            response.request = request
            response.body = io.StringIO('User-agent:*\nAllow: /\n')

            checker.web_client.session_obj.done_value = True
            return response
Exemplo n.º 4
0
        def response_callback(request):
            request.prepare_for_send()
            self.assertTrue(request.url_info.url.endswith('robots.txt'))
            response = Response(302, 'See else')
            response.request = request
            response.fields['Location'] = '/robots.txt'

            nonlocal_dict['counter'] += 1

            if nonlocal_dict['counter'] > 20:
                raise ProtocolError('Mock redirect loop error.')

            return response
Exemplo n.º 5
0
        def response_callback_2(request):
            request.prepare_for_send()
            self.assertEqual('http://www.example.com/robots.txt',
                             request.url_info.url)

            response = Response(301, 'Moved')
            response.fields['location'] = 'http://www.example.net/robots.txt'
            response.request = request

            checker.web_client.mock_response_callback = response_callback_3
            checker.web_client.request = Request(
                'http://www.example.net/robots.txt')

            return response