当前位置: 首页>>代码示例>>Python>>正文


Python processor.fetch_file函数代码示例

本文整理汇总了Python中sentry.lang.javascript.processor.fetch_file函数的典型用法代码示例。如果您正苦于以下问题:Python fetch_file函数的具体用法?Python fetch_file怎么用?Python fetch_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了fetch_file函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_truncated

    def test_truncated(self):
        url = truncatechars('http://example.com', 3)
        with pytest.raises(CannotFetchSource) as exc:
            fetch_file(url)

        assert exc.value.data['type'] == EventError.JS_MISSING_SOURCE
        assert exc.value.data['url'] == url
开发者ID:pythorn,项目名称:sentry,代码行数:7,代码来源:test_processor.py

示例2: test_non_unicode_release_file

    def test_non_unicode_release_file(self, mock_fetch_release_file):
        mock_fetch_release_file.return_value = (
            {'content-type': 'application/octet-stream'},
            '\xffff',  # This is some random binary data
            200
        )

        release = Release.objects.create(project=self.project, version='1')

        with pytest.raises(BadSource):
            fetch_file('/example.js', release=release)
开发者ID:alexm92,项目名称:sentry,代码行数:11,代码来源:test_processor.py

示例3: test_connection_failure

    def test_connection_failure(self):
        responses.add(responses.GET, 'http://example.com', body=RequestException())

        with pytest.raises(BadSource):
            fetch_file('http://example.com')

        assert len(responses.calls) == 1

        # ensure we use the cached domain-wide failure for the second call
        with pytest.raises(BadSource):
            fetch_file('http://example.com/foo/bar')

        assert len(responses.calls) == 1
开发者ID:pythorn,项目名称:sentry,代码行数:13,代码来源:test_processor.py

示例4: test_with_token

    def test_with_token(self):
        responses.add(
            responses.GET,
            re.compile(r'http://example.com/\d+/'),
            body='foo bar',
            content_type='application/json'
        )

        self.project.update_option('sentry:token', 'foobar')
        self.project.update_option('sentry:origins', ['*'])

        default_header_name = 'X-Sentry-Token'
        header_pairs = [
            (None, default_header_name),
            ('', default_header_name),
            ('X-Custom-Token-Header', 'X-Custom-Token-Header'),
        ]

        for i, (header_name_option_value, expected_request_header_name) in enumerate(header_pairs):
            self.project.update_option('sentry:token_header', header_name_option_value)

            url = 'http://example.com/{}/'.format(i)
            result = fetch_file(url, project=self.project)

            assert result.url == url
            assert result.body == 'foo bar'
            assert result.headers == {'content-type': 'application/json'}

            assert len(responses.calls) == i + 1
            assert responses.calls[i].request.headers[expected_request_header_name] == 'foobar'
开发者ID:binlee1990,项目名称:sentry,代码行数:30,代码来源:test_processor.py

示例5: test_simple

    def test_simple(self):
        responses.add(responses.GET, 'http://example.com', body='foo bar',
                      content_type='application/json')

        result = fetch_file('http://example.com')

        assert len(responses.calls) == 1

        assert result.url == 'http://example.com'
        assert result.body == 'foo bar'
        assert result.headers == {'content-type': 'application/json'}

        # ensure we use the cached result
        result2 = fetch_file('http://example.com')

        assert len(responses.calls) == 1

        assert result == result2
开发者ID:pythorn,项目名称:sentry,代码行数:18,代码来源:test_processor.py

示例6: test_unicode_body

    def test_unicode_body(self):
        responses.add(responses.GET, 'http://example.com',
                      body=u'"fôo bar"'.encode('utf-8'),
                      content_type='application/json; charset=utf-8')

        result = fetch_file('http://example.com')

        assert len(responses.calls) == 1

        assert result.url == 'http://example.com'
        assert result.body == u'"fôo bar"'
        assert result.headers == {'content-type': 'application/json; charset=utf-8'}

        # ensure we use the cached result
        result2 = fetch_file('http://example.com')

        assert len(responses.calls) == 1

        assert result == result2
开发者ID:alexm92,项目名称:sentry,代码行数:19,代码来源:test_processor.py

示例7: test_non_url_with_release

    def test_non_url_with_release(self, mock_fetch_release_file):
        mock_fetch_release_file.return_value = (
            {'content-type': 'application/json'},
            'foo',
            200
        )

        release = Release.objects.create(project=self.project, version='1')

        result = fetch_file('/example.js', release=release)
        assert result.url == '/example.js'
        assert result.body == 'foo'
        assert result.headers == {'content-type': 'application/json'}
开发者ID:jasonbeverage,项目名称:sentry,代码行数:13,代码来源:test_processor.py

示例8: test_with_token

    def test_with_token(self):
        responses.add(responses.GET, 'http://example.com', body='foo bar',
                      content_type='application/json')

        self.project.update_option('sentry:token', 'foobar')
        self.project.update_option('sentry:origins', ['*'])

        result = fetch_file('http://example.com', project=self.project)

        assert len(responses.calls) == 1
        assert responses.calls[0].request.headers['X-Sentry-Token'] == 'foobar'

        assert result.url == 'http://example.com'
        assert result.body == 'foo bar'
        assert result.headers == {'content-type': 'application/json'}
开发者ID:pythorn,项目名称:sentry,代码行数:15,代码来源:test_processor.py

示例9: test_non_url_with_release

    def test_non_url_with_release(self, mock_fetch_release_file):
        mock_fetch_release_file.return_value = http.UrlResult(
            '/example.js',
            {'content-type': 'application/json'},
            'foo',
            200,
            None,
        )

        release = Release.objects.create(version='1', organization_id=self.project.organization_id)
        release.add_project(self.project)

        result = fetch_file('/example.js', release=release)
        assert result.url == '/example.js'
        assert result.body == 'foo'
        assert isinstance(result.body, six.binary_type)
        assert result.headers == {'content-type': 'application/json'}
        assert result.encoding is None
开发者ID:binlee1990,项目名称:sentry,代码行数:18,代码来源:test_processor.py

示例10: test_non_url_without_release

 def test_non_url_without_release(self):
     with pytest.raises(BadSource):
         fetch_file('/example.js')
开发者ID:pythorn,项目名称:sentry,代码行数:3,代码来源:test_processor.py


注:本文中的sentry.lang.javascript.processor.fetch_file函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。