# 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

    def test_image_list_with_owner(self):
        images = self.mgr.list(owner='A', page_size=20)
        image_list = list(images)
        self.assertEqual('A', image_list[0].owner)
        self.assertEqual('a', image_list[0].id)
        self.assertEqual(1, len(image_list))

    def test_image_list_with_owner_req_id(self):
        fields = {
            'owner': 'A',
            'return_req_id': [],
        }
        images = self.mgr.list(**fields)
        next(images)
        self.assertEqual(['req-1234'], fields['return_req_id'])

    def test_image_list_with_notfound_owner(self):
        images = self.mgr.list(owner='X', page_size=20)
        self.assertEqual(0, len(list(images)))

    def test_image_list_with_empty_string_owner(self):
        images = self.mgr.list(owner='', page_size=20)
        image_list = list(images)
        self.assertRaises(AttributeError, lambda: image_list[0].owner)
        self.assertEqual('c', image_list[0].id)
        self.assertEqual(1, len(image_list))

    def test_image_list_with_unspecified_owner(self):
        images = self.mgr.list(owner=None, page_size=5)

# 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


    def test_image_list_with_owner(self):
        images = self.mgr.list(owner='A', page_size=20)
        image_list = list(images)
        self.assertEqual('A', image_list[0].owner)
        self.assertEqual('a', image_list[0].id)
        self.assertEqual(1, len(image_list))

    def test_image_list_with_owner_req_id(self):
        fields = {
            'owner': 'A',
            'return_req_id': [],
        }
        images = self.mgr.list(**fields)
        next(images)
        self.assertEqual(['req-1234'], fields['return_req_id'])

    def test_image_list_with_notfound_owner(self):
        images = self.mgr.list(owner='X', page_size=20)
        self.assertEqual(0, len(list(images)))

    def test_image_list_with_empty_string_owner(self):
        images = self.mgr.list(owner='', page_size=20)
        image_list = list(images)
        self.assertRaises(AttributeError, lambda: image_list[0].owner)
        self.assertEqual('c', image_list[0].id)
        self.assertEqual(1, len(image_list))

    def test_image_list_with_unspecified_owner(self):
        images = self.mgr.list(owner=None, page_size=5)

        image_list = list(images)