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


Python DownloadReport.headers方法代码示例

本文整理汇总了Python中nectar.report.DownloadReport.headers方法的典型用法代码示例。如果您正苦于以下问题:Python DownloadReport.headers方法的具体用法?Python DownloadReport.headers怎么用?Python DownloadReport.headers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nectar.report.DownloadReport的用法示例。


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

示例1: test_get_single_path_failure

# 需要导入模块: from nectar.report import DownloadReport [as 别名]
# 或者: from nectar.report.DownloadReport import headers [as 别名]
    def test_get_single_path_failure(self, mock_download_one):
        report = DownloadReport('http://pulpproject.org/v1/repositories/pulp/crane/images',
                                StringIO(''))
        report.headers = {}
        report.state = report.DOWNLOAD_FAILED
        mock_download_one.return_value = report

        self.assertRaises(IOError, self.repo._get_single_path, '/v1/repositories/pulp/crane/images')
开发者ID:TomasTomecek,项目名称:pulp_docker,代码行数:10,代码来源:test_registry.py

示例2: download_one

# 需要导入模块: from nectar.report import DownloadReport [as 别名]
# 或者: from nectar.report.DownloadReport import headers [as 别名]
 def download_one(request):
     """
     Mock the download_one() method.
     """
     self.assertEqual(request.url, 'https://registry.example.com/some/path')
     self.assertEqual(type(request.destination), type(StringIO()))
     report = DownloadReport(request.url, request.destination)
     report.download_succeeded()
     report.headers = {'some': 'cool stuff'}
     report.destination.write("This is the stuff you've been waiting for.")
     return report
开发者ID:shubham90,项目名称:pulp_docker,代码行数:13,代码来源:test_registry.py

示例3: test_get_tags

# 需要导入模块: from nectar.report import DownloadReport [as 别名]
# 或者: from nectar.report.DownloadReport import headers [as 别名]
    def test_get_tags(self, mock_download_one):
        body = json.dumps({'latest': 'abc123'})
        report = DownloadReport('http://pulpproject.org/v1/repositories/pulp/crane/tags',
                                StringIO(body))
        report.headers = {}
        mock_download_one.return_value = report

        ret = self.repo._get_single_path('/v1/repositories/pulp/crane/tags')

        self.assertEqual(ret, {'latest': 'abc123'})
        self.assertEqual(mock_download_one.call_count, 1)
        self.assertTrue(isinstance(mock_download_one.call_args[0][0], DownloadRequest))
        req = mock_download_one.call_args[0][0]
        self.assertEqual(req.url, 'http://pulpproject.org/v1/repositories/pulp/crane/tags')
开发者ID:TomasTomecek,项目名称:pulp_docker,代码行数:16,代码来源:test_registry.py

示例4: test_get_with_headers

# 需要导入模块: from nectar.report import DownloadReport [as 别名]
# 或者: from nectar.report.DownloadReport import headers [as 别名]
    def test_get_with_headers(self, mock_download_one):
        body = json.dumps(['abc123'])
        report = DownloadReport('http://pulpproject.org/v1/repositories/pulp/crane/images',
                                StringIO(body))
        report.headers = {
            self.repo.DOCKER_TOKEN_HEADER: 'token',
            self.repo.DOCKER_ENDPOINT_HEADER: 'endpoint',
        }
        mock_download_one.return_value = report

        self.repo._get_single_path('/v1/repositories/pulp/crane/images')

        self.assertEqual(self.repo.token, 'token')
        self.assertEqual(self.repo.endpoint, 'endpoint')
开发者ID:TomasTomecek,项目名称:pulp_docker,代码行数:16,代码来源:test_registry.py

示例5: test_get_images

# 需要导入模块: from nectar.report import DownloadReport [as 别名]
# 或者: from nectar.report.DownloadReport import headers [as 别名]
    def test_get_images(self, mock_download_one):
        body = json.dumps(['abc123'])
        report = DownloadReport('http://pulpproject.org/v1/repositories/pulp/crane/images',
                                StringIO(body))
        report.headers = {}
        mock_download_one.return_value = report

        ret = self.repo._get_single_path('/v1/repositories/pulp/crane/images')

        self.assertEqual(ret, ['abc123'])
        self.assertEqual(mock_download_one.call_count, 1)
        self.assertTrue(isinstance(mock_download_one.call_args[0][0], DownloadRequest))
        req = mock_download_one.call_args[0][0]
        self.assertEqual(req.url, 'http://pulpproject.org/v1/repositories/pulp/crane/images')
        # make sure this header is set, which is required by the docker API in order
        # to give us an auth token
        self.assertEqual(req.headers[self.repo.DOCKER_TOKEN_HEADER], 'true')
开发者ID:TomasTomecek,项目名称:pulp_docker,代码行数:19,代码来源:test_registry.py

示例6: test_on_succeeded_pulp_requested

# 需要导入模块: from nectar.report import DownloadReport [as 别名]
# 或者: from nectar.report.DownloadReport import headers [as 别名]
    def test_on_succeeded_pulp_requested(self, _insert_deferred):
        entry = Mock(url='url-a')
        request = Mock(uri='http://content-world.com/content/bear.rpm')
        request.getHeader.side_effect = {
            constants.PULP_STREAM_REQUEST_HEADER: True
        }.__getitem__
        report = DownloadReport('', '')
        report.headers = {
            'A': 1,
            'B': 2,
        }

        # test
        streamer = Streamer(Mock())
        streamer._on_succeeded(entry, request, report)

        # validation
        self.assertFalse(_insert_deferred.called)
开发者ID:release-engineering,项目名称:pulp,代码行数:20,代码来源:test_server.py

示例7: test_get_tags_from_endpoint

# 需要导入模块: from nectar.report import DownloadReport [as 别名]
# 或者: from nectar.report.DownloadReport import headers [as 别名]
    def test_get_tags_from_endpoint(self, mock_download_one):
        body = json.dumps({'latest': 'abc123'})
        report = DownloadReport('http://some-endpoint.org/v1/repositories/pulp/crane/tags',
                                StringIO(body))
        report.headers = {}
        mock_download_one.return_value = report
        self.repo.endpoint = 'some-endpoint.org'
        # this lets us test that auth was added to the request
        self.repo.token = 'letmein'

        ret = self.repo._get_single_path('/v1/repositories/pulp/crane/tags')

        self.assertEqual(ret, {'latest': 'abc123'})
        self.assertEqual(mock_download_one.call_count, 1)
        self.assertTrue(isinstance(mock_download_one.call_args[0][0], DownloadRequest))
        req = mock_download_one.call_args[0][0]
        self.assertEqual(req.url, 'http://some-endpoint.org/v1/repositories/pulp/crane/tags')
        # make sure the authorization was added, which is usually required by an endpoint
        self.assertTrue('Authorization' in req.headers)
开发者ID:TomasTomecek,项目名称:pulp_docker,代码行数:21,代码来源:test_registry.py

示例8: test_download_headers

# 需要导入模块: from nectar.report import DownloadReport [as 别名]
# 或者: from nectar.report.DownloadReport import headers [as 别名]
    def test_download_headers(self):
        request = Mock(
            uri='http://content-world.com/content/bear.rpm',
            headers={})
        request.setHeader.side_effect = request.headers.__setitem__
        report = DownloadReport('', '')
        report.headers = {
            'A': 1,
            'B': 2,
        }

        # should be ignored.
        report.headers.update({k: '' for k in HOP_BY_HOP_HEADERS})

        config = Mock(properties={
            'streamer': {
                'cache_timeout': 100
            }
        })

        def get(s, p):
            return config.properties[s][p]

        config.get.side_effect = get
        streamer = Mock(config=config)

        # test
        listener = DownloadListener(streamer, request)
        listener.download_headers(report)

        # validation
        self.assertEqual(
            request.headers,
            {
                'Cache-Control': 'public, s-maxage=100, max-age=100',
                'A': 1,
                'B': 2,
            })
开发者ID:release-engineering,项目名称:pulp,代码行数:40,代码来源:test_server.py


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