示例#1
0
文件: test_server.py 项目: ulif/pulp
    def test_download_failed(self):
        report = DownloadReport('', '')
        report.error_report['response_code'] = 1234

        # test
        listener = DownloadListener(None, None)
        listener.download_failed(report)
示例#2
0
文件: test_server.py 项目: W3SS/pulp
    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,
        })
示例#3
0
    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,
            })
示例#4
0
文件: test_server.py 项目: ulif/pulp
    def test_download_failed_not_code(self):
        report = DownloadReport('', '')

        # test
        listener = DownloadListener(None, None)
        listener.download_failed(report)