summaryrefslogtreecommitdiff
path: root/openstackclient
diff options
context:
space:
mode:
Diffstat (limited to 'openstackclient')
-rw-r--r--openstackclient/tests/unit/volume/v1/test_snapshot.py22
-rw-r--r--openstackclient/tests/unit/volume/v2/test_snapshot.py29
-rw-r--r--openstackclient/volume/v1/volume_snapshot.py3
-rw-r--r--openstackclient/volume/v2/volume_snapshot.py3
4 files changed, 20 insertions, 37 deletions
diff --git a/openstackclient/tests/unit/volume/v1/test_snapshot.py b/openstackclient/tests/unit/volume/v1/test_snapshot.py
index 87a62b0a..70b55ce2 100644
--- a/openstackclient/tests/unit/volume/v1/test_snapshot.py
+++ b/openstackclient/tests/unit/volume/v1/test_snapshot.py
@@ -18,6 +18,7 @@ from mock import call
from osc_lib import exceptions
from osc_lib import utils
+from openstackclient.tests.unit import utils as tests_utils
from openstackclient.tests.unit.volume.v1 import fakes as volume_fakes
from openstackclient.volume.v1 import volume_snapshot
@@ -98,26 +99,17 @@ class TestSnapshotCreate(TestSnapshot):
def test_snapshot_create_without_name(self):
arglist = [
"--volume", self.new_snapshot.volume_id,
- "--description", self.new_snapshot.display_description,
- "--force"
]
verifylist = [
("volume", self.new_snapshot.volume_id),
- ("description", self.new_snapshot.display_description),
- ("force", True)
]
- parsed_args = self.check_parser(self.cmd, arglist, verifylist)
-
- columns, data = self.cmd.take_action(parsed_args)
-
- self.snapshots_mock.create.assert_called_with(
- self.new_snapshot.volume_id,
- True,
- None,
- self.new_snapshot.display_description,
+ self.assertRaises(
+ tests_utils.ParserException,
+ self.check_parser,
+ self.cmd,
+ arglist,
+ verifylist,
)
- self.assertEqual(self.columns, columns)
- self.assertEqual(self.data, data)
def test_snapshot_create_without_volume(self):
arglist = [
diff --git a/openstackclient/tests/unit/volume/v2/test_snapshot.py b/openstackclient/tests/unit/volume/v2/test_snapshot.py
index 1ad97e85..16d0602b 100644
--- a/openstackclient/tests/unit/volume/v2/test_snapshot.py
+++ b/openstackclient/tests/unit/volume/v2/test_snapshot.py
@@ -20,6 +20,7 @@ from osc_lib import exceptions
from osc_lib import utils
from openstackclient.tests.unit.identity.v3 import fakes as project_fakes
+from openstackclient.tests.unit import utils as tests_utils
from openstackclient.tests.unit.volume.v2 import fakes as volume_fakes
from openstackclient.volume.v2 import volume_snapshot
@@ -107,27 +108,17 @@ class TestSnapshotCreate(TestSnapshot):
def test_snapshot_create_without_name(self):
arglist = [
"--volume", self.new_snapshot.volume_id,
- "--description", self.new_snapshot.description,
- "--force"
]
verifylist = [
("volume", self.new_snapshot.volume_id),
- ("description", self.new_snapshot.description),
- ("force", True)
]
- parsed_args = self.check_parser(self.cmd, arglist, verifylist)
-
- columns, data = self.cmd.take_action(parsed_args)
-
- self.snapshots_mock.create.assert_called_with(
- self.new_snapshot.volume_id,
- force=True,
- name=None,
- description=self.new_snapshot.description,
- metadata=None,
+ self.assertRaises(
+ tests_utils.ParserException,
+ self.check_parser,
+ self.cmd,
+ arglist,
+ verifylist,
)
- self.assertEqual(self.columns, columns)
- self.assertEqual(self.data, data)
def test_snapshot_create_without_volume(self):
arglist = [
@@ -156,17 +147,19 @@ class TestSnapshotCreate(TestSnapshot):
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, data)
- def test_snapshot_create_without_remote_source(self):
+ def test_snapshot_create_with_remote_source(self):
arglist = [
'--remote-source', 'source-name=test_source_name',
'--remote-source', 'source-id=test_source_id',
'--volume', self.new_snapshot.volume_id,
+ self.new_snapshot.name,
]
ref_dict = {'source-name': 'test_source_name',
'source-id': 'test_source_id'}
verifylist = [
('remote_source', ref_dict),
('volume', self.new_snapshot.volume_id),
+ ("snapshot_name", self.new_snapshot.name),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -175,7 +168,7 @@ class TestSnapshotCreate(TestSnapshot):
self.snapshots_mock.manage.assert_called_with(
volume_id=self.new_snapshot.volume_id,
ref=ref_dict,
- name=None,
+ name=self.new_snapshot.name,
description=None,
metadata=None,
)
diff --git a/openstackclient/volume/v1/volume_snapshot.py b/openstackclient/volume/v1/volume_snapshot.py
index f22c338b..3e83da5a 100644
--- a/openstackclient/volume/v1/volume_snapshot.py
+++ b/openstackclient/volume/v1/volume_snapshot.py
@@ -38,8 +38,7 @@ class CreateVolumeSnapshot(command.ShowOne):
parser.add_argument(
'snapshot_name',
metavar='<snapshot-name>',
- nargs="?",
- help=_('Name of the snapshot (default to None)'),
+ help=_('Name of the new snapshot'),
)
parser.add_argument(
'--volume',
diff --git a/openstackclient/volume/v2/volume_snapshot.py b/openstackclient/volume/v2/volume_snapshot.py
index 804c8291..fe969410 100644
--- a/openstackclient/volume/v2/volume_snapshot.py
+++ b/openstackclient/volume/v2/volume_snapshot.py
@@ -38,8 +38,7 @@ class CreateVolumeSnapshot(command.ShowOne):
parser.add_argument(
"snapshot_name",
metavar="<snapshot-name>",
- nargs="?",
- help=_("Name of the new snapshot (default to None)")
+ help=_("Name of the new snapshot"),
)
parser.add_argument(
"--volume",