summaryrefslogtreecommitdiff
path: root/openstackclient/tests/unit
diff options
context:
space:
mode:
Diffstat (limited to 'openstackclient/tests/unit')
-rw-r--r--openstackclient/tests/unit/common/test_quota.py50
-rw-r--r--openstackclient/tests/unit/image/v2/test_image.py22
2 files changed, 72 insertions, 0 deletions
diff --git a/openstackclient/tests/unit/common/test_quota.py b/openstackclient/tests/unit/common/test_quota.py
index 3fff062b..6504c5b0 100644
--- a/openstackclient/tests/unit/common/test_quota.py
+++ b/openstackclient/tests/unit/common/test_quota.py
@@ -900,6 +900,56 @@ class TestQuotaSet(TestQuota):
self.assertNotCalled(self.network_mock.update_quota)
self.assertIsNone(result)
+ def test_quota_set_with_force(self):
+ arglist = [
+ '--cores', str(compute_fakes.core_num),
+ '--ram', str(compute_fakes.ram_num),
+ '--instances', str(compute_fakes.instance_num),
+ '--volumes', str(volume_fakes.QUOTA['volumes']),
+ '--subnets', str(network_fakes.QUOTA['subnet']),
+ '--force',
+ self.projects[0].name,
+ ]
+ verifylist = [
+ ('cores', compute_fakes.core_num),
+ ('ram', compute_fakes.ram_num),
+ ('instances', compute_fakes.instance_num),
+ ('volumes', volume_fakes.QUOTA['volumes']),
+ ('subnet', network_fakes.QUOTA['subnet']),
+ ('force', True),
+ ('project', self.projects[0].name),
+ ]
+ self.app.client_manager.network_endpoint_enabled = True
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ result = self.cmd.take_action(parsed_args)
+
+ kwargs_compute = {
+ 'cores': compute_fakes.core_num,
+ 'ram': compute_fakes.ram_num,
+ 'instances': compute_fakes.instance_num,
+ 'force': True,
+ }
+ kwargs_volume = {
+ 'volumes': volume_fakes.QUOTA['volumes'],
+ }
+ kwargs_network = {
+ 'subnet': network_fakes.QUOTA['subnet'],
+ }
+ self.compute_quotas_mock.update.assert_called_once_with(
+ self.projects[0].id,
+ **kwargs_compute
+ )
+ self.volume_quotas_mock.update.assert_called_once_with(
+ self.projects[0].id,
+ **kwargs_volume
+ )
+ self.network_mock.update_quota.assert_called_once_with(
+ self.projects[0].id,
+ **kwargs_network
+ )
+ self.assertIsNone(result)
+
class TestQuotaShow(TestQuota):
diff --git a/openstackclient/tests/unit/image/v2/test_image.py b/openstackclient/tests/unit/image/v2/test_image.py
index a021cfc7..310f6b76 100644
--- a/openstackclient/tests/unit/image/v2/test_image.py
+++ b/openstackclient/tests/unit/image/v2/test_image.py
@@ -271,6 +271,28 @@ class TestImageCreate(TestImage):
exceptions.CommandError,
self.cmd.take_action, parsed_args)
+ @mock.patch('sys.stdin', side_effect=[None])
+ def test_image_create_import(self, raw_input):
+
+ arglist = [
+ '--import',
+ self.new_image.name,
+ ]
+ verifylist = [
+ ('name', self.new_image.name),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ columns, data = self.cmd.take_action(parsed_args)
+
+ # ImageManager.create(name=, **)
+ self.client.create_image.assert_called_with(
+ name=self.new_image.name,
+ container_format=image.DEFAULT_CONTAINER_FORMAT,
+ disk_format=image.DEFAULT_DISK_FORMAT,
+ use_import=True
+ )
+
class TestAddProjectToImage(TestImage):