Merge "tests: Use consistent shortcut to fake image client"
This commit is contained in:
commit
6ae38b2888
@ -167,6 +167,7 @@ class TestComputev2(network_fakes.FakeClientMixin, utils.TestCommand):
|
||||
)
|
||||
|
||||
self.app.client_manager.image = mock.Mock()
|
||||
self.image_client = self.app.client_manager.image
|
||||
|
||||
self.app.client_manager.volume = volume_fakes.FakeVolumeClient(
|
||||
endpoint=fakes.AUTH_URL,
|
||||
|
@ -92,16 +92,6 @@ class TestServer(compute_fakes.TestComputev2):
|
||||
self.flavors_mock = self.app.client_manager.compute.flavors
|
||||
self.flavors_mock.reset_mock()
|
||||
|
||||
# Get a shortcut to the image client ImageManager Mock
|
||||
self.images_mock = self.app.client_manager.image.images
|
||||
self.images_mock.reset_mock()
|
||||
|
||||
self.find_image_mock = self.app.client_manager.image.find_image
|
||||
self.find_image_mock.reset_mock()
|
||||
|
||||
self.get_image_mock = self.app.client_manager.image.get_image
|
||||
self.get_image_mock.reset_mock()
|
||||
|
||||
# Get a shortcut to the volume client VolumeManager Mock
|
||||
self.volumes_mock = self.app.client_manager.volume.volumes
|
||||
self.volumes_mock.reset_mock()
|
||||
@ -1375,8 +1365,8 @@ class TestServerCreate(TestServer):
|
||||
self.servers_mock.create.return_value = self.new_server
|
||||
|
||||
self.image = image_fakes.create_one_image()
|
||||
self.find_image_mock.return_value = self.image
|
||||
self.get_image_mock.return_value = self.image
|
||||
self.image_client.find_image.return_value = self.image
|
||||
self.image_client.get_image.return_value = self.image
|
||||
|
||||
self.flavor = compute_fakes.create_one_flavor()
|
||||
self.flavors_mock.get.return_value = self.flavor
|
||||
@ -1452,7 +1442,7 @@ class TestServerCreate(TestServer):
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.datalist(), data)
|
||||
self.assertFalse(self.images_mock.called)
|
||||
self.assertFalse(self.image_client.images.called)
|
||||
self.assertFalse(self.flavors_mock.called)
|
||||
|
||||
def test_server_create_with_options(self):
|
||||
@ -3444,7 +3434,7 @@ class TestServerCreate(TestServer):
|
||||
}
|
||||
|
||||
_image = image_fakes.create_one_image(image_info)
|
||||
self.images_mock.return_value = [_image]
|
||||
self.image_client.images.return_value = [_image]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -3500,7 +3490,7 @@ class TestServerCreate(TestServer):
|
||||
'hw_disk_bus': 'ide',
|
||||
}
|
||||
_image = image_fakes.create_one_image(image_info)
|
||||
self.images_mock.return_value = [_image]
|
||||
self.image_client.images.return_value = [_image]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -3557,7 +3547,7 @@ class TestServerCreate(TestServer):
|
||||
}
|
||||
|
||||
_image = image_fakes.create_one_image(image_info)
|
||||
self.images_mock.return_value = [_image]
|
||||
self.image_client.images.return_value = [_image]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -3589,7 +3579,7 @@ class TestServerCreate(TestServer):
|
||||
|
||||
target_image = image_fakes.create_one_image(image_info)
|
||||
another_image = image_fakes.create_one_image({})
|
||||
self.images_mock.return_value = [target_image, another_image]
|
||||
self.image_client.images.return_value = [target_image, another_image]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -3893,7 +3883,7 @@ class TestServerCreate(TestServer):
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.datalist(), data)
|
||||
self.assertFalse(self.images_mock.called)
|
||||
self.assertFalse(self.image_client.images.called)
|
||||
self.assertFalse(self.flavors_mock.called)
|
||||
|
||||
def test_server_create_with_description_api_older(self):
|
||||
@ -3975,7 +3965,7 @@ class TestServerCreate(TestServer):
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.datalist(), data)
|
||||
self.assertFalse(self.images_mock.called)
|
||||
self.assertFalse(self.image_client.images.called)
|
||||
self.assertFalse(self.flavors_mock.called)
|
||||
|
||||
def test_server_create_with_tag_pre_v252(self):
|
||||
@ -4063,7 +4053,7 @@ class TestServerCreate(TestServer):
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.datalist(), data)
|
||||
self.assertFalse(self.images_mock.called)
|
||||
self.assertFalse(self.image_client.images.called)
|
||||
self.assertFalse(self.flavors_mock.called)
|
||||
|
||||
def test_server_create_with_host_pre_v274(self):
|
||||
@ -4147,7 +4137,7 @@ class TestServerCreate(TestServer):
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.datalist(), data)
|
||||
self.assertFalse(self.images_mock.called)
|
||||
self.assertFalse(self.image_client.images.called)
|
||||
self.assertFalse(self.flavors_mock.called)
|
||||
|
||||
def test_server_create_with_hypervisor_hostname_pre_v274(self):
|
||||
@ -4235,7 +4225,7 @@ class TestServerCreate(TestServer):
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.datalist(), data)
|
||||
self.assertFalse(self.images_mock.called)
|
||||
self.assertFalse(self.image_client.images.called)
|
||||
self.assertFalse(self.flavors_mock.called)
|
||||
|
||||
def test_server_create_with_hostname_v290(self):
|
||||
@ -4286,7 +4276,7 @@ class TestServerCreate(TestServer):
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.datalist(), data)
|
||||
self.assertFalse(self.images_mock.called)
|
||||
self.assertFalse(self.image_client.images.called)
|
||||
self.assertFalse(self.flavors_mock.called)
|
||||
|
||||
def test_server_create_with_hostname_pre_v290(self):
|
||||
@ -4366,7 +4356,7 @@ class TestServerCreate(TestServer):
|
||||
)
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.datalist(), data)
|
||||
self.assertFalse(self.images_mock.called)
|
||||
self.assertFalse(self.image_client.images.called)
|
||||
self.assertFalse(self.flavors_mock.called)
|
||||
|
||||
def test_server_create_with_trusted_image_cert_prev263(self):
|
||||
@ -4714,9 +4704,8 @@ class _TestServerList(TestServer):
|
||||
|
||||
self.image = image_fakes.create_one_image()
|
||||
|
||||
# self.images_mock.return_value = [self.image]
|
||||
self.find_image_mock.return_value = self.image
|
||||
self.get_image_mock.return_value = self.image
|
||||
self.image_client.find_image.return_value = self.image
|
||||
self.image_client.get_image.return_value = self.image
|
||||
|
||||
self.flavor = compute_fakes.create_one_flavor()
|
||||
self.sdk_client.find_flavor.return_value = self.flavor
|
||||
@ -4735,7 +4724,7 @@ class TestServerList(_TestServerList):
|
||||
super(TestServerList, self).setUp()
|
||||
|
||||
Image = collections.namedtuple('Image', 'id name')
|
||||
self.images_mock.return_value = [
|
||||
self.image_client.images.return_value = [
|
||||
Image(id=s.image['id'], name=self.image.name)
|
||||
# Image will be an empty string if boot-from-volume
|
||||
for s in self.servers
|
||||
@ -4774,11 +4763,11 @@ class TestServerList(_TestServerList):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.sdk_client.servers.assert_called_with(**self.kwargs)
|
||||
self.images_mock.assert_called()
|
||||
self.image_client.images.assert_called()
|
||||
self.sdk_client.flavors.assert_called()
|
||||
# we did not pass image or flavor, so gets on those must be absent
|
||||
self.assertFalse(self.flavors_mock.get.call_count)
|
||||
self.assertFalse(self.get_image_mock.call_count)
|
||||
self.assertFalse(self.image_client.get_image.call_count)
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.data, tuple(data))
|
||||
|
||||
@ -4796,7 +4785,7 @@ class TestServerList(_TestServerList):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.sdk_client.servers.assert_called_with(**self.kwargs)
|
||||
self.images_mock.assert_not_called()
|
||||
self.image_client.images.assert_not_called()
|
||||
self.sdk_client.flavors.assert_not_called()
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.data, tuple(data))
|
||||
@ -4833,7 +4822,7 @@ class TestServerList(_TestServerList):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.sdk_client.servers.assert_called_with(**self.kwargs)
|
||||
image_ids = {s.image['id'] for s in self.servers if s.image}
|
||||
self.images_mock.assert_called_once_with(
|
||||
self.image_client.images.assert_called_once_with(
|
||||
id=f'in:{",".join(image_ids)}',
|
||||
)
|
||||
self.sdk_client.flavors.assert_called_once_with(is_public=None)
|
||||
@ -4913,7 +4902,7 @@ class TestServerList(_TestServerList):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.sdk_client.servers.assert_called_with(**self.kwargs)
|
||||
self.images_mock.assert_not_called()
|
||||
self.image_client.images.assert_not_called()
|
||||
self.sdk_client.flavors.assert_not_called()
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.data, tuple(data))
|
||||
@ -4944,7 +4933,7 @@ class TestServerList(_TestServerList):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.sdk_client.servers.assert_called_with(**self.kwargs)
|
||||
self.images_mock.assert_not_called()
|
||||
self.image_client.images.assert_not_called()
|
||||
self.sdk_client.flavors.assert_not_called()
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.data, tuple(data))
|
||||
@ -4961,9 +4950,9 @@ class TestServerList(_TestServerList):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.sdk_client.servers.assert_called_with(**self.kwargs)
|
||||
self.images_mock.assert_not_called()
|
||||
self.image_client.images.assert_not_called()
|
||||
self.sdk_client.flavors.assert_not_called()
|
||||
self.get_image_mock.assert_called()
|
||||
self.image_client.get_image.assert_called()
|
||||
self.sdk_client.find_flavor.assert_called()
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
@ -4976,13 +4965,13 @@ class TestServerList(_TestServerList):
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.find_image_mock.assert_called_with(
|
||||
self.image_client.find_image.assert_called_with(
|
||||
self.image.id, ignore_missing=False
|
||||
)
|
||||
|
||||
self.kwargs['image'] = self.image.id
|
||||
self.sdk_client.servers.assert_called_with(**self.kwargs)
|
||||
self.images_mock.assert_not_called()
|
||||
self.image_client.images.assert_not_called()
|
||||
self.sdk_client.flavors.assert_called_once()
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
@ -5001,7 +4990,7 @@ class TestServerList(_TestServerList):
|
||||
|
||||
self.kwargs['flavor'] = self.flavor.id
|
||||
self.sdk_client.servers.assert_called_with(**self.kwargs)
|
||||
self.images_mock.assert_called_once()
|
||||
self.image_client.images.assert_called_once()
|
||||
self.sdk_client.flavors.assert_not_called()
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
@ -5326,7 +5315,7 @@ class TestServerList(_TestServerList):
|
||||
|
||||
# Make sure the returned image and flavor IDs match the servers.
|
||||
Image = collections.namedtuple('Image', 'id name')
|
||||
self.images_mock.return_value = [
|
||||
self.image_client.images.return_value = [
|
||||
Image(id=s.image['id'], name=self.image.name)
|
||||
# Image will be an empty string if boot-from-volume
|
||||
for s in servers
|
||||
@ -5409,7 +5398,7 @@ class TestServerListV273(_TestServerList):
|
||||
self.sdk_client.servers.return_value = self.servers
|
||||
|
||||
Image = collections.namedtuple('Image', 'id name')
|
||||
self.images_mock.return_value = [
|
||||
self.image_client.images.return_value = [
|
||||
Image(id=s.image['id'], name=self.image.name)
|
||||
# Image will be an empty string if boot-from-volume
|
||||
for s in self.servers
|
||||
@ -6172,7 +6161,7 @@ class TestServerRebuild(TestServer):
|
||||
|
||||
# Return value for utils.find_resource for image
|
||||
self.image = image_fakes.create_one_image()
|
||||
self.get_image_mock.return_value = self.image
|
||||
self.image_client.get_image.return_value = self.image
|
||||
|
||||
# Fake the rebuilt new server.
|
||||
attrs = {
|
||||
@ -6200,7 +6189,7 @@ class TestServerRebuild(TestServer):
|
||||
def test_rebuild_with_image_name(self):
|
||||
image_name = 'my-custom-image'
|
||||
user_image = image_fakes.create_one_image(attrs={'name': image_name})
|
||||
self.find_image_mock.return_value = user_image
|
||||
self.image_client.find_image.return_value = user_image
|
||||
|
||||
attrs = {
|
||||
'image': {'id': user_image.id},
|
||||
@ -6218,10 +6207,10 @@ class TestServerRebuild(TestServer):
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.servers_mock.get.assert_called_with(self.server.id)
|
||||
self.find_image_mock.assert_called_with(
|
||||
self.image_client.find_image.assert_called_with(
|
||||
image_name, ignore_missing=False
|
||||
)
|
||||
self.get_image_mock.assert_called_with(user_image.id)
|
||||
self.image_client.get_image.assert_called_with(user_image.id)
|
||||
self.server.rebuild.assert_called_with(user_image, None)
|
||||
|
||||
def test_rebuild_with_current_image(self):
|
||||
@ -6235,8 +6224,8 @@ class TestServerRebuild(TestServer):
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.servers_mock.get.assert_called_with(self.server.id)
|
||||
self.find_image_mock.assert_not_called()
|
||||
self.get_image_mock.assert_called_with(self.image.id)
|
||||
self.image_client.find_image.assert_not_called()
|
||||
self.image_client.get_image.assert_called_with(self.image.id)
|
||||
self.server.rebuild.assert_called_with(self.image, None)
|
||||
|
||||
def test_rebuild_with_volume_backed_server_no_image(self):
|
||||
@ -6274,7 +6263,7 @@ class TestServerRebuild(TestServer):
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.servers_mock.get.assert_called_with(self.server.id)
|
||||
self.get_image_mock.assert_called_with(self.image.id)
|
||||
self.image_client.get_image.assert_called_with(self.image.id)
|
||||
self.server.rebuild.assert_called_with(self.image, None, name=name)
|
||||
|
||||
def test_rebuild_with_preserve_ephemeral(self):
|
||||
@ -6292,7 +6281,7 @@ class TestServerRebuild(TestServer):
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.servers_mock.get.assert_called_with(self.server.id)
|
||||
self.get_image_mock.assert_called_with(self.image.id)
|
||||
self.image_client.get_image.assert_called_with(self.image.id)
|
||||
self.server.rebuild.assert_called_with(
|
||||
self.image, None, preserve_ephemeral=True
|
||||
)
|
||||
@ -6312,7 +6301,7 @@ class TestServerRebuild(TestServer):
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.servers_mock.get.assert_called_with(self.server.id)
|
||||
self.get_image_mock.assert_called_with(self.image.id)
|
||||
self.image_client.get_image.assert_called_with(self.image.id)
|
||||
self.server.rebuild.assert_called_with(
|
||||
self.image, None, preserve_ephemeral=False
|
||||
)
|
||||
@ -6327,7 +6316,7 @@ class TestServerRebuild(TestServer):
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.servers_mock.get.assert_called_with(self.server.id)
|
||||
self.get_image_mock.assert_called_with(self.image.id)
|
||||
self.image_client.get_image.assert_called_with(self.image.id)
|
||||
self.server.rebuild.assert_called_with(self.image, password)
|
||||
|
||||
def test_rebuild_with_description(self):
|
||||
@ -6343,7 +6332,7 @@ class TestServerRebuild(TestServer):
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.servers_mock.get.assert_called_with(self.server.id)
|
||||
self.get_image_mock.assert_called_with(self.image.id)
|
||||
self.image_client.get_image.assert_called_with(self.image.id)
|
||||
self.server.rebuild.assert_called_with(
|
||||
self.image, None, description=description
|
||||
)
|
||||
@ -6388,7 +6377,7 @@ class TestServerRebuild(TestServer):
|
||||
)
|
||||
|
||||
self.servers_mock.get.assert_called_with(self.server.id)
|
||||
self.get_image_mock.assert_called_with(self.image.id)
|
||||
self.image_client.get_image.assert_called_with(self.image.id)
|
||||
self.server.rebuild.assert_called_with(self.image, None)
|
||||
|
||||
@mock.patch.object(common_utils, 'wait_for_status', return_value=False)
|
||||
@ -6413,7 +6402,7 @@ class TestServerRebuild(TestServer):
|
||||
)
|
||||
|
||||
self.servers_mock.get.assert_called_with(self.server.id)
|
||||
self.get_image_mock.assert_called_with(self.image.id)
|
||||
self.image_client.get_image.assert_called_with(self.image.id)
|
||||
self.server.rebuild.assert_called_with(self.image, None)
|
||||
|
||||
@mock.patch.object(common_utils, 'wait_for_status', return_value=True)
|
||||
@ -6443,7 +6432,7 @@ class TestServerRebuild(TestServer):
|
||||
)
|
||||
|
||||
self.servers_mock.get.assert_called_with(self.server.id)
|
||||
self.get_image_mock.assert_called_with(self.image.id)
|
||||
self.image_client.get_image.assert_called_with(self.image.id)
|
||||
self.server.rebuild.assert_called_with(self.image, None)
|
||||
|
||||
@mock.patch.object(common_utils, 'wait_for_status', return_value=True)
|
||||
@ -6473,7 +6462,7 @@ class TestServerRebuild(TestServer):
|
||||
)
|
||||
|
||||
self.servers_mock.get.assert_called_with(self.server.id)
|
||||
self.get_image_mock.assert_called_with(self.image.id)
|
||||
self.image_client.get_image.assert_called_with(self.image.id)
|
||||
self.server.rebuild.assert_called_with(self.image, None)
|
||||
|
||||
def test_rebuild_wrong_status_fails(self):
|
||||
@ -6491,7 +6480,7 @@ class TestServerRebuild(TestServer):
|
||||
)
|
||||
|
||||
self.servers_mock.get.assert_called_with(self.server.id)
|
||||
self.get_image_mock.assert_called_with(self.image.id)
|
||||
self.image_client.get_image.assert_called_with(self.image.id)
|
||||
self.server.rebuild.assert_not_called()
|
||||
|
||||
def test_rebuild_with_property(self):
|
||||
@ -6513,7 +6502,7 @@ class TestServerRebuild(TestServer):
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.servers_mock.get.assert_called_with(self.server.id)
|
||||
self.get_image_mock.assert_called_with(self.image.id)
|
||||
self.image_client.get_image.assert_called_with(self.image.id)
|
||||
self.server.rebuild.assert_called_with(
|
||||
self.image, None, meta=expected_properties
|
||||
)
|
||||
@ -6538,7 +6527,7 @@ class TestServerRebuild(TestServer):
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.servers_mock.get.assert_called_with(self.server.id)
|
||||
self.get_image_mock.assert_called_with(self.image.id)
|
||||
self.image_client.get_image.assert_called_with(self.image.id)
|
||||
self.server.rebuild.assert_called_with(
|
||||
self.image, None, key_name=self.server.key_name
|
||||
)
|
||||
@ -6581,7 +6570,7 @@ class TestServerRebuild(TestServer):
|
||||
|
||||
self.cmd.take_action(parsed_args)
|
||||
self.servers_mock.get.assert_called_with(self.server.id)
|
||||
self.get_image_mock.assert_called_with(self.image.id)
|
||||
self.image_client.get_image.assert_called_with(self.image.id)
|
||||
self.server.rebuild.assert_called_with(self.image, None, key_name=None)
|
||||
|
||||
def test_rebuild_with_keypair_name_and_unset(self):
|
||||
@ -6634,7 +6623,7 @@ class TestServerRebuild(TestServer):
|
||||
mock_file.close.assert_called_with()
|
||||
|
||||
self.servers_mock.get.assert_called_with(self.server.id)
|
||||
self.get_image_mock.assert_called_with(self.image.id)
|
||||
self.image_client.get_image.assert_called_with(self.image.id)
|
||||
self.server.rebuild.assert_called_with(
|
||||
self.image,
|
||||
None,
|
||||
@ -6679,7 +6668,7 @@ class TestServerRebuild(TestServer):
|
||||
|
||||
self.cmd.take_action(parsed_args)
|
||||
self.servers_mock.get.assert_called_with(self.server.id)
|
||||
self.get_image_mock.assert_called_with(self.image.id)
|
||||
self.image_client.get_image.assert_called_with(self.image.id)
|
||||
self.server.rebuild.assert_called_with(self.image, None, userdata=None)
|
||||
|
||||
def test_rebuild_with_no_user_data_pre_v254(self):
|
||||
@ -6733,7 +6722,7 @@ class TestServerRebuild(TestServer):
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.servers_mock.get.assert_called_with(self.server.id)
|
||||
self.get_image_mock.assert_called_with(self.image.id)
|
||||
self.image_client.get_image.assert_called_with(self.image.id)
|
||||
self.server.rebuild.assert_called_with(
|
||||
self.image, None, trusted_image_certificates=['foo', 'bar']
|
||||
)
|
||||
@ -6777,7 +6766,7 @@ class TestServerRebuild(TestServer):
|
||||
|
||||
self.cmd.take_action(parsed_args)
|
||||
self.servers_mock.get.assert_called_with(self.server.id)
|
||||
self.get_image_mock.assert_called_with(self.image.id)
|
||||
self.image_client.get_image.assert_called_with(self.image.id)
|
||||
self.server.rebuild.assert_called_with(
|
||||
self.image, None, trusted_image_certificates=None
|
||||
)
|
||||
@ -6813,7 +6802,7 @@ class TestServerRebuild(TestServer):
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.servers_mock.get.assert_called_with(self.server.id)
|
||||
self.get_image_mock.assert_called_with(self.image.id)
|
||||
self.image_client.get_image.assert_called_with(self.image.id)
|
||||
self.server.rebuild.assert_called_with(
|
||||
self.image, None, hostname='new-hostname'
|
||||
)
|
||||
@ -6841,7 +6830,7 @@ class TestServerRebuildVolumeBacked(TestServer):
|
||||
super().setUp()
|
||||
|
||||
self.new_image = image_fakes.create_one_image()
|
||||
self.find_image_mock.return_value = self.new_image
|
||||
self.image_client.find_image.return_value = self.new_image
|
||||
|
||||
attrs = {
|
||||
'image': '',
|
||||
@ -6939,9 +6928,10 @@ class TestServerRebuildVolumeBacked(TestServer):
|
||||
class TestEvacuateServer(TestServer):
|
||||
def setUp(self):
|
||||
super(TestEvacuateServer, self).setUp()
|
||||
|
||||
# Return value for utils.find_resource for image
|
||||
self.image = image_fakes.create_one_image()
|
||||
self.images_mock.get.return_value = self.image
|
||||
self.image_client.get_image.return_value = self.image
|
||||
|
||||
# Fake the rebuilt new server.
|
||||
attrs = {
|
||||
@ -7137,7 +7127,7 @@ class TestServerRescue(TestServer):
|
||||
|
||||
# Return value for utils.find_resource for image
|
||||
self.image = image_fakes.create_one_image()
|
||||
self.get_image_mock.return_value = self.image
|
||||
self.image_client.get_image.return_value = self.image
|
||||
|
||||
new_server = compute_fakes.create_one_server()
|
||||
attrs = {
|
||||
@ -7178,7 +7168,7 @@ class TestServerRescue(TestServer):
|
||||
|
||||
def test_rescue_with_new_image(self):
|
||||
new_image = image_fakes.create_one_image()
|
||||
self.find_image_mock.return_value = new_image
|
||||
self.image_client.find_image.return_value = new_image
|
||||
arglist = [
|
||||
'--image',
|
||||
new_image.id,
|
||||
@ -7194,7 +7184,7 @@ class TestServerRescue(TestServer):
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.servers_mock.get.assert_called_with(self.server.id)
|
||||
self.find_image_mock.assert_called_with(new_image.id)
|
||||
self.image_client.find_image.assert_called_with(new_image.id)
|
||||
self.server.rescue.assert_called_with(image=new_image, password=None)
|
||||
|
||||
def test_rescue_with_current_image_and_password(self):
|
||||
@ -8278,7 +8268,7 @@ class TestServerShow(TestServer):
|
||||
|
||||
# This is the return value for utils.find_resource()
|
||||
self.sdk_client.get_server.return_value = self.server
|
||||
self.get_image_mock.return_value = self.image
|
||||
self.image_client.get_image.return_value = self.image
|
||||
self.flavors_mock.get.return_value = self.flavor
|
||||
|
||||
# Get the command object to test
|
||||
@ -9119,7 +9109,7 @@ class TestServerGeneral(TestServer):
|
||||
}
|
||||
_server = compute_fakes.create_one_server(attrs=server_info)
|
||||
find_resource.side_effect = [_server, _flavor]
|
||||
self.get_image_mock.return_value = _image
|
||||
self.image_client.get_image.return_value = _image
|
||||
|
||||
# Prepare result data.
|
||||
info = {
|
||||
@ -9139,7 +9129,7 @@ class TestServerGeneral(TestServer):
|
||||
# Call _prep_server_detail().
|
||||
server_detail = server._prep_server_detail(
|
||||
self.app.client_manager.compute,
|
||||
self.app.client_manager.image,
|
||||
self.image_client,
|
||||
_server,
|
||||
)
|
||||
# 'networks' is used to create _server. Remove it.
|
||||
|
@ -31,10 +31,6 @@ class TestServerBackup(compute_fakes.TestComputev2):
|
||||
self.app.client_manager.sdk_connection.compute = mock.Mock()
|
||||
self.sdk_client = self.app.client_manager.sdk_connection.compute
|
||||
|
||||
# Get a shortcut to the image client ImageManager Mock
|
||||
self.images_mock = self.app.client_manager.image
|
||||
self.images_mock.find_image.reset_mock()
|
||||
|
||||
# Set object attributes to be tested. Could be overwritten in subclass.
|
||||
self.attrs = {}
|
||||
|
||||
@ -102,8 +98,7 @@ class TestServerBackupCreate(TestServerBackup):
|
||||
count=count,
|
||||
)
|
||||
|
||||
# self.images_mock.get = mock.Mock(side_effect=images)
|
||||
self.images_mock.find_image = mock.Mock(side_effect=images)
|
||||
self.image_client.find_image = mock.Mock(side_effect=images)
|
||||
return images
|
||||
|
||||
def test_server_backup_defaults(self):
|
||||
@ -177,7 +172,7 @@ class TestServerBackupCreate(TestServerBackup):
|
||||
def test_server_backup_wait_fail(self, mock_wait_for_status):
|
||||
servers = self.setup_servers_mock(count=1)
|
||||
images = self.setup_images_mock(count=1, servers=servers)
|
||||
self.images_mock.get_image = mock.Mock(
|
||||
self.image_client.get_image = mock.Mock(
|
||||
side_effect=images[0],
|
||||
)
|
||||
|
||||
@ -211,7 +206,7 @@ class TestServerBackupCreate(TestServerBackup):
|
||||
)
|
||||
|
||||
mock_wait_for_status.assert_called_once_with(
|
||||
self.images_mock.get_image, images[0].id, callback=mock.ANY
|
||||
self.image_client.get_image, images[0].id, callback=mock.ANY
|
||||
)
|
||||
|
||||
@mock.patch.object(common_utils, 'wait_for_status', return_value=True)
|
||||
@ -219,7 +214,7 @@ class TestServerBackupCreate(TestServerBackup):
|
||||
servers = self.setup_servers_mock(count=1)
|
||||
images = self.setup_images_mock(count=1, servers=servers)
|
||||
|
||||
self.images_mock.get_image = mock.Mock(
|
||||
self.image_client.get_image = mock.Mock(
|
||||
side_effect=images[0],
|
||||
)
|
||||
|
||||
@ -252,7 +247,7 @@ class TestServerBackupCreate(TestServerBackup):
|
||||
)
|
||||
|
||||
mock_wait_for_status.assert_called_once_with(
|
||||
self.images_mock.get_image, images[0].id, callback=mock.ANY
|
||||
self.image_client.get_image, images[0].id, callback=mock.ANY
|
||||
)
|
||||
|
||||
self.assertEqual(self.image_columns(images[0]), columns)
|
||||
|
@ -30,10 +30,6 @@ class TestServerImage(compute_fakes.TestComputev2):
|
||||
self.app.client_manager.sdk_connection.compute = mock.Mock()
|
||||
self.sdk_client = self.app.client_manager.sdk_connection.compute
|
||||
|
||||
# Get a shortcut to the image client ImageManager Mock
|
||||
self.images_mock = self.app.client_manager.image
|
||||
self.images_mock.find_image.reset_mock()
|
||||
|
||||
# Set object attributes to be tested. Could be overwritten in subclass.
|
||||
self.attrs = {}
|
||||
|
||||
@ -100,7 +96,7 @@ class TestServerImageCreate(TestServerImage):
|
||||
count=count,
|
||||
)
|
||||
|
||||
self.images_mock.find_image = mock.Mock(side_effect=images)
|
||||
self.image_client.find_image = mock.Mock(side_effect=images)
|
||||
self.sdk_client.create_server_image = mock.Mock(
|
||||
return_value=images[0],
|
||||
)
|
||||
@ -192,7 +188,7 @@ class TestServerImageCreate(TestServerImage):
|
||||
)
|
||||
|
||||
mock_wait_for_status.assert_called_once_with(
|
||||
self.images_mock.get_image, images[0].id, callback=mock.ANY
|
||||
self.image_client.get_image, images[0].id, callback=mock.ANY
|
||||
)
|
||||
|
||||
@mock.patch.object(common_utils, 'wait_for_status', return_value=True)
|
||||
@ -222,7 +218,7 @@ class TestServerImageCreate(TestServerImage):
|
||||
)
|
||||
|
||||
mock_wait_for_status.assert_called_once_with(
|
||||
self.images_mock.get_image, images[0].id, callback=mock.ANY
|
||||
self.image_client.get_image, images[0].id, callback=mock.ANY
|
||||
)
|
||||
|
||||
self.assertEqual(self.image_columns(images[0]), columns)
|
||||
|
@ -27,14 +27,13 @@ class TestImagev1(utils.TestCommand):
|
||||
super().setUp()
|
||||
|
||||
self.app.client_manager.image = mock.Mock()
|
||||
self.image_client = self.app.client_manager.image
|
||||
|
||||
self.app.client_manager.volume = volume_fakes.FakeVolumev1Client(
|
||||
endpoint=fakes.AUTH_URL,
|
||||
token=fakes.AUTH_TOKEN,
|
||||
)
|
||||
|
||||
self.client = self.app.client_manager.image
|
||||
|
||||
|
||||
def create_one_image(attrs=None):
|
||||
"""Create a fake image.
|
||||
|
@ -11,7 +11,6 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
import copy
|
||||
from unittest import mock
|
||||
@ -23,11 +22,7 @@ from openstackclient.tests.unit import fakes
|
||||
from openstackclient.tests.unit.image.v1 import fakes as image_fakes
|
||||
|
||||
|
||||
class TestImage(image_fakes.TestImagev1):
|
||||
pass
|
||||
|
||||
|
||||
class TestImageCreate(TestImage):
|
||||
class TestImageCreate(image_fakes.TestImagev1):
|
||||
new_image = image_fakes.create_one_image()
|
||||
columns = (
|
||||
'container_format',
|
||||
@ -59,9 +54,9 @@ class TestImageCreate(TestImage):
|
||||
def setUp(self):
|
||||
super(TestImageCreate, self).setUp()
|
||||
|
||||
self.client.create_image = mock.Mock(return_value=self.new_image)
|
||||
self.client.find_image = mock.Mock(return_value=self.new_image)
|
||||
self.client.update_image = mock.Mock(return_image=self.new_image)
|
||||
self.image_client.create_image = mock.Mock(return_value=self.new_image)
|
||||
self.image_client.find_image = mock.Mock(return_value=self.new_image)
|
||||
self.image_client.update_image = mock.Mock(return_image=self.new_image)
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = image.CreateImage(self.app, None)
|
||||
@ -84,14 +79,14 @@ class TestImageCreate(TestImage):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
# ImageManager.create(name=, **)
|
||||
self.client.create_image.assert_called_with(
|
||||
self.image_client.create_image.assert_called_with(
|
||||
name=self.new_image.name,
|
||||
container_format=image.DEFAULT_CONTAINER_FORMAT,
|
||||
disk_format=image.DEFAULT_DISK_FORMAT,
|
||||
)
|
||||
|
||||
# Verify update() was not called, if it was show the args
|
||||
self.assertEqual(self.client.update_image.call_args_list, [])
|
||||
self.assertEqual(self.image_client.update_image.call_args_list, [])
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertCountEqual(self.data, data)
|
||||
@ -133,7 +128,7 @@ class TestImageCreate(TestImage):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
# ImageManager.create(name=, **)
|
||||
self.client.create_image.assert_called_with(
|
||||
self.image_client.create_image.assert_called_with(
|
||||
name=self.new_image.name,
|
||||
container_format='ovf',
|
||||
disk_format='ami',
|
||||
@ -145,7 +140,7 @@ class TestImageCreate(TestImage):
|
||||
)
|
||||
|
||||
# Verify update() was not called, if it was show the args
|
||||
self.assertEqual(self.client.update_image.call_args_list, [])
|
||||
self.assertEqual(self.image_client.update_image.call_args_list, [])
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertCountEqual(self.data, data)
|
||||
@ -190,7 +185,7 @@ class TestImageCreate(TestImage):
|
||||
mock_file.close.assert_called_with()
|
||||
|
||||
# ImageManager.create(name=, **)
|
||||
self.client.create_image.assert_called_with(
|
||||
self.image_client.create_image.assert_called_with(
|
||||
name=self.new_image.name,
|
||||
container_format=image.DEFAULT_CONTAINER_FORMAT,
|
||||
disk_format=image.DEFAULT_DISK_FORMAT,
|
||||
@ -204,21 +199,21 @@ class TestImageCreate(TestImage):
|
||||
)
|
||||
|
||||
# Verify update() was not called, if it was show the args
|
||||
self.assertEqual(self.client.update_image.call_args_list, [])
|
||||
self.assertEqual(self.image_client.update_image.call_args_list, [])
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertCountEqual(self.data, data)
|
||||
|
||||
|
||||
class TestImageDelete(TestImage):
|
||||
class TestImageDelete(image_fakes.TestImagev1):
|
||||
_image = image_fakes.create_one_image()
|
||||
|
||||
def setUp(self):
|
||||
super(TestImageDelete, self).setUp()
|
||||
|
||||
# This is the return value for utils.find_resource()
|
||||
self.client.find_image = mock.Mock(return_value=self._image)
|
||||
self.client.delete_image = mock.Mock(return_value=None)
|
||||
self.image_client.find_image = mock.Mock(return_value=self._image)
|
||||
self.image_client.delete_image = mock.Mock(return_value=None)
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = image.DeleteImage(self.app, None)
|
||||
@ -234,11 +229,11 @@ class TestImageDelete(TestImage):
|
||||
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.client.delete_image.assert_called_with(self._image.id)
|
||||
self.image_client.delete_image.assert_called_with(self._image.id)
|
||||
self.assertIsNone(result)
|
||||
|
||||
|
||||
class TestImageList(TestImage):
|
||||
class TestImageList(image_fakes.TestImagev1):
|
||||
_image = image_fakes.create_one_image()
|
||||
|
||||
columns = (
|
||||
@ -266,8 +261,8 @@ class TestImageList(TestImage):
|
||||
def setUp(self):
|
||||
super(TestImageList, self).setUp()
|
||||
|
||||
self.client.images = mock.Mock()
|
||||
self.client.images.side_effect = [
|
||||
self.image_client.images = mock.Mock()
|
||||
self.image_client.images.side_effect = [
|
||||
[self._image],
|
||||
[],
|
||||
]
|
||||
@ -288,7 +283,7 @@ class TestImageList(TestImage):
|
||||
# returns a tuple containing the column names and an iterable
|
||||
# containing the data to be listed.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.client.images.assert_called_with()
|
||||
self.image_client.images.assert_called_with()
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.datalist, tuple(data))
|
||||
@ -308,7 +303,7 @@ class TestImageList(TestImage):
|
||||
# returns a tuple containing the column names and an iterable
|
||||
# containing the data to be listed.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.client.images.assert_called_with(
|
||||
self.image_client.images.assert_called_with(
|
||||
is_public=True,
|
||||
)
|
||||
|
||||
@ -330,7 +325,7 @@ class TestImageList(TestImage):
|
||||
# returns a tuple containing the column names and an iterable
|
||||
# containing the data to be listed.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.client.images.assert_called_with(
|
||||
self.image_client.images.assert_called_with(
|
||||
is_private=True,
|
||||
)
|
||||
|
||||
@ -350,7 +345,7 @@ class TestImageList(TestImage):
|
||||
# returns a tuple containing the column names and an iterable
|
||||
# containing the data to be listed.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.client.images.assert_called_with()
|
||||
self.image_client.images.assert_called_with()
|
||||
|
||||
collist = (
|
||||
'ID',
|
||||
@ -406,7 +401,7 @@ class TestImageList(TestImage):
|
||||
# returns a tuple containing the column names and an iterable
|
||||
# containing the data to be listed.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.client.images.assert_called_with()
|
||||
self.image_client.images.assert_called_with()
|
||||
sf_mock.assert_called_with(
|
||||
[self._image],
|
||||
attr='a',
|
||||
@ -432,22 +427,22 @@ class TestImageList(TestImage):
|
||||
# returns a tuple containing the column names and an iterable
|
||||
# containing the data to be listed.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.client.images.assert_called_with()
|
||||
self.image_client.images.assert_called_with()
|
||||
si_mock.assert_called_with([self._image], 'name:asc')
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.datalist, tuple(data))
|
||||
|
||||
|
||||
class TestImageSet(TestImage):
|
||||
class TestImageSet(image_fakes.TestImagev1):
|
||||
_image = image_fakes.create_one_image()
|
||||
|
||||
def setUp(self):
|
||||
super(TestImageSet, self).setUp()
|
||||
|
||||
# This is the return value for utils.find_resource()
|
||||
self.client.find_image = mock.Mock(return_value=self._image)
|
||||
self.client.update_image = mock.Mock(return_value=self._image)
|
||||
self.image_client.find_image = mock.Mock(return_value=self._image)
|
||||
self.image_client.update_image = mock.Mock(return_value=self._image)
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = image.SetImage(self.app, None)
|
||||
@ -463,7 +458,7 @@ class TestImageSet(TestImage):
|
||||
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.client.update_image.assert_called_with(self._image.id, **{})
|
||||
self.image_client.update_image.assert_called_with(self._image.id, **{})
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_image_set_options(self):
|
||||
@ -508,7 +503,9 @@ class TestImageSet(TestImage):
|
||||
'size': 35165824,
|
||||
}
|
||||
# ImageManager.update(image, **kwargs)
|
||||
self.client.update_image.assert_called_with(self._image.id, **kwargs)
|
||||
self.image_client.update_image.assert_called_with(
|
||||
self._image.id, **kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_image_set_bools1(self):
|
||||
@ -533,7 +530,9 @@ class TestImageSet(TestImage):
|
||||
'is_public': False,
|
||||
}
|
||||
# ImageManager.update(image, **kwargs)
|
||||
self.client.update_image.assert_called_with(self._image.id, **kwargs)
|
||||
self.image_client.update_image.assert_called_with(
|
||||
self._image.id, **kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_image_set_bools2(self):
|
||||
@ -558,7 +557,9 @@ class TestImageSet(TestImage):
|
||||
'is_public': True,
|
||||
}
|
||||
# ImageManager.update(image, **kwargs)
|
||||
self.client.update_image.assert_called_with(self._image.id, **kwargs)
|
||||
self.image_client.update_image.assert_called_with(
|
||||
self._image.id, **kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_image_set_properties(self):
|
||||
@ -585,7 +586,9 @@ class TestImageSet(TestImage):
|
||||
},
|
||||
}
|
||||
# ImageManager.update(image, **kwargs)
|
||||
self.client.update_image.assert_called_with(self._image.id, **kwargs)
|
||||
self.image_client.update_image.assert_called_with(
|
||||
self._image.id, **kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_image_update_volume(self):
|
||||
@ -642,7 +645,7 @@ class TestImageSet(TestImage):
|
||||
'',
|
||||
)
|
||||
# ImageManager.update(image_id, remove_props=, **)
|
||||
self.client.update_image.assert_called_with(
|
||||
self.image_client.update_image.assert_called_with(
|
||||
self._image.id,
|
||||
name='updated_image',
|
||||
volume='volly',
|
||||
@ -671,11 +674,13 @@ class TestImageSet(TestImage):
|
||||
'min_ram': 0,
|
||||
}
|
||||
# ImageManager.update(image, **kwargs)
|
||||
self.client.update_image.assert_called_with(self._image.id, **kwargs)
|
||||
self.image_client.update_image.assert_called_with(
|
||||
self._image.id, **kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
|
||||
class TestImageShow(TestImage):
|
||||
class TestImageShow(image_fakes.TestImagev1):
|
||||
_image = image_fakes.create_one_image(attrs={'size': 2000})
|
||||
columns = (
|
||||
'container_format',
|
||||
@ -707,7 +712,7 @@ class TestImageShow(TestImage):
|
||||
def setUp(self):
|
||||
super(TestImageShow, self).setUp()
|
||||
|
||||
self.client.find_image = mock.Mock(return_value=self._image)
|
||||
self.image_client.find_image = mock.Mock(return_value=self._image)
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = image.ShowImage(self.app, None)
|
||||
@ -725,7 +730,7 @@ class TestImageShow(TestImage):
|
||||
# returns a two-part tuple with a tuple of column names and a tuple of
|
||||
# data to be shown.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.client.find_image.assert_called_with(
|
||||
self.image_client.find_image.assert_called_with(
|
||||
self._image.id,
|
||||
)
|
||||
|
||||
@ -747,7 +752,7 @@ class TestImageShow(TestImage):
|
||||
# returns a two-part tuple with a tuple of column names and a tuple of
|
||||
# data to be shown.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.client.find_image.assert_called_with(
|
||||
self.image_client.find_image.assert_called_with(
|
||||
self._image.id,
|
||||
)
|
||||
|
||||
|
@ -33,6 +33,7 @@ class TestImagev2(utils.TestCommand):
|
||||
super().setUp()
|
||||
|
||||
self.app.client_manager.image = mock.Mock()
|
||||
self.image_client = self.app.client_manager.image
|
||||
|
||||
self.app.client_manager.identity = identity_fakes.FakeIdentityv3Client(
|
||||
endpoint=fakes.AUTH_URL,
|
||||
@ -231,34 +232,6 @@ def create_tasks(attrs=None, count=2):
|
||||
return tasks
|
||||
|
||||
|
||||
class FakeMetadefNamespaceClient:
|
||||
def __init__(self, **kwargs):
|
||||
self.create_metadef_namespace = mock.Mock()
|
||||
self.delete_metadef_namespace = mock.Mock()
|
||||
self.metadef_namespaces = mock.Mock()
|
||||
self.get_metadef_namespace = mock.Mock()
|
||||
self.update_metadef_namespace = mock.Mock()
|
||||
|
||||
self.auth_token = kwargs['token']
|
||||
self.management_url = kwargs['endpoint']
|
||||
self.version = 2.0
|
||||
|
||||
|
||||
class TestMetadefNamespaces(utils.TestCommand):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.app.client_manager.image = FakeMetadefNamespaceClient(
|
||||
endpoint=fakes.AUTH_URL,
|
||||
token=fakes.AUTH_TOKEN,
|
||||
)
|
||||
|
||||
self.app.client_manager.identity = identity_fakes.FakeIdentityv3Client(
|
||||
endpoint=fakes.AUTH_URL,
|
||||
token=fakes.AUTH_TOKEN,
|
||||
)
|
||||
|
||||
|
||||
def create_one_metadef_namespace(attrs=None):
|
||||
"""Create a fake MetadefNamespace member.
|
||||
|
||||
|
@ -32,9 +32,6 @@ class TestImage(image_fakes.TestImagev2, volume_fakes.TestVolume):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
# Get shortcuts to mocked image client
|
||||
self.client = self.app.client_manager.image
|
||||
|
||||
# Get shortcut to the Mocks in identity client
|
||||
self.project_mock = self.app.client_manager.identity.projects
|
||||
self.project_mock.reset_mock()
|
||||
@ -61,14 +58,13 @@ class TestImageCreate(TestImage):
|
||||
super().setUp()
|
||||
|
||||
self.new_image = image_fakes.create_one_image()
|
||||
self.client.create_image.return_value = self.new_image
|
||||
self.image_client.create_image.return_value = self.new_image
|
||||
self.image_client.update_image.return_value = self.new_image
|
||||
|
||||
self.project_mock.get.return_value = self.project
|
||||
|
||||
self.domain_mock.get.return_value = self.domain
|
||||
|
||||
self.client.update_image.return_value = self.new_image
|
||||
|
||||
(self.expected_columns, self.expected_data) = zip(
|
||||
*sorted(_image._format_image(self.new_image).items())
|
||||
)
|
||||
@ -92,7 +88,7 @@ class TestImageCreate(TestImage):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
# ImageManager.create(name=, **)
|
||||
self.client.create_image.assert_called_with(
|
||||
self.image_client.create_image.assert_called_with(
|
||||
name=self.new_image.name,
|
||||
allow_duplicates=True,
|
||||
container_format=_image.DEFAULT_CONTAINER_FORMAT,
|
||||
@ -144,7 +140,7 @@ class TestImageCreate(TestImage):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
# ImageManager.create(name=, **)
|
||||
self.client.create_image.assert_called_with(
|
||||
self.image_client.create_image.assert_called_with(
|
||||
name=self.new_image.name,
|
||||
allow_duplicates=True,
|
||||
container_format='ovf',
|
||||
@ -240,7 +236,7 @@ class TestImageCreate(TestImage):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
# ImageManager.create(name=, **)
|
||||
self.client.create_image.assert_called_with(
|
||||
self.image_client.create_image.assert_called_with(
|
||||
name=self.new_image.name,
|
||||
allow_duplicates=True,
|
||||
container_format=_image.DEFAULT_CONTAINER_FORMAT,
|
||||
@ -276,7 +272,7 @@ class TestImageCreate(TestImage):
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.client.create_image.assert_called_with(
|
||||
self.image_client.create_image.assert_called_with(
|
||||
name=self.new_image.name,
|
||||
allow_duplicates=True,
|
||||
container_format=_image.DEFAULT_CONTAINER_FORMAT,
|
||||
@ -317,7 +313,7 @@ class TestImageCreate(TestImage):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
# ImageManager.create(name=, **)
|
||||
self.client.create_image.assert_called_with(
|
||||
self.image_client.create_image.assert_called_with(
|
||||
name=self.new_image.name,
|
||||
allow_duplicates=True,
|
||||
container_format=_image.DEFAULT_CONTAINER_FORMAT,
|
||||
@ -439,10 +435,10 @@ class TestAddProjectToImage(TestImage):
|
||||
super().setUp()
|
||||
|
||||
# This is the return value for utils.find_resource()
|
||||
self.client.find_image.return_value = self._image
|
||||
self.image_client.find_image.return_value = self._image
|
||||
|
||||
# Update the image_id in the MEMBER dict
|
||||
self.client.add_member.return_value = self.new_member
|
||||
self.image_client.add_member.return_value = self.new_member
|
||||
self.project_mock.get.return_value = self.project
|
||||
self.domain_mock.get.return_value = self.domain
|
||||
# Get the command object to test
|
||||
@ -463,7 +459,7 @@ class TestAddProjectToImage(TestImage):
|
||||
# returns a two-part tuple with a tuple of column names and a tuple of
|
||||
# data to be shown.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.client.add_member.assert_called_with(
|
||||
self.image_client.add_member.assert_called_with(
|
||||
image=self._image.id, member_id=self.project.id
|
||||
)
|
||||
|
||||
@ -488,7 +484,7 @@ class TestAddProjectToImage(TestImage):
|
||||
# returns a two-part tuple with a tuple of column names and a tuple of
|
||||
# data to be shown.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.client.add_member.assert_called_with(
|
||||
self.image_client.add_member.assert_called_with(
|
||||
image=self._image.id, member_id=self.project.id
|
||||
)
|
||||
|
||||
@ -500,7 +496,7 @@ class TestImageDelete(TestImage):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.client.delete_image.return_value = None
|
||||
self.image_client.delete_image.return_value = None
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = _image.DeleteImage(self.app, None)
|
||||
@ -516,11 +512,11 @@ class TestImageDelete(TestImage):
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
self.client.find_image.side_effect = images
|
||||
self.image_client.find_image.side_effect = images
|
||||
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.client.delete_image.assert_called_with(
|
||||
self.image_client.delete_image.assert_called_with(
|
||||
images[0].id, store=parsed_args.store, ignore_missing=False
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
@ -536,11 +532,11 @@ class TestImageDelete(TestImage):
|
||||
verifylist = [('images', [images[0].id]), ('store', 'store1')]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
self.client.find_image.side_effect = images
|
||||
self.image_client.find_image.side_effect = images
|
||||
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.client.delete_image.assert_called_with(
|
||||
self.image_client.delete_image.assert_called_with(
|
||||
images[0].id, store=parsed_args.store, ignore_missing=False
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
@ -554,7 +550,7 @@ class TestImageDelete(TestImage):
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
self.client.find_image.side_effect = images
|
||||
self.image_client.find_image.side_effect = images
|
||||
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
|
||||
@ -562,7 +558,7 @@ class TestImageDelete(TestImage):
|
||||
mock.call(i.id, store=parsed_args.store, ignore_missing=False)
|
||||
for i in images
|
||||
]
|
||||
self.client.delete_image.assert_has_calls(calls)
|
||||
self.image_client.delete_image.assert_has_calls(calls)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_image_delete_from_store_without_multi_backend(self):
|
||||
@ -572,9 +568,11 @@ class TestImageDelete(TestImage):
|
||||
verifylist = [('images', [images[0].id]), ('store', 'store1')]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
self.client.find_image.side_effect = images
|
||||
self.image_client.find_image.side_effect = images
|
||||
|
||||
self.client.delete_image.side_effect = sdk_exceptions.ResourceNotFound
|
||||
self.image_client.delete_image.side_effect = (
|
||||
sdk_exceptions.ResourceNotFound
|
||||
)
|
||||
exc = self.assertRaises(
|
||||
exceptions.CommandError,
|
||||
self.cmd.take_action,
|
||||
@ -602,7 +600,7 @@ class TestImageDelete(TestImage):
|
||||
# And fake find() to find the real network or not.
|
||||
ret_find = [images[0], images[1], sdk_exceptions.ResourceNotFound()]
|
||||
|
||||
self.client.find_image.side_effect = ret_find
|
||||
self.image_client.find_image.side_effect = ret_find
|
||||
|
||||
self.assertRaises(
|
||||
exceptions.CommandError, self.cmd.take_action, parsed_args
|
||||
@ -611,7 +609,7 @@ class TestImageDelete(TestImage):
|
||||
mock.call(i.id, store=parsed_args.store, ignore_missing=False)
|
||||
for i in images
|
||||
]
|
||||
self.client.delete_image.assert_has_calls(calls)
|
||||
self.image_client.delete_image.assert_has_calls(calls)
|
||||
|
||||
|
||||
class TestImageList(TestImage):
|
||||
@ -634,7 +632,7 @@ class TestImageList(TestImage):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.client.images.side_effect = [[self._image], []]
|
||||
self.image_client.images.side_effect = [[self._image], []]
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = _image.ListImage(self.app, None)
|
||||
@ -651,7 +649,7 @@ class TestImageList(TestImage):
|
||||
# returns a tuple containing the column names and an iterable
|
||||
# containing the data to be listed.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.client.images.assert_called_with(
|
||||
self.image_client.images.assert_called_with(
|
||||
# marker=self._image.id,
|
||||
)
|
||||
|
||||
@ -672,7 +670,7 @@ class TestImageList(TestImage):
|
||||
# returns a tuple containing the column names and an iterable
|
||||
# containing the data to be listed.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.client.images.assert_called_with(
|
||||
self.image_client.images.assert_called_with(
|
||||
visibility='public',
|
||||
)
|
||||
|
||||
@ -693,7 +691,7 @@ class TestImageList(TestImage):
|
||||
# returns a tuple containing the column names and an iterable
|
||||
# containing the data to be listed.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.client.images.assert_called_with(
|
||||
self.image_client.images.assert_called_with(
|
||||
visibility='private',
|
||||
)
|
||||
|
||||
@ -714,7 +712,7 @@ class TestImageList(TestImage):
|
||||
# returns a tuple containing the column names and an iterable
|
||||
# containing the data to be listed.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.client.images.assert_called_with(
|
||||
self.image_client.images.assert_called_with(
|
||||
visibility='community',
|
||||
)
|
||||
|
||||
@ -735,7 +733,7 @@ class TestImageList(TestImage):
|
||||
# returns a tuple containing the column names and an iterable
|
||||
# containing the data to be listed.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.client.images.assert_called_with(
|
||||
self.image_client.images.assert_called_with(
|
||||
visibility='shared',
|
||||
)
|
||||
|
||||
@ -756,7 +754,7 @@ class TestImageList(TestImage):
|
||||
# returns a tuple containing the column names and an iterable
|
||||
# containing the data to be listed.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.client.images.assert_called_with(
|
||||
self.image_client.images.assert_called_with(
|
||||
visibility='all',
|
||||
)
|
||||
|
||||
@ -776,7 +774,7 @@ class TestImageList(TestImage):
|
||||
# returns a tuple containing the column names and an iterable
|
||||
# containing the data to be listed.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.client.images.assert_called_with(
|
||||
self.image_client.images.assert_called_with(
|
||||
visibility='shared',
|
||||
member_status='all',
|
||||
)
|
||||
@ -806,7 +804,7 @@ class TestImageList(TestImage):
|
||||
# returns a tuple containing the column names and an iterable
|
||||
# containing the data to be listed.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.client.images.assert_called_with()
|
||||
self.image_client.images.assert_called_with()
|
||||
|
||||
collist = (
|
||||
'ID',
|
||||
@ -857,7 +855,7 @@ class TestImageList(TestImage):
|
||||
# returns a tuple containing the column names and an iterable
|
||||
# containing the data to be listed.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.client.images.assert_called_with()
|
||||
self.image_client.images.assert_called_with()
|
||||
sf_mock.assert_called_with(
|
||||
[self._image],
|
||||
attr='a',
|
||||
@ -880,7 +878,7 @@ class TestImageList(TestImage):
|
||||
# returns a tuple containing the column names and an iterable
|
||||
# containing the data to be listed.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.client.images.assert_called_with()
|
||||
self.image_client.images.assert_called_with()
|
||||
si_mock.assert_called_with(
|
||||
[self._image],
|
||||
'name:asc',
|
||||
@ -901,7 +899,7 @@ class TestImageList(TestImage):
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.client.images.assert_called_with(
|
||||
self.image_client.images.assert_called_with(
|
||||
limit=ret_limit,
|
||||
paginated=False
|
||||
# marker=None
|
||||
@ -911,7 +909,7 @@ class TestImageList(TestImage):
|
||||
self.assertEqual(ret_limit, len(tuple(data)))
|
||||
|
||||
def test_image_list_project_option(self):
|
||||
self.client.find_image = mock.Mock(return_value=self._image)
|
||||
self.image_client.find_image = mock.Mock(return_value=self._image)
|
||||
arglist = [
|
||||
'--project',
|
||||
'nova',
|
||||
@ -928,7 +926,7 @@ class TestImageList(TestImage):
|
||||
|
||||
@mock.patch('osc_lib.utils.find_resource')
|
||||
def test_image_list_marker_option(self, fr_mock):
|
||||
self.client.find_image = mock.Mock(return_value=self._image)
|
||||
self.image_client.find_image = mock.Mock(return_value=self._image)
|
||||
|
||||
arglist = [
|
||||
'--marker',
|
||||
@ -940,11 +938,11 @@ class TestImageList(TestImage):
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.client.images.assert_called_with(
|
||||
self.image_client.images.assert_called_with(
|
||||
marker=self._image.id,
|
||||
)
|
||||
|
||||
self.client.find_image.assert_called_with(
|
||||
self.image_client.find_image.assert_called_with(
|
||||
'graven',
|
||||
ignore_missing=False,
|
||||
)
|
||||
@ -960,7 +958,7 @@ class TestImageList(TestImage):
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.client.images.assert_called_with(
|
||||
self.image_client.images.assert_called_with(
|
||||
name='abc',
|
||||
# marker=self._image.id
|
||||
)
|
||||
@ -976,7 +974,7 @@ class TestImageList(TestImage):
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.client.images.assert_called_with(status='active')
|
||||
self.image_client.images.assert_called_with(status='active')
|
||||
|
||||
def test_image_list_hidden_option(self):
|
||||
arglist = [
|
||||
@ -988,7 +986,7 @@ class TestImageList(TestImage):
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.client.images.assert_called_with(is_hidden=True)
|
||||
self.image_client.images.assert_called_with(is_hidden=True)
|
||||
|
||||
def test_image_list_tag_option(self):
|
||||
arglist = ['--tag', 'abc', '--tag', 'cba']
|
||||
@ -998,7 +996,7 @@ class TestImageList(TestImage):
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.client.images.assert_called_with(tag=['abc', 'cba'])
|
||||
self.image_client.images.assert_called_with(tag=['abc', 'cba'])
|
||||
|
||||
|
||||
class TestListImageProjects(TestImage):
|
||||
@ -1021,8 +1019,8 @@ class TestListImageProjects(TestImage):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.client.find_image.return_value = self._image
|
||||
self.client.members.return_value = [self.member]
|
||||
self.image_client.find_image.return_value = self._image
|
||||
self.image_client.members.return_value = [self.member]
|
||||
|
||||
self.cmd = _image.ListImageProjects(self.app, None)
|
||||
|
||||
@ -1033,7 +1031,7 @@ class TestListImageProjects(TestImage):
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.client.members.assert_called_with(image=self._image.id)
|
||||
self.image_client.members.assert_called_with(image=self._image.id)
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.datalist, list(data))
|
||||
@ -1048,11 +1046,11 @@ class TestRemoveProjectImage(TestImage):
|
||||
|
||||
self._image = image_fakes.create_one_image()
|
||||
# This is the return value for utils.find_resource()
|
||||
self.client.find_image.return_value = self._image
|
||||
self.image_client.find_image.return_value = self._image
|
||||
|
||||
self.project_mock.get.return_value = self.project
|
||||
self.domain_mock.get.return_value = self.domain
|
||||
self.client.remove_member.return_value = None
|
||||
self.image_client.remove_member.return_value = None
|
||||
# Get the command object to test
|
||||
self.cmd = _image.RemoveProjectImage(self.app, None)
|
||||
|
||||
@ -1069,11 +1067,11 @@ class TestRemoveProjectImage(TestImage):
|
||||
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.client.find_image.assert_called_with(
|
||||
self.image_client.find_image.assert_called_with(
|
||||
self._image.id, ignore_missing=False
|
||||
)
|
||||
|
||||
self.client.remove_member.assert_called_with(
|
||||
self.image_client.remove_member.assert_called_with(
|
||||
member=self.project.id,
|
||||
image=self._image.id,
|
||||
)
|
||||
@ -1095,7 +1093,7 @@ class TestRemoveProjectImage(TestImage):
|
||||
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.client.remove_member.assert_called_with(
|
||||
self.image_client.remove_member.assert_called_with(
|
||||
member=self.project.id,
|
||||
image=self._image.id,
|
||||
)
|
||||
@ -1114,7 +1112,7 @@ class TestImageSet(TestImage):
|
||||
|
||||
self.domain_mock.get.return_value = self.domain
|
||||
|
||||
self.client.find_image.return_value = self._image
|
||||
self.image_client.find_image.return_value = self._image
|
||||
|
||||
self.app.client_manager.auth_ref = mock.Mock(
|
||||
project_id=self.project.id,
|
||||
@ -1145,7 +1143,7 @@ class TestImageSet(TestImage):
|
||||
'member_id': self.project.id,
|
||||
}
|
||||
)
|
||||
self.client.update_member.return_value = membership
|
||||
self.image_client.update_member.return_value = membership
|
||||
|
||||
arglist = [
|
||||
'--accept',
|
||||
@ -1156,7 +1154,7 @@ class TestImageSet(TestImage):
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.client.update_member.assert_called_once_with(
|
||||
self.image_client.update_member.assert_called_once_with(
|
||||
image=self._image.id,
|
||||
member=self.app.client_manager.auth_ref.project_id,
|
||||
status='accepted',
|
||||
@ -1164,7 +1162,7 @@ class TestImageSet(TestImage):
|
||||
|
||||
# Assert that the 'update image" route is also called, in addition to
|
||||
# the 'update membership' route.
|
||||
self.client.update_image.assert_called_with(self._image.id)
|
||||
self.image_client.update_image.assert_called_with(self._image.id)
|
||||
|
||||
def test_image_set_membership_option_reject(self):
|
||||
membership = image_fakes.create_one_image_member(
|
||||
@ -1173,7 +1171,7 @@ class TestImageSet(TestImage):
|
||||
'member_id': self.project.id,
|
||||
}
|
||||
)
|
||||
self.client.update_member.return_value = membership
|
||||
self.image_client.update_member.return_value = membership
|
||||
|
||||
arglist = [
|
||||
'--reject',
|
||||
@ -1187,7 +1185,7 @@ class TestImageSet(TestImage):
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.client.update_member.assert_called_once_with(
|
||||
self.image_client.update_member.assert_called_once_with(
|
||||
image=self._image.id,
|
||||
member=self.app.client_manager.auth_ref.project_id,
|
||||
status='rejected',
|
||||
@ -1195,7 +1193,7 @@ class TestImageSet(TestImage):
|
||||
|
||||
# Assert that the 'update image" route is also called, in addition to
|
||||
# the 'update membership' route.
|
||||
self.client.update_image.assert_called_with(self._image.id)
|
||||
self.image_client.update_image.assert_called_with(self._image.id)
|
||||
|
||||
def test_image_set_membership_option_pending(self):
|
||||
membership = image_fakes.create_one_image_member(
|
||||
@ -1204,7 +1202,7 @@ class TestImageSet(TestImage):
|
||||
'member_id': self.project.id,
|
||||
}
|
||||
)
|
||||
self.client.update_member.return_value = membership
|
||||
self.image_client.update_member.return_value = membership
|
||||
|
||||
arglist = [
|
||||
'--pending',
|
||||
@ -1218,7 +1216,7 @@ class TestImageSet(TestImage):
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.client.update_member.assert_called_once_with(
|
||||
self.image_client.update_member.assert_called_once_with(
|
||||
image=self._image.id,
|
||||
member=self.app.client_manager.auth_ref.project_id,
|
||||
status='pending',
|
||||
@ -1226,7 +1224,7 @@ class TestImageSet(TestImage):
|
||||
|
||||
# Assert that the 'update image" route is also called, in addition to
|
||||
# the 'update membership' route.
|
||||
self.client.update_image.assert_called_with(self._image.id)
|
||||
self.image_client.update_image.assert_called_with(self._image.id)
|
||||
|
||||
def test_image_set_options(self):
|
||||
arglist = [
|
||||
@ -1269,7 +1267,9 @@ class TestImageSet(TestImage):
|
||||
'disk_format': 'vmdk',
|
||||
}
|
||||
# ImageManager.update(image, **kwargs)
|
||||
self.client.update_image.assert_called_with(self._image.id, **kwargs)
|
||||
self.image_client.update_image.assert_called_with(
|
||||
self._image.id, **kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_image_set_with_unexist_project(self):
|
||||
@ -1311,7 +1311,9 @@ class TestImageSet(TestImage):
|
||||
'visibility': 'private',
|
||||
}
|
||||
# ImageManager.update(image, **kwargs)
|
||||
self.client.update_image.assert_called_with(self._image.id, **kwargs)
|
||||
self.image_client.update_image.assert_called_with(
|
||||
self._image.id, **kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_image_set_bools2(self):
|
||||
@ -1334,7 +1336,9 @@ class TestImageSet(TestImage):
|
||||
'visibility': 'public',
|
||||
}
|
||||
# ImageManager.update(image, **kwargs)
|
||||
self.client.update_image.assert_called_with(self._image.id, **kwargs)
|
||||
self.image_client.update_image.assert_called_with(
|
||||
self._image.id, **kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_image_set_properties(self):
|
||||
@ -1358,7 +1362,9 @@ class TestImageSet(TestImage):
|
||||
'Beta': '2',
|
||||
}
|
||||
# ImageManager.update(image, **kwargs)
|
||||
self.client.update_image.assert_called_with(self._image.id, **kwargs)
|
||||
self.image_client.update_image.assert_called_with(
|
||||
self._image.id, **kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_image_set_fake_properties(self):
|
||||
@ -1399,7 +1405,9 @@ class TestImageSet(TestImage):
|
||||
'ramdisk_id': 'xyzpdq',
|
||||
}
|
||||
# ImageManager.update(image, **kwargs)
|
||||
self.client.update_image.assert_called_with(self._image.id, **kwargs)
|
||||
self.image_client.update_image.assert_called_with(
|
||||
self._image.id, **kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_image_set_tag(self):
|
||||
@ -1420,7 +1428,9 @@ class TestImageSet(TestImage):
|
||||
'tags': ['test-tag'],
|
||||
}
|
||||
# ImageManager.update(image, **kwargs)
|
||||
self.client.update_image.assert_called_with(self._image.id, **kwargs)
|
||||
self.image_client.update_image.assert_called_with(
|
||||
self._image.id, **kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_image_set_activate(self):
|
||||
@ -1442,11 +1452,13 @@ class TestImageSet(TestImage):
|
||||
'tags': ['test-tag'],
|
||||
}
|
||||
|
||||
self.client.reactivate_image.assert_called_with(
|
||||
self.image_client.reactivate_image.assert_called_with(
|
||||
self._image.id,
|
||||
)
|
||||
# ImageManager.update(image, **kwargs)
|
||||
self.client.update_image.assert_called_with(self._image.id, **kwargs)
|
||||
self.image_client.update_image.assert_called_with(
|
||||
self._image.id, **kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_image_set_deactivate(self):
|
||||
@ -1468,17 +1480,19 @@ class TestImageSet(TestImage):
|
||||
'tags': ['test-tag'],
|
||||
}
|
||||
|
||||
self.client.deactivate_image.assert_called_with(
|
||||
self.image_client.deactivate_image.assert_called_with(
|
||||
self._image.id,
|
||||
)
|
||||
# ImageManager.update(image, **kwargs)
|
||||
self.client.update_image.assert_called_with(self._image.id, **kwargs)
|
||||
self.image_client.update_image.assert_called_with(
|
||||
self._image.id, **kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_image_set_tag_merge(self):
|
||||
old_image = self._image
|
||||
old_image['tags'] = ['old1', 'new2']
|
||||
self.client.find_image.return_value = old_image
|
||||
self.image_client.find_image.return_value = old_image
|
||||
arglist = [
|
||||
'--tag',
|
||||
'test-tag',
|
||||
@ -1496,7 +1510,7 @@ class TestImageSet(TestImage):
|
||||
'tags': ['old1', 'new2', 'test-tag'],
|
||||
}
|
||||
# ImageManager.update(image, **kwargs)
|
||||
a, k = self.client.update_image.call_args
|
||||
a, k = self.image_client.update_image.call_args
|
||||
self.assertEqual(self._image.id, a[0])
|
||||
self.assertIn('tags', k)
|
||||
self.assertEqual(set(kwargs['tags']), set(k['tags']))
|
||||
@ -1505,7 +1519,7 @@ class TestImageSet(TestImage):
|
||||
def test_image_set_tag_merge_dupe(self):
|
||||
old_image = self._image
|
||||
old_image['tags'] = ['old1', 'new2']
|
||||
self.client.find_image.return_value = old_image
|
||||
self.image_client.find_image.return_value = old_image
|
||||
arglist = [
|
||||
'--tag',
|
||||
'old1',
|
||||
@ -1523,7 +1537,7 @@ class TestImageSet(TestImage):
|
||||
'tags': ['new2', 'old1'],
|
||||
}
|
||||
# ImageManager.update(image, **kwargs)
|
||||
a, k = self.client.update_image.call_args
|
||||
a, k = self.image_client.update_image.call_args
|
||||
self.assertEqual(self._image.id, a[0])
|
||||
self.assertIn('tags', k)
|
||||
self.assertEqual(set(kwargs['tags']), set(k['tags']))
|
||||
@ -1567,7 +1581,9 @@ class TestImageSet(TestImage):
|
||||
'min_ram': 0,
|
||||
}
|
||||
# ImageManager.update(image, **kwargs)
|
||||
self.client.update_image.assert_called_with(self._image.id, **kwargs)
|
||||
self.image_client.update_image.assert_called_with(
|
||||
self._image.id, **kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_image_set_hidden(self):
|
||||
@ -1590,7 +1606,9 @@ class TestImageSet(TestImage):
|
||||
'visibility': 'public',
|
||||
}
|
||||
# ImageManager.update(image, **kwargs)
|
||||
self.client.update_image.assert_called_with(self._image.id, **kwargs)
|
||||
self.image_client.update_image.assert_called_with(
|
||||
self._image.id, **kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_image_set_unhidden(self):
|
||||
@ -1613,7 +1631,9 @@ class TestImageSet(TestImage):
|
||||
'visibility': 'public',
|
||||
}
|
||||
# ImageManager.update(image, **kwargs)
|
||||
self.client.update_image.assert_called_with(self._image.id, **kwargs)
|
||||
self.image_client.update_image.assert_called_with(
|
||||
self._image.id, **kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
|
||||
@ -1636,7 +1656,7 @@ class TestImageShow(TestImage):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.client.find_image = mock.Mock(return_value=self._data)
|
||||
self.image_client.find_image = mock.Mock(return_value=self._data)
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = _image.ShowImage(self.app, None)
|
||||
@ -1654,7 +1674,7 @@ class TestImageShow(TestImage):
|
||||
# returns a two-part tuple with a tuple of column names and a tuple of
|
||||
# data to be shown.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.client.find_image.assert_called_with(
|
||||
self.image_client.find_image.assert_called_with(
|
||||
'0f41529e-7c12-4de8-be2d-181abb825b3c', ignore_missing=False
|
||||
)
|
||||
|
||||
@ -1662,7 +1682,7 @@ class TestImageShow(TestImage):
|
||||
self.assertCountEqual(self.data, data)
|
||||
|
||||
def test_image_show_human_readable(self):
|
||||
self.client.find_image.return_value = self.new_image
|
||||
self.image_client.find_image.return_value = self.new_image
|
||||
arglist = [
|
||||
'--human-readable',
|
||||
self.new_image.id,
|
||||
@ -1677,7 +1697,7 @@ class TestImageShow(TestImage):
|
||||
# returns a two-part tuple with a tuple of column names and a tuple of
|
||||
# data to be shown.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.client.find_image.assert_called_with(
|
||||
self.image_client.find_image.assert_called_with(
|
||||
self.new_image.id, ignore_missing=False
|
||||
)
|
||||
|
||||
@ -1696,9 +1716,9 @@ class TestImageUnset(TestImage):
|
||||
attrs['prop2'] = 'fake'
|
||||
self.image = image_fakes.create_one_image(attrs)
|
||||
|
||||
self.client.find_image.return_value = self.image
|
||||
self.client.remove_tag.return_value = self.image
|
||||
self.client.update_image.return_value = self.image
|
||||
self.image_client.find_image.return_value = self.image
|
||||
self.image_client.remove_tag.return_value = self.image
|
||||
self.image_client.update_image.return_value = self.image
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = _image.UnsetImage(self.app, None)
|
||||
@ -1728,7 +1748,7 @@ class TestImageUnset(TestImage):
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.client.remove_tag.assert_called_with(self.image.id, 'test')
|
||||
self.image_client.remove_tag.assert_called_with(self.image.id, 'test')
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_image_unset_property_option(self):
|
||||
@ -1747,7 +1767,7 @@ class TestImageUnset(TestImage):
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.client.update_image.assert_called_with(
|
||||
self.image_client.update_image.assert_called_with(
|
||||
self.image, properties={'prop2': 'fake'}
|
||||
)
|
||||
|
||||
@ -1772,11 +1792,11 @@ class TestImageUnset(TestImage):
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.client.update_image.assert_called_with(
|
||||
self.image_client.update_image.assert_called_with(
|
||||
self.image, properties={'prop2': 'fake'}
|
||||
)
|
||||
|
||||
self.client.remove_tag.assert_called_with(self.image.id, 'test')
|
||||
self.image_client.remove_tag.assert_called_with(self.image.id, 'test')
|
||||
self.assertIsNone(result)
|
||||
|
||||
|
||||
@ -1786,7 +1806,7 @@ class TestImageStage(TestImage):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.client.find_image.return_value = self.image
|
||||
self.image_client.find_image.return_value = self.image
|
||||
|
||||
self.cmd = _image.StageImage(self.app, None)
|
||||
|
||||
@ -1808,7 +1828,7 @@ class TestImageStage(TestImage):
|
||||
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.client.stage_image.assert_called_once_with(
|
||||
self.image_client.stage_image.assert_called_once_with(
|
||||
self.image,
|
||||
filename=imagefile.name,
|
||||
)
|
||||
@ -1828,7 +1848,7 @@ class TestImageStage(TestImage):
|
||||
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.client.stage_image.assert_called_once_with(
|
||||
self.image_client.stage_image.assert_called_once_with(
|
||||
self.image,
|
||||
data=fake_stdin,
|
||||
)
|
||||
@ -1846,8 +1866,8 @@ class TestImageImport(TestImage):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.client.find_image.return_value = self.image
|
||||
self.client.get_import_info.return_value = self.import_info
|
||||
self.image_client.find_image.return_value = self.image
|
||||
self.image_client.get_import_info.return_value = self.import_info
|
||||
|
||||
self.cmd = _image.ImportImage(self.app, None)
|
||||
|
||||
@ -1863,7 +1883,7 @@ class TestImageImport(TestImage):
|
||||
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.client.import_image.assert_called_once_with(
|
||||
self.image_client.import_image.assert_called_once_with(
|
||||
self.image,
|
||||
method='glance-direct',
|
||||
uri=None,
|
||||
@ -1893,7 +1913,7 @@ class TestImageImport(TestImage):
|
||||
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.client.import_image.assert_called_once_with(
|
||||
self.image_client.import_image.assert_called_once_with(
|
||||
self.image,
|
||||
method='web-download',
|
||||
uri='https://example.com/',
|
||||
@ -1927,7 +1947,7 @@ class TestImageImport(TestImage):
|
||||
)
|
||||
self.assertIn("The '--uri' option is required ", str(exc))
|
||||
|
||||
self.client.import_image.assert_not_called()
|
||||
self.image_client.import_image.assert_not_called()
|
||||
|
||||
# NOTE(stephenfin): Ditto
|
||||
def test_import_image__web_download_invalid_options(self):
|
||||
@ -1952,7 +1972,7 @@ class TestImageImport(TestImage):
|
||||
)
|
||||
self.assertIn("The '--uri' option is only supported ", str(exc))
|
||||
|
||||
self.client.import_image.assert_not_called()
|
||||
self.image_client.import_image.assert_not_called()
|
||||
|
||||
def test_import_image__web_download_invalid_image_state(self):
|
||||
self.image.status = 'uploading' # != 'queued'
|
||||
@ -1981,7 +2001,7 @@ class TestImageImport(TestImage):
|
||||
str(exc),
|
||||
)
|
||||
|
||||
self.client.import_image.assert_not_called()
|
||||
self.image_client.import_image.assert_not_called()
|
||||
|
||||
def test_import_image__copy_image(self):
|
||||
self.image.status = 'active'
|
||||
@ -2001,7 +2021,7 @@ class TestImageImport(TestImage):
|
||||
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.client.import_image.assert_called_once_with(
|
||||
self.image_client.import_image.assert_called_once_with(
|
||||
self.image,
|
||||
method='copy-image',
|
||||
uri=None,
|
||||
@ -2036,7 +2056,7 @@ class TestImageImport(TestImage):
|
||||
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.client.import_image.assert_called_once_with(
|
||||
self.image_client.import_image.assert_called_once_with(
|
||||
self.image,
|
||||
method='glance-download',
|
||||
uri=None,
|
||||
@ -2055,8 +2075,8 @@ class TestImageSave(TestImage):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.client.find_image.return_value = self.image
|
||||
self.client.download_image.return_value = self.image
|
||||
self.image_client.find_image.return_value = self.image
|
||||
self.image_client.download_image.return_value = self.image
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = _image.SaveImage(self.app, None)
|
||||
@ -2072,7 +2092,7 @@ class TestImageSave(TestImage):
|
||||
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.client.download_image.assert_called_once_with(
|
||||
self.image_client.download_image.assert_called_once_with(
|
||||
self.image.id, stream=True, output='/path/to/file'
|
||||
)
|
||||
|
||||
@ -2109,7 +2129,7 @@ class TestStoresInfo(TestImage):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.client.stores.return_value = self.stores_info
|
||||
self.image_client.stores.return_value = self.stores_info
|
||||
|
||||
self.cmd = _image.StoresInfo(self.app, None)
|
||||
|
||||
@ -2118,19 +2138,21 @@ class TestStoresInfo(TestImage):
|
||||
parsed_args = self.check_parser(self.cmd, arglist, [])
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.client.stores.assert_called()
|
||||
self.image_client.stores.assert_called()
|
||||
|
||||
def test_stores_info_with_detail(self):
|
||||
arglist = ['--detail']
|
||||
parsed_args = self.check_parser(self.cmd, arglist, [])
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.client.stores.assert_called_with(details=True)
|
||||
self.image_client.stores.assert_called_with(details=True)
|
||||
|
||||
def test_stores_info_neg(self):
|
||||
arglist = []
|
||||
parsed_args = self.check_parser(self.cmd, arglist, [])
|
||||
self.client.stores.side_effect = sdk_exceptions.ResourceNotFound()
|
||||
self.image_client.stores.side_effect = (
|
||||
sdk_exceptions.ResourceNotFound()
|
||||
)
|
||||
|
||||
exc = self.assertRaises(
|
||||
exceptions.CommandError,
|
||||
|
@ -14,24 +14,16 @@
|
||||
# under the License.
|
||||
|
||||
from openstackclient.image.v2 import info
|
||||
from openstackclient.tests.unit.image.v2 import fakes as info_fakes
|
||||
from openstackclient.tests.unit.image.v2 import fakes as image_fakes
|
||||
|
||||
|
||||
class TestInfo(info_fakes.TestImagev2):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
# Get shortcuts to mocked image client
|
||||
self.client = self.app.client_manager.image
|
||||
|
||||
|
||||
class TestImportInfo(TestInfo):
|
||||
import_info = info_fakes.create_one_import_info()
|
||||
class TestImportInfo(image_fakes.TestImagev2):
|
||||
import_info = image_fakes.create_one_import_info()
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.client.get_import_info.return_value = self.import_info
|
||||
self.image_client.get_import_info.return_value = self.import_info
|
||||
|
||||
self.cmd = info.ImportInfo(self.app, None)
|
||||
|
||||
@ -40,4 +32,4 @@ class TestImportInfo(TestInfo):
|
||||
parsed_args = self.check_parser(self.cmd, arglist, [])
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.client.get_import_info.assert_called()
|
||||
self.image_client.get_import_info.assert_called()
|
||||
|
@ -13,25 +13,11 @@
|
||||
# under the License.
|
||||
|
||||
from openstackclient.image.v2 import metadef_namespaces
|
||||
from openstackclient.tests.unit.image.v2 import fakes as md_namespace_fakes
|
||||
from openstackclient.tests.unit.image.v2 import fakes as image_fakes
|
||||
|
||||
|
||||
class TestMetadefNamespaces(md_namespace_fakes.TestMetadefNamespaces):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
# Get shortcuts to mocked image client
|
||||
self.client = self.app.client_manager.image
|
||||
|
||||
# Get shortcut to the Mocks in identity client
|
||||
self.project_mock = self.app.client_manager.identity.projects
|
||||
self.project_mock.reset_mock()
|
||||
self.domain_mock = self.app.client_manager.identity.domains
|
||||
self.domain_mock.reset_mock()
|
||||
|
||||
|
||||
class TestMetadefNamespaceCreate(TestMetadefNamespaces):
|
||||
_metadef_namespace = md_namespace_fakes.create_one_metadef_namespace()
|
||||
class TestMetadefNamespaceCreate(image_fakes.TestImagev2):
|
||||
_metadef_namespace = image_fakes.create_one_metadef_namespace()
|
||||
|
||||
expected_columns = (
|
||||
'created_at',
|
||||
@ -65,7 +51,7 @@ class TestMetadefNamespaceCreate(TestMetadefNamespaces):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.client.create_metadef_namespace.return_value = (
|
||||
self.image_client.create_metadef_namespace.return_value = (
|
||||
self._metadef_namespace
|
||||
)
|
||||
self.cmd = metadef_namespaces.CreateMetadefNameSpace(self.app, None)
|
||||
@ -83,13 +69,13 @@ class TestMetadefNamespaceCreate(TestMetadefNamespaces):
|
||||
self.assertEqual(self.expected_data, data)
|
||||
|
||||
|
||||
class TestMetadefNamespaceDelete(TestMetadefNamespaces):
|
||||
_metadef_namespace = md_namespace_fakes.create_one_metadef_namespace()
|
||||
class TestMetadefNamespaceDelete(image_fakes.TestImagev2):
|
||||
_metadef_namespace = image_fakes.create_one_metadef_namespace()
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.client.delete_metadef_namespace.return_value = (
|
||||
self.image_client.delete_metadef_namespace.return_value = (
|
||||
self._metadef_namespace
|
||||
)
|
||||
self.cmd = metadef_namespaces.DeleteMetadefNameSpace(self.app, None)
|
||||
@ -106,8 +92,8 @@ class TestMetadefNamespaceDelete(TestMetadefNamespaces):
|
||||
self.assertIsNone(result)
|
||||
|
||||
|
||||
class TestMetadefNamespaceList(TestMetadefNamespaces):
|
||||
_metadef_namespace = [md_namespace_fakes.create_one_metadef_namespace()]
|
||||
class TestMetadefNamespaceList(image_fakes.TestImagev2):
|
||||
_metadef_namespace = [image_fakes.create_one_metadef_namespace()]
|
||||
|
||||
columns = ['namespace']
|
||||
|
||||
@ -116,13 +102,13 @@ class TestMetadefNamespaceList(TestMetadefNamespaces):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.client.metadef_namespaces.side_effect = [
|
||||
self.image_client.metadef_namespaces.side_effect = [
|
||||
self._metadef_namespace,
|
||||
[],
|
||||
]
|
||||
|
||||
# Get the command object to test
|
||||
self.client.metadef_namespaces.return_value = iter(
|
||||
self.image_client.metadef_namespaces.return_value = iter(
|
||||
self._metadef_namespace
|
||||
)
|
||||
self.cmd = metadef_namespaces.ListMetadefNameSpaces(self.app, None)
|
||||
@ -141,13 +127,13 @@ class TestMetadefNamespaceList(TestMetadefNamespaces):
|
||||
self.assertEqual(getattr(self.datalist[0], 'namespace'), next(data)[0])
|
||||
|
||||
|
||||
class TestMetadefNamespaceSet(TestMetadefNamespaces):
|
||||
_metadef_namespace = md_namespace_fakes.create_one_metadef_namespace()
|
||||
class TestMetadefNamespaceSet(image_fakes.TestImagev2):
|
||||
_metadef_namespace = image_fakes.create_one_metadef_namespace()
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.client.update_metadef_namespace.return_value = (
|
||||
self.image_client.update_metadef_namespace.return_value = (
|
||||
self._metadef_namespace
|
||||
)
|
||||
self.cmd = metadef_namespaces.SetMetadefNameSpace(self.app, None)
|
||||
@ -166,8 +152,8 @@ class TestMetadefNamespaceSet(TestMetadefNamespaces):
|
||||
self.assertIsNone(result)
|
||||
|
||||
|
||||
class TestMetadefNamespaceShow(TestMetadefNamespaces):
|
||||
_metadef_namespace = md_namespace_fakes.create_one_metadef_namespace()
|
||||
class TestMetadefNamespaceShow(image_fakes.TestImagev2):
|
||||
_metadef_namespace = image_fakes.create_one_metadef_namespace()
|
||||
|
||||
expected_columns = (
|
||||
'created_at',
|
||||
@ -187,7 +173,7 @@ class TestMetadefNamespaceShow(TestMetadefNamespaces):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.client.get_metadef_namespace.return_value = (
|
||||
self.image_client.get_metadef_namespace.return_value = (
|
||||
self._metadef_namespace
|
||||
)
|
||||
self.cmd = metadef_namespaces.ShowMetadefNameSpace(self.app, None)
|
||||
|
@ -11,18 +11,11 @@
|
||||
# under the License.
|
||||
|
||||
from openstackclient.image.v2 import metadef_resource_types
|
||||
from openstackclient.tests.unit.image.v2 import fakes as resource_type_fakes
|
||||
from openstackclient.tests.unit.image.v2 import fakes as image_fakes
|
||||
|
||||
|
||||
class TestMetadefResourceTypes(resource_type_fakes.TestImagev2):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.client = self.app.client_manager.image
|
||||
|
||||
|
||||
class TestMetadefResourceTypeList(TestMetadefResourceTypes):
|
||||
resource_types = resource_type_fakes.create_resource_types()
|
||||
class TestMetadefResourceTypeList(image_fakes.TestImagev2):
|
||||
resource_types = image_fakes.create_resource_types()
|
||||
|
||||
columns = ['Name']
|
||||
|
||||
@ -31,7 +24,7 @@ class TestMetadefResourceTypeList(TestMetadefResourceTypes):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.client.metadef_resource_types.side_effect = [
|
||||
self.image_client.metadef_resource_types.side_effect = [
|
||||
self.resource_types,
|
||||
[],
|
||||
]
|
||||
|
@ -16,15 +16,7 @@ from openstackclient.image.v2 import task
|
||||
from openstackclient.tests.unit.image.v2 import fakes as image_fakes
|
||||
|
||||
|
||||
class TestTask(image_fakes.TestImagev2):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
# Get shortcuts to mocked image client
|
||||
self.client = self.app.client_manager.image
|
||||
|
||||
|
||||
class TestTaskShow(TestTask):
|
||||
class TestTaskShow(image_fakes.TestImagev2):
|
||||
task = image_fakes.create_one_task()
|
||||
|
||||
columns = (
|
||||
@ -57,7 +49,7 @@ class TestTaskShow(TestTask):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.client.get_task.return_value = self.task
|
||||
self.image_client.get_task.return_value = self.task
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = task.ShowTask(self.app, None)
|
||||
@ -73,13 +65,13 @@ class TestTaskShow(TestTask):
|
||||
# returns a two-part tuple with a tuple of column names and a tuple of
|
||||
# data to be shown.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.client.get_task.assert_called_with(self.task.id)
|
||||
self.image_client.get_task.assert_called_with(self.task.id)
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertCountEqual(self.data, data)
|
||||
|
||||
|
||||
class TestTaskList(TestTask):
|
||||
class TestTaskList(image_fakes.TestImagev2):
|
||||
tasks = image_fakes.create_tasks()
|
||||
|
||||
columns = (
|
||||
@ -101,7 +93,7 @@ class TestTaskList(TestTask):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.client.tasks.side_effect = [self.tasks, []]
|
||||
self.image_client.tasks.side_effect = [self.tasks, []]
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = task.ListTask(self.app, None)
|
||||
@ -120,7 +112,7 @@ class TestTaskList(TestTask):
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.client.tasks.assert_called_with()
|
||||
self.image_client.tasks.assert_called_with()
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertCountEqual(self.datalist, data)
|
||||
@ -132,7 +124,7 @@ class TestTaskList(TestTask):
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.client.tasks.assert_called_with(
|
||||
self.image_client.tasks.assert_called_with(
|
||||
sort_key=parsed_args.sort_key,
|
||||
)
|
||||
|
||||
@ -146,7 +138,7 @@ class TestTaskList(TestTask):
|
||||
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.client.tasks.assert_called_with(
|
||||
self.image_client.tasks.assert_called_with(
|
||||
sort_dir=parsed_args.sort_dir,
|
||||
)
|
||||
|
||||
@ -157,7 +149,7 @@ class TestTaskList(TestTask):
|
||||
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.client.tasks.assert_called_with(
|
||||
self.image_client.tasks.assert_called_with(
|
||||
limit=parsed_args.limit,
|
||||
marker=parsed_args.marker,
|
||||
)
|
||||
@ -169,7 +161,7 @@ class TestTaskList(TestTask):
|
||||
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.client.tasks.assert_called_with(
|
||||
self.image_client.tasks.assert_called_with(
|
||||
type=self.tasks[0].type,
|
||||
)
|
||||
|
||||
@ -180,6 +172,6 @@ class TestTaskList(TestTask):
|
||||
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.client.tasks.assert_called_with(
|
||||
self.image_client.tasks.assert_called_with(
|
||||
status=self.tasks[0].status,
|
||||
)
|
||||
|
@ -44,9 +44,8 @@ class TestVolume(volume_fakes.TestVolumev1):
|
||||
self.users_mock = self.app.client_manager.identity.users
|
||||
self.users_mock.reset_mock()
|
||||
|
||||
# Get a shortcut to the ImageManager Mock
|
||||
self.images_mock = self.app.client_manager.image.images
|
||||
self.images_mock.reset_mock()
|
||||
self.app.client_manager.image = mock.Mock()
|
||||
self.image_client = self.app.client_manager.image
|
||||
|
||||
def setup_volumes_mock(self, count):
|
||||
volumes = volume_fakes.create_volumes(count=count)
|
||||
@ -328,7 +327,7 @@ class TestVolumeCreate(TestVolume):
|
||||
|
||||
def test_volume_create_image_id(self):
|
||||
image = image_fakes.create_one_image()
|
||||
self.images_mock.get.return_value = image
|
||||
self.image_client.find_image.return_value = image
|
||||
|
||||
arglist = [
|
||||
'--image',
|
||||
@ -373,7 +372,7 @@ class TestVolumeCreate(TestVolume):
|
||||
|
||||
def test_volume_create_image_name(self):
|
||||
image = image_fakes.create_one_image()
|
||||
self.images_mock.get.return_value = image
|
||||
self.image_client.find_image.return_value = image
|
||||
|
||||
arglist = [
|
||||
'--image',
|
||||
|
@ -41,9 +41,6 @@ class TestVolume(volume_fakes.TestVolume):
|
||||
self.users_mock = self.app.client_manager.identity.users
|
||||
self.users_mock.reset_mock()
|
||||
|
||||
self.find_image_mock = self.app.client_manager.image.find_image
|
||||
self.find_image_mock.reset_mock()
|
||||
|
||||
self.snapshots_mock = self.app.client_manager.volume.volume_snapshots
|
||||
self.snapshots_mock.reset_mock()
|
||||
|
||||
@ -58,6 +55,8 @@ class TestVolume(volume_fakes.TestVolume):
|
||||
)
|
||||
self.consistencygroups_mock.reset_mock()
|
||||
|
||||
self.image_client = self.app.client_manager.image
|
||||
|
||||
def setup_volumes_mock(self, count):
|
||||
volumes = volume_fakes.create_volumes(count=count)
|
||||
|
||||
@ -233,7 +232,7 @@ class TestVolumeCreate(TestVolume):
|
||||
|
||||
def test_volume_create_image_id(self):
|
||||
image = image_fakes.create_one_image()
|
||||
self.find_image_mock.return_value = image
|
||||
self.image_client.find_image.return_value = image
|
||||
|
||||
arglist = [
|
||||
'--image',
|
||||
@ -274,7 +273,7 @@ class TestVolumeCreate(TestVolume):
|
||||
|
||||
def test_volume_create_image_name(self):
|
||||
image = image_fakes.create_one_image()
|
||||
self.find_image_mock.return_value = image
|
||||
self.image_client.find_image.return_value = image
|
||||
|
||||
arglist = [
|
||||
'--image',
|
||||
|
@ -206,9 +206,9 @@ class CreateVolume(command.ShowOne):
|
||||
|
||||
image = None
|
||||
if parsed_args.image:
|
||||
image = utils.find_resource(
|
||||
image_client.images,
|
||||
image = image_client.find_image(
|
||||
parsed_args.image,
|
||||
ignore_missing=False,
|
||||
).id
|
||||
|
||||
snapshot = parsed_args.snapshot or parsed_args.snapshot_id
|
||||
|
Loading…
Reference in New Issue
Block a user