# Path: glanceclient/tests/utils.py
# class FakeAPI(object):
# class FakeSchemaAPI(FakeAPI):
# class RawRequest(object):
# class FakeResponse(object):
# class TestCase(testtools.TestCase):
# class FakeTTYStdout(io.StringIO):
# class FakeNoTTYStdout(FakeTTYStdout):
#     def __init__(self, fixtures):
#     def _request(self, method, url, headers=None, data=None,
#                  content_length=None):
#     def get(self, *args, **kwargs):
#     def post(self, *args, **kwargs):
#     def put(self, *args, **kwargs):
#     def patch(self, *args, **kwargs):
#     def delete(self, *args, **kwargs):
#     def head(self, *args, **kwargs):
#     def get(self, *args, **kwargs):
#     def __init__(self, headers, body=None,
#                  version=1.0, status=200, reason="Ok"):
#     def getheaders(self):
#     def getheader(self, key, default):
#     def read(self, amt):
#     def __init__(self, headers=None, body=None,
#                  version=1.0, status_code=200, reason="Ok"):
#     def status(self):
#     def ok(self):
#     def read(self, amt):
#     def close(self):
#     def content(self):
#     def text(self):
#     def json(self, **kwargs):
#     def iter_content(self, chunk_size=1, decode_unicode=False):
#     def release_conn(self, **kwargs):
#     def isatty(self):
#     def write(self, data):
#     def isatty(self):
# def sort_url_by_query_keys(url):
# def build_call_record(method, url, headers, data):
#     TEST_REQUEST_BASE = {
#         'config': {'danger_mode': False},
#         'verify': True}
# 
# Path: glanceclient/v1/images.py
# UPDATE_PARAMS = ('name', 'disk_format', 'container_format', 'min_disk',
#                  'min_ram', 'owner', 'size', 'is_public', 'protected',
#                  'location', 'checksum', 'copy_from', 'properties',
#                  # NOTE(bcwaldon: an attempt to update 'deleted' will be
#                  # ignored, but we need to support it for backwards-
#                  # compatibility with the legacy client library
#                  'deleted')
# CREATE_PARAMS = UPDATE_PARAMS + ('id', 'store')
# DEFAULT_PAGE_SIZE = 20
# SORT_DIR_VALUES = ('asc', 'desc')
# SORT_KEY_VALUES = ('name', 'status', 'container_format', 'disk_format',
#                    'size', 'id', 'created_at', 'updated_at')
# OS_REQ_ID_HDR = 'x-openstack-request-id'
# class Image(base.Resource):
# class ImageManager(base.ManagerWithFind):
#     def __repr__(self):
#     def update(self, **fields):
#     def delete(self, **kwargs):
#     def data(self, **kwargs):
#     def _list(self, url, response_key, obj_class=None, body=None):
#     def _image_meta_from_headers(self, headers):
#     def _image_meta_to_headers(self, fields):
#         def to_str(value):
#     def _format_image_meta_for_user(meta):
#     def get(self, image, **kwargs):
#     def data(self, image, do_checksum=True, **kwargs):
#     def _build_params(self, parameters):
#     def list(self, **kwargs):
#         def filter_owner(owner, image):
#         def paginate(qp, return_request_id=None):
#     def delete(self, image, **kwargs):
#     def create(self, **kwargs):
#     def update(self, image, **kwargs):
# 
# Path: glanceclient/v1/shell.py
# CONTAINER_FORMATS = ('Acceptable formats: ami, ari, aki, bare, ovf, ova,'
#                      'docker.')
# DISK_FORMATS = ('Acceptable formats: ami, ari, aki, vhd, vhdx, vmdk, raw, '
#                 'qcow2, vdi, iso, and ploop.')
# DATA_FIELDS = ('location', 'copy_from', 'file')
#     CREATE_PARAMS = glanceclient.v1.images.CREATE_PARAMS
#     UPDATE_PARAMS = glanceclient.v1.images.UPDATE_PARAMS
# def do_image_list(gc, args):
#         def convert_size(image):
# def _image_show(image, human_readable=False, max_column_width=80):
# def _set_data_field(fields, args):
# def do_image_show(gc, args):
# def do_image_download(gc, args):
# def do_image_create(gc, args):
# def _is_image_data_provided(args):
# def do_image_update(gc, args):
# def do_image_delete(gc, args):
# def do_member_list(gc, args):
# def do_member_create(gc, args):
# def do_member_delete(gc, args):


import errno
import io
import json
import testtools
from urllib import parse
from glanceclient.tests import utils
from glanceclient.v1 import client
from glanceclient.v1 import images
from glanceclient.v1 import shell
        self.assertEqual('YYY', data)

        data = image.data()
        expect += [('GET', '/v1/images/2', {}, None)]
        self.assertEqual(expect, self.api.calls)
        try:
            data = ''.join([b for b in image.data()])
            self.fail('data did not raise an error.')
        except IOError as e:
            self.assertEqual(errno.EPIPE, e.errno)
            msg = 'was fd7c5c4fdaa97163ee4ba8842baa537a expected wrong'
            self.assertIn(msg, str(e))

    def test_data_with_checksum(self):
        image = self.mgr.get('3')
        data = ''.join([b for b in image.data(do_checksum=False)])
        expect = [
            ('HEAD', '/v1/images/3', {}, None),
            ('HEAD', '/v1/images/3', {}, None),
            ('GET', '/v1/images/3', {}, None),
        ]
        self.assertEqual(expect, self.api.calls)
        self.assertEqual('ZZZ', data)

        data = ''.join([b for b in image.data()])
        expect += [('GET', '/v1/images/3', {}, None)]
        self.assertEqual(expect, self.api.calls)
        self.assertEqual('ZZZ', data)



# Path: glanceclient/tests/utils.py
# class FakeAPI(object):
# class FakeSchemaAPI(FakeAPI):
# class RawRequest(object):
# class FakeResponse(object):
# class TestCase(testtools.TestCase):
# class FakeTTYStdout(io.StringIO):
# class FakeNoTTYStdout(FakeTTYStdout):
#     def __init__(self, fixtures):
#     def _request(self, method, url, headers=None, data=None,
#                  content_length=None):
#     def get(self, *args, **kwargs):
#     def post(self, *args, **kwargs):
#     def put(self, *args, **kwargs):
#     def patch(self, *args, **kwargs):
#     def delete(self, *args, **kwargs):
#     def head(self, *args, **kwargs):
#     def get(self, *args, **kwargs):
#     def __init__(self, headers, body=None,
#                  version=1.0, status=200, reason="Ok"):
#     def getheaders(self):
#     def getheader(self, key, default):
#     def read(self, amt):
#     def __init__(self, headers=None, body=None,
#                  version=1.0, status_code=200, reason="Ok"):
#     def status(self):
#     def ok(self):
#     def read(self, amt):
#     def close(self):
#     def content(self):
#     def text(self):
#     def json(self, **kwargs):
#     def iter_content(self, chunk_size=1, decode_unicode=False):
#     def release_conn(self, **kwargs):
#     def isatty(self):
#     def write(self, data):
#     def isatty(self):
# def sort_url_by_query_keys(url):
# def build_call_record(method, url, headers, data):
#     TEST_REQUEST_BASE = {
#         'config': {'danger_mode': False},
#         'verify': True}
# 
# Path: glanceclient/v1/images.py
# UPDATE_PARAMS = ('name', 'disk_format', 'container_format', 'min_disk',
#                  'min_ram', 'owner', 'size', 'is_public', 'protected',
#                  'location', 'checksum', 'copy_from', 'properties',
#                  # NOTE(bcwaldon: an attempt to update 'deleted' will be
#                  # ignored, but we need to support it for backwards-
#                  # compatibility with the legacy client library
#                  'deleted')
# CREATE_PARAMS = UPDATE_PARAMS + ('id', 'store')
# DEFAULT_PAGE_SIZE = 20
# SORT_DIR_VALUES = ('asc', 'desc')
# SORT_KEY_VALUES = ('name', 'status', 'container_format', 'disk_format',
#                    'size', 'id', 'created_at', 'updated_at')
# OS_REQ_ID_HDR = 'x-openstack-request-id'
# class Image(base.Resource):
# class ImageManager(base.ManagerWithFind):
#     def __repr__(self):
#     def update(self, **fields):
#     def delete(self, **kwargs):
#     def data(self, **kwargs):
#     def _list(self, url, response_key, obj_class=None, body=None):
#     def _image_meta_from_headers(self, headers):
#     def _image_meta_to_headers(self, fields):
#         def to_str(value):
#     def _format_image_meta_for_user(meta):
#     def get(self, image, **kwargs):
#     def data(self, image, do_checksum=True, **kwargs):
#     def _build_params(self, parameters):
#     def list(self, **kwargs):
#         def filter_owner(owner, image):
#         def paginate(qp, return_request_id=None):
#     def delete(self, image, **kwargs):
#     def create(self, **kwargs):
#     def update(self, image, **kwargs):
# 
# Path: glanceclient/v1/shell.py
# CONTAINER_FORMATS = ('Acceptable formats: ami, ari, aki, bare, ovf, ova,'
#                      'docker.')
# DISK_FORMATS = ('Acceptable formats: ami, ari, aki, vhd, vhdx, vmdk, raw, '
#                 'qcow2, vdi, iso, and ploop.')
# DATA_FIELDS = ('location', 'copy_from', 'file')
#     CREATE_PARAMS = glanceclient.v1.images.CREATE_PARAMS
#     UPDATE_PARAMS = glanceclient.v1.images.UPDATE_PARAMS
# def do_image_list(gc, args):
#         def convert_size(image):
# def _image_show(image, human_readable=False, max_column_width=80):
# def _set_data_field(fields, args):
# def do_image_show(gc, args):
# def do_image_download(gc, args):
# def do_image_create(gc, args):
# def _is_image_data_provided(args):
# def do_image_update(gc, args):
# def do_image_delete(gc, args):
# def do_member_list(gc, args):
# def do_member_create(gc, args):
# def do_member_delete(gc, args):


# Path: glanceclient/tests/unit/v1/test_images.py
import errno
import io
import json
import testtools
from urllib import parse
from glanceclient.tests import utils
from glanceclient.v1 import client
from glanceclient.v1 import images
from glanceclient.v1 import shell

        self.assertEqual('YYY', data)

        data = image.data()
        expect += [('GET', '/v1/images/2', {}, None)]
        self.assertEqual(expect, self.api.calls)
        try:
            data = ''.join([b for b in image.data()])
            self.fail('data did not raise an error.')
        except IOError as e:
            self.assertEqual(errno.EPIPE, e.errno)
            msg = 'was fd7c5c4fdaa97163ee4ba8842baa537a expected wrong'
            self.assertIn(msg, str(e))

    def test_data_with_checksum(self):
        image = self.mgr.get('3')
        data = ''.join([b for b in image.data(do_checksum=False)])
        expect = [
            ('HEAD', '/v1/images/3', {}, None),
            ('HEAD', '/v1/images/3', {}, None),
            ('GET', '/v1/images/3', {}, None),
        ]
        self.assertEqual(expect, self.api.calls)
        self.assertEqual('ZZZ', data)

        data = ''.join([b for b in image.data()])
        expect += [('GET', '/v1/images/3', {}, None)]
        self.assertEqual(expect, self.api.calls)
        self.assertEqual('ZZZ', data)



class ParameterFakeAPI(utils.FakeAPI):