diff options
| author | yanpuqing <yanpq@awcloud.com> | 2019-05-20 06:47:44 +0000 |
|---|---|---|
| committer | Lance Bragstad <lbragstad@gmail.com> | 2020-06-10 14:21:41 -0500 |
| commit | 19723aee18e2901e9250dd840a61359704baa170 (patch) | |
| tree | 6e4f8b8915ecce42e76b5457b4227cd76be6ad6e /openstackclient/tests/unit/identity/v3/test_project.py | |
| parent | 65411e45279c9b4c47d17b768084dd1b9e131aee (diff) | |
| download | python-openstackclient-5.2.1.tar.gz | |
Client should parse string to boolean for value 'is_domain'5.2.1
When we use "--property" parameter, client get lists these the
value is string type, but the type of the value 'is_domain'
should be boolean, so we should judge it and parse it.
The patch parse string to boolean for value 'is_domain'.
Co-Authored-By: Lance Bragstad <lbragstad@gmail.com>
Conflict:
Direct backports of this patch fail because the original tests
proposed to the Victoria (master) branch included keystone
``options``. Support for ``options`` was added in:
I9c3bdd741f28bf558267fb217818d947597ce13e
This backport removes the ``options`` key from the expected values in
the tests since feature support for ``options`` isn't going to be
backported. Otherwise, the functionality of this change is fully
tested like it is on later releases.
Change-Id: I37c9eb854524bde3a1530bfe2e3a03810fb1a676
Task: 30039
Story: 2005246
(cherry picked from commit 533af9f1b2de40d98f69e83cdf89ecf254cf3879)
Diffstat (limited to 'openstackclient/tests/unit/identity/v3/test_project.py')
| -rw-r--r-- | openstackclient/tests/unit/identity/v3/test_project.py | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/openstackclient/tests/unit/identity/v3/test_project.py b/openstackclient/tests/unit/identity/v3/test_project.py index 466bea18..7194b0bd 100644 --- a/openstackclient/tests/unit/identity/v3/test_project.py +++ b/openstackclient/tests/unit/identity/v3/test_project.py @@ -350,6 +350,123 @@ class TestProjectCreate(TestProject): self.assertEqual(self.columns, columns) self.assertEqual(self.datalist, data) + def test_project_create_is_domain_false_property(self): + arglist = [ + '--property', 'is_domain=false', + self.project.name, + ] + verifylist = [ + ('parent', None), + ('enable', False), + ('disable', False), + ('name', self.project.name), + ('tags', []), + ('property', {'is_domain': 'false'}), + ('name', self.project.name), + ] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + # In base command class ShowOne in cliff, abstract method take_action() + # 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) + + # Set expected values + kwargs = { + 'name': self.project.name, + 'domain': None, + 'description': None, + 'enabled': True, + 'parent': None, + 'is_domain': False, + 'tags': [], + } + self.projects_mock.create.assert_called_with( + **kwargs + ) + + self.assertEqual(self.columns, columns) + self.assertEqual(self.datalist, data) + + def test_project_create_is_domain_true_property(self): + arglist = [ + '--property', 'is_domain=true', + self.project.name, + ] + verifylist = [ + ('parent', None), + ('enable', False), + ('disable', False), + ('name', self.project.name), + ('tags', []), + ('property', {'is_domain': 'true'}), + ('name', self.project.name), + ] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + # In base command class ShowOne in cliff, abstract method take_action() + # 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) + + # Set expected values + kwargs = { + 'name': self.project.name, + 'domain': None, + 'description': None, + 'enabled': True, + 'parent': None, + 'is_domain': True, + 'tags': [], + } + self.projects_mock.create.assert_called_with( + **kwargs + ) + + self.assertEqual(self.columns, columns) + self.assertEqual(self.datalist, data) + + def test_project_create_is_domain_none_property(self): + arglist = [ + '--property', 'is_domain=none', + self.project.name, + ] + verifylist = [ + ('parent', None), + ('enable', False), + ('disable', False), + ('name', self.project.name), + ('tags', []), + ('property', {'is_domain': 'none'}), + ('name', self.project.name), + ] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + # In base command class ShowOne in cliff, abstract method take_action() + # 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) + + # Set expected values + kwargs = { + 'name': self.project.name, + 'domain': None, + 'description': None, + 'enabled': True, + 'parent': None, + 'is_domain': None, + 'tags': [], + } + self.projects_mock.create.assert_called_with( + **kwargs + ) + + self.assertEqual(self.columns, columns) + self.assertEqual(self.datalist, data) + def test_project_create_parent(self): self.parent = identity_fakes.FakeProject.create_one_project() self.project = identity_fakes.FakeProject.create_one_project( |
