'Even though Content-Range is incorrect on requests, we support it
for backward compatibility with clients written for pre-Pike
Glance.
The following test is for \'Content-Range\' requests, which we have
to ensure that we prevent regression.'

def test_content_range_requests_for_image_downloads(self):

    def download_successful_ContentRange(d_range):
        request = wsgi.Request.blank('/')
        request.environ = {}
        request.headers['Content-Range'] = d_range
        response = webob.Response()
        response.request = request
        image = FakeImage(size=3, data=['X', 'Y', 'Z'])
        self.serializer.download(response, image)
        self.assertEqual(206, response.status_code)
        self.assertEqual('2', response.headers['Content-Length'])
        self.assertEqual('bytes    1-2/3', response.headers['Content-Range'])
        self.assertEqual('YZ', response.body)
    download_successful_ContentRange('bytes    1-2/3')
    download_successful_ContentRange('bytes    1-2/*')
    def download_failures_ContentRange(d_range):
        request = wsgi.Request.blank('/')
        request.environ = {}
        request.headers['Content-Range'] = d_range
        response = webob.Response()
        response.request = request
        image = FakeImage(size=3, data=['Z', 'Z', 'Z'])
        self.assertRaises(webob.exc.HTTPRequestRangeNotSatisfiable, self.serializer.download, response, image)
        return
    download_failures_ContentRange('bytes    -3/3')
    download_failures_ContentRange('bytes    1-/3')
    download_failures_ContentRange('bytes    1-3/3')
    download_failures_ContentRange('bytes    1-4/3')
    download_failures_ContentRange('bytes    1-4/*')
    download_failures_ContentRange('bytes    4-1/3')
    download_failures_ContentRange('bytes    4-1/*')
    download_failures_ContentRange('bytes    4-8/*')
    download_failures_ContentRange('bytes    4-8/10')
    download_failures_ContentRange('bytes    4-8/3')
