def test_index(self): class Image(): id = 'test' filters = {} limit = 18 marker = False sort_key = 'test' kwarg = 'name' sort_dir = 'test' name = 'test' disk_format = 'ovi' container_format = 'ovi' size = 1024 args = Image() gc = client.Client('1', 'http://is.invalid') with mock.patch.object(gc.images, 'list') as mocked_list: mocked_list.return_value = [Image(), Image()] test_shell.do_index(gc, args)
def test_index_return_empty(self): class Image(): id = 'test' filters = {} limit = 18 marker = False sort_key = 'test' kwarg = 'name' sort_dir = 'test' name = 'test' disk_format = 'ovi' container_format = 'ovi' size = 1024 args = Image() gc = client.Client('1', 'http://is.invalid') with mock.patch.object(test_shell, '_get_images') as mocked_get: mocked_get.return_value = False actual = test_shell.do_index(gc, args) self.assertEqual(0, actual)