def test_download_failed(self): report = DownloadReport('', '') report.error_report['response_code'] = 1234 # test listener = DownloadListener(None, None) listener.download_failed(report)
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, })
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, })
def test_download_failed_not_code(self): report = DownloadReport('', '') # test listener = DownloadListener(None, None) listener.download_failed(report)