summaryrefslogtreecommitdiff
path: root/openstackclient/tests/unit/identity/v3/test_domain.py
diff options
context:
space:
mode:
authorVishakha Agarwal <agarwalvishakha18@gmail.com>2020-03-26 22:23:57 +0530
committerVishakha Agarwal <agarwalvishakha18@gmail.com>2020-04-08 13:51:01 +0000
commit7f66273d3f2fb6449d7b50d88460ace0cb81bf30 (patch)
tree78e639f02b4d8bda23f15823ecfc4a80d9e8b66b /openstackclient/tests/unit/identity/v3/test_domain.py
parent05da145eaee329e299b449ba2d7ea88d1325e432 (diff)
downloadpython-openstackclient-7f66273d3f2fb6449d7b50d88460ace0cb81bf30.tar.gz
Add resource option immutable
This patch adds the --immutable and --no-immutable option to the role, project and domain CLI. Related-Patch: https://review.opendev.org/#/c/712182/ Change-Id: I9c3bdd741f28bf558267fb217818d947597ce13e
Diffstat (limited to 'openstackclient/tests/unit/identity/v3/test_domain.py')
-rw-r--r--openstackclient/tests/unit/identity/v3/test_domain.py110
1 files changed, 110 insertions, 0 deletions
diff --git a/openstackclient/tests/unit/identity/v3/test_domain.py b/openstackclient/tests/unit/identity/v3/test_domain.py
index 014986e5..46f389e8 100644
--- a/openstackclient/tests/unit/identity/v3/test_domain.py
+++ b/openstackclient/tests/unit/identity/v3/test_domain.py
@@ -68,6 +68,7 @@ class TestDomainCreate(TestDomain):
kwargs = {
'name': self.domain.name,
'description': None,
+ 'options': {},
'enabled': True,
}
self.domains_mock.create.assert_called_with(
@@ -97,6 +98,7 @@ class TestDomainCreate(TestDomain):
kwargs = {
'name': self.domain.name,
'description': 'new desc',
+ 'options': {},
'enabled': True,
}
self.domains_mock.create.assert_called_with(
@@ -126,6 +128,7 @@ class TestDomainCreate(TestDomain):
kwargs = {
'name': self.domain.name,
'description': None,
+ 'options': {},
'enabled': True,
}
self.domains_mock.create.assert_called_with(
@@ -155,6 +158,7 @@ class TestDomainCreate(TestDomain):
kwargs = {
'name': self.domain.name,
'description': None,
+ 'options': {},
'enabled': False,
}
self.domains_mock.create.assert_called_with(
@@ -164,6 +168,66 @@ class TestDomainCreate(TestDomain):
self.assertEqual(self.columns, columns)
self.assertEqual(self.datalist, data)
+ def test_domain_create_with_immutable(self):
+ arglist = [
+ '--immutable',
+ self.domain.name,
+ ]
+ verifylist = [
+ ('immutable', True),
+ ('name', self.domain.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.domain.name,
+ 'description': None,
+ 'options': {'immutable': True},
+ 'enabled': True,
+ }
+ self.domains_mock.create.assert_called_with(
+ **kwargs
+ )
+
+ self.assertEqual(self.columns, columns)
+ self.assertEqual(self.datalist, data)
+
+ def test_domain_create_with_no_immutable(self):
+ arglist = [
+ '--no-immutable',
+ self.domain.name,
+ ]
+ verifylist = [
+ ('no_immutable', True),
+ ('name', self.domain.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.domain.name,
+ 'description': None,
+ 'options': {'immutable': False},
+ 'enabled': True,
+ }
+ self.domains_mock.create.assert_called_with(
+ **kwargs
+ )
+
+ self.assertEqual(self.columns, columns)
+ self.assertEqual(self.datalist, data)
+
class TestDomainDelete(TestDomain):
@@ -354,6 +418,52 @@ class TestDomainSet(TestDomain):
)
self.assertIsNone(result)
+ def test_domain_set_immutable_option(self):
+ arglist = [
+ '--immutable',
+ self.domain.id,
+ ]
+ verifylist = [
+ ('immutable', True),
+ ('domain', self.domain.id),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ result = self.cmd.take_action(parsed_args)
+
+ # Set expected values
+ kwargs = {
+ 'options': {'immutable': True},
+ }
+ self.domains_mock.update.assert_called_with(
+ self.domain.id,
+ **kwargs
+ )
+ self.assertIsNone(result)
+
+ def test_domain_set_no_immutable_option(self):
+ arglist = [
+ '--no-immutable',
+ self.domain.id,
+ ]
+ verifylist = [
+ ('no_immutable', True),
+ ('domain', self.domain.id),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ result = self.cmd.take_action(parsed_args)
+
+ # Set expected values
+ kwargs = {
+ 'options': {'immutable': False},
+ }
+ self.domains_mock.update.assert_called_with(
+ self.domain.id,
+ **kwargs
+ )
+ self.assertIsNone(result)
+
class TestDomainShow(TestDomain):