コード例 #1
0
ファイル: test_requestor.py プロジェクト: tylderen/fulmar
    def test_http_status_555(self, requestor):
        task = copy.deepcopy(self.default_task)
        task['url'] = task['url'] + '/status/555'
        result = requestor.sync_request(task)
        response = rebuild_response(result)

        assert response.status_code == 555
コード例 #2
0
ファイル: test_requestor.py プロジェクト: tylderen/fulmar
    def test_fake_request(self, requestor):
        task = copy.deepcopy(self.default_task)
        task['url'] = 'first_task: test_project'
        result = requestor.sync_request(task)
        response = rebuild_response(result)

        assert response.json == None
コード例 #3
0
ファイル: test_requestor.py プロジェクト: tylderen/fulmar
    def test_http_max_redirect(self, requestor):
        task = copy.deepcopy(self.default_task)
        task['url'] = task['url'] + '/redirect/4'
        task['fetch']['max_redirects'] = 3

        result = requestor.sync_request(task)
        response = rebuild_response(result)

        assert response.error == 'HTTP 599: Maximum (3) redirects followed'

        task = copy.deepcopy(self.default_task)
        task['url'] = task['url'] + '/redirect/4'
        task['fetch']['max_redirects'] = 5

        result = requestor.sync_request(task)
        response = rebuild_response(result)

        assert response.status_code == 200
コード例 #4
0
ファイル: test_requestor.py プロジェクト: tylderen/fulmar
    def test_http_no_redirect(self, requestor):
        task = copy.deepcopy(self.default_task)
        task['url'] = task['url'] + '/redirect/4'
        task['fetch']['allow_redirects'] = False

        result = requestor.sync_request(task)
        response = rebuild_response(result)

        assert response.error == 'HTTP 302: FOUND'
コード例 #5
0
ファイル: test_requestor.py プロジェクト: tylderen/fulmar
    def test_http_proxy_auth_failed(self, requestor):
        task = copy.deepcopy(self.default_task)
        task['url'] = task['url'] + '/get'
        task['fetch']['proxy_host'] = self.proxy_host
        task['fetch']['proxy_port'] = self.proxy_port

        result = requestor.sync_request(task)
        response = rebuild_response(result)

        assert response.status_code == 403
コード例 #6
0
ファイル: test_requestor.py プロジェクト: tylderen/fulmar
    def test__phantomjs_url(self, requestor):
        task = copy.deepcopy(self.default_task)
        task['url'] = task['url'] + '/status/200'
        task['fetch']['fetch_type'] = 'js'

        result = requestor.sync_request(task)
        response = rebuild_response(result)

        assert response.status_code == 200
        assert response.error == None
        assert response.isok() == True
        assert response.js_script_result == None
コード例 #7
0
ファイル: test_requestor.py プロジェクト: tylderen/fulmar
    def test_http_post(self, requestor):
        task = copy.deepcopy(self.default_task)
        task['url'] = task['url'] + '/post'
        task['fetch']['method'] = 'POST'
        task['fetch']['data'] = 'Hello World'
        task['fetch']['cookies'] = {'c': 'd'}
        result = requestor.sync_request(task)
        response = rebuild_response(result)

        assert response.status_code == 200
        assert response.orig_url == task['url']
        assert response.json['form']['Hello World'] == ''
        assert response.json['headers'].get('A') == 'b'
コード例 #8
0
ファイル: test_requestor.py プロジェクト: tylderen/fulmar
    def test_http_timeout(self, requestor):
        task = copy.deepcopy(self.default_task)
        task['url'] = task['url'] + '/delay/4'
        task['fetch']['timeout'] = 2
        start_time = time.time()
        result = requestor.sync_request(task)
        end_time = time.time()
        response = rebuild_response(result)
        time_cost = end_time - start_time

        assert time_cost >= 2
        assert time_cost < 3
        assert response.content == ''
        assert response.status_code == 599
        assert 'HTTP 599: Operation timed out' in response.error
コード例 #9
0
ファイル: test_requestor.py プロジェクト: tylderen/fulmar
    def test_http_get(self, requestor):
        task = copy.deepcopy(self.default_task)
        task['url'] = task['url'] + '/get'
        result = requestor.sync_request(task)
        response = rebuild_response(result)

        assert response.ok == True
        assert response.status_code == 200
        assert response.url == task['url']
        assert hasattr(response, 'headers')
        assert len(response.content) > 0
        assert isinstance(response.time_cost, (int, float))
        assert response.cookies == {'c': 'd'}
        assert response.json['headers']['A'] == 'b'
        assert response.json['headers']['Cookie'] == 'a=b'