def test_do_image_list(self):
        input = {
            'page_size': 18,
            'visibility': True,
            'member_status': 'Fake',
            'owner': 'test',
            'checksum': 'fake_checksum',
            'tag': 'fake tag'
        }
        args = self._make_args(input)
        with mock.patch.object(self.gc.images, 'list') as mocked_list:
            mocked_list.return_value = {}

            test_shell.do_image_list(self.gc, args)

            exp_img_filters = {
                'owner': 'test',
                'member_status': 'Fake',
                'visibility': True,
                'checksum': 'fake_checksum',
                'tag': 'fake tag'
            }
            mocked_list.assert_called_once_with(page_size=18,
                                                filters=exp_img_filters)
            utils.print_list.assert_called_once_with({}, ['ID', 'Name'])
    def test_do_image_list_with_single_sort_key(self):
        input = {
            'limit': None,
            'page_size': 18,
            'visibility': True,
            'member_status': 'Fake',
            'owner': 'test',
            'checksum': 'fake_checksum',
            'tag': 'fake tag',
            'properties': [],
            'sort_key': ['name'],
            'sort_dir': ['desc'],
            'sort': None,
            'verbose': False
        }
        args = self._make_args(input)
        with mock.patch.object(self.gc.images, 'list') as mocked_list:
            mocked_list.return_value = {}

            test_shell.do_image_list(self.gc, args)

            exp_img_filters = {
                'owner': 'test',
                'member_status': 'Fake',
                'visibility': True,
                'checksum': 'fake_checksum',
                'tag': 'fake tag'
            }
            mocked_list.assert_called_once_with(page_size=18,
                                                sort_key=['name'],
                                                sort_dir=['desc'],
                                                filters=exp_img_filters)
            utils.print_list.assert_called_once_with({}, ['ID', 'Name'])
예제 #3
0
    def test_do_image_list_with_property_filter(self):
        input = {
            "page_size": 1,
            "visibility": True,
            "member_status": "Fake",
            "owner": "test",
            "checksum": "fake_checksum",
            "tag": "fake tag",
            "properties": ["os_distro=NixOS", "architecture=x86_64"],
        }
        args = self._make_args(input)
        with mock.patch.object(self.gc.images, "list") as mocked_list:
            mocked_list.return_value = {}

            test_shell.do_image_list(self.gc, args)

            exp_img_filters = {
                "owner": "test",
                "member_status": "Fake",
                "visibility": True,
                "checksum": "fake_checksum",
                "tag": "fake tag",
                "os_distro": "NixOS",
                "architecture": "x86_64",
            }

            mocked_list.assert_called_once_with(page_size=1, filters=exp_img_filters)
            utils.print_list.assert_called_once_with({}, ["ID", "Name"])
예제 #4
0
    def test_do_image_list_with_single_sort_key(self):
        input = {
            "limit": None,
            "page_size": 18,
            "visibility": True,
            "member_status": "Fake",
            "owner": "test",
            "checksum": "fake_checksum",
            "tag": "fake tag",
            "properties": [],
            "sort_key": ["name"],
            "sort_dir": ["desc"],
            "sort": None,
            "verbose": False,
        }
        args = self._make_args(input)
        with mock.patch.object(self.gc.images, "list") as mocked_list:
            mocked_list.return_value = {}

            test_shell.do_image_list(self.gc, args)

            exp_img_filters = {
                "owner": "test",
                "member_status": "Fake",
                "visibility": True,
                "checksum": "fake_checksum",
                "tag": "fake tag",
            }
            mocked_list.assert_called_once_with(
                page_size=18, sort_key=["name"], sort_dir=["desc"], filters=exp_img_filters
            )
            utils.print_list.assert_called_once_with({}, ["ID", "Name"])
    def test_do_image_list(self):
        input = {
            'page_size': 18,
            'visibility': True,
            'member_status': 'Fake',
            'owner': 'test',
            'checksum': 'fake_checksum',
            'tag': 'fake tag'
        }
        args = self._make_args(input)
        with mock.patch.object(self.gc.images, 'list') as mocked_list:
            mocked_list.return_value = {}

            test_shell.do_image_list(self.gc, args)

            exp_img_filters = {
                'owner': 'test',
                'member_status': 'Fake',
                'visibility': True,
                'checksum': 'fake_checksum',
                'tag': 'fake tag'
            }
            mocked_list.assert_called_once_with(page_size=18,
                                                filters=exp_img_filters)
            utils.print_list.assert_called_once_with({}, ['ID', 'Name'])
예제 #6
0
    def test_do_image_list_with_property_filter(self):
        input = {
            'limit': None,
            'page_size': 1,
            'visibility': True,
            'member_status': 'Fake',
            'owner': 'test',
            'checksum': 'fake_checksum',
            'tag': 'fake tag',
            'properties': ['os_distro=NixOS', 'architecture=x86_64']
        }
        args = self._make_args(input)
        with mock.patch.object(self.gc.images, 'list') as mocked_list:
            mocked_list.return_value = {}

            test_shell.do_image_list(self.gc, args)

            exp_img_filters = {
                'owner': 'test',
                'member_status': 'Fake',
                'visibility': True,
                'checksum': 'fake_checksum',
                'tag': 'fake tag',
                'os_distro': 'NixOS',
                'architecture': 'x86_64'
            }

            mocked_list.assert_called_once_with(page_size=1,
                                                filters=exp_img_filters)
            utils.print_list.assert_called_once_with({}, ['ID', 'Name'])
예제 #7
0
    def test_do_image_list_with_property_filter(self):
        input = {
            'page_size': 1,
            'visibility': True,
            'member_status': 'Fake',
            'owner': 'test',
            'checksum': 'fake_checksum',
            'tag': 'fake tag',
            'properties': ['os_distro=NixOS', 'architecture=x86_64']
        }
        args = self._make_args(input)
        with mock.patch.object(self.gc.images, 'list') as mocked_list:
            mocked_list.return_value = {}

            test_shell.do_image_list(self.gc, args)

            exp_img_filters = {
                'owner': 'test',
                'member_status': 'Fake',
                'visibility': True,
                'checksum': 'fake_checksum',
                'tag': 'fake tag',
                'os_distro': 'NixOS',
                'architecture': 'x86_64'
            }

            mocked_list.assert_called_once_with(page_size=1,
                                                filters=exp_img_filters)
            utils.print_list.assert_called_once_with({}, ['ID', 'Name'])
예제 #8
0
    def test_do_image_list_with_single_sort_key(self):
        input = {
            'limit': None,
            'page_size': 18,
            'visibility': True,
            'member_status': 'Fake',
            'owner': 'test',
            'checksum': 'fake_checksum',
            'tag': 'fake tag',
            'properties': [],
            'sort_key': ['name'],
            'sort_dir': ['desc'],
            'sort': None,
            'verbose': False
        }
        args = self._make_args(input)
        with mock.patch.object(self.gc.images, 'list') as mocked_list:
            mocked_list.return_value = {}

            test_shell.do_image_list(self.gc, args)

            exp_img_filters = {
                'owner': 'test',
                'member_status': 'Fake',
                'visibility': True,
                'checksum': 'fake_checksum',
                'tag': 'fake tag'
            }
            mocked_list.assert_called_once_with(page_size=18,
                                                sort_key=['name'],
                                                sort_dir=['desc'],
                                                filters=exp_img_filters)
            utils.print_list.assert_called_once_with({}, ['ID', 'Name'])
예제 #9
0
    def test_do_image_list(self):
        gc = client.Client('1', 'http://no.where')

        class Fake():
            def __init__(self):
                self.page_size = 18
                self.visibility = True
                self.member_status = 'Fake'
                self.owner = 'test'

        with mock.patch.object(gc.images, 'list') as mocked_list:
            mocked_list.return_value = {}
            actual = test_shell.do_image_list(gc, Fake())
예제 #10
0
    def test_do_image_list(self):
        gc = client.Client('1', 'http://is.invalid')

        class Fake():
            def __init__(self):
                self.page_size = 18
                self.visibility = True
                self.member_status = 'Fake'
                self.owner = 'test'

        with mock.patch.object(gc.images, 'list') as mocked_list:
            mocked_list.return_value = {}
            actual = test_shell.do_image_list(gc, Fake())
예제 #11
0
    def test_do_image_list(self):
        input = {
            "page_size": 18,
            "visibility": True,
            "member_status": "Fake",
            "owner": "test",
            "checksum": "fake_checksum",
            "tag": "fake tag",
        }
        args = self._make_args(input)
        with mock.patch.object(self.gc.images, "list") as mocked_list:
            mocked_list.return_value = {}

            test_shell.do_image_list(self.gc, args)

            exp_img_filters = {
                "owner": "test",
                "member_status": "Fake",
                "visibility": True,
                "checksum": "fake_checksum",
                "tag": "fake tag",
            }
            mocked_list.assert_called_once_with(page_size=18, filters=exp_img_filters)
            utils.print_list.assert_called_once_with({}, ["ID", "Name"])