def _missing_header_helper(self, **kwargs):
        response = mock.Mock(headers={}, spec=[u"headers"])
        with pytest.raises(common.InvalidResponse) as exc_info:
            _download.get_range_info(response, _get_headers, **kwargs)

        error = exc_info.value
        assert error.response is response
        assert len(error.args) == 2
        assert error.args[1] == u"content-range"
    def _failure_helper(self, **kwargs):
        content_range = u"nope x-6/y"
        response = self._make_response(content_range)
        with pytest.raises(common.InvalidResponse) as exc_info:
            _download.get_range_info(response, _get_headers, **kwargs)

        error = exc_info.value
        assert error.response is response
        assert len(error.args) == 3
        assert error.args[1] == content_range
Ejemplo n.º 3
0
 def _success_helper(self, **kwargs):
     content_range = u'Bytes 7-11/42'
     response = self._make_response(content_range)
     start_byte, end_byte, total_bytes = _download.get_range_info(
         response, _get_headers, **kwargs)
     assert start_byte == 7
     assert end_byte == 11
     assert total_bytes == 42