|
14 | 14 | # |
15 | 15 |
|
16 | 16 | import copy |
| 17 | +import mock |
17 | 18 |
|
18 | 19 | from openstackclient.identity.v3 import project |
19 | 20 | from openstackclient.tests import fakes |
@@ -172,6 +173,45 @@ def test_project_create_domain(self): |
172 | 173 | ) |
173 | 174 | self.assertEqual(data, datalist) |
174 | 175 |
|
| 176 | + def test_project_create_domain_no_perms(self): |
| 177 | + arglist = [ |
| 178 | + '--domain', identity_fakes.domain_id, |
| 179 | + identity_fakes.project_name, |
| 180 | + ] |
| 181 | + verifylist = [ |
| 182 | + ('domain', identity_fakes.domain_id), |
| 183 | + ('enable', False), |
| 184 | + ('disable', False), |
| 185 | + ('name', identity_fakes.project_name), |
| 186 | + ] |
| 187 | + parsed_args = self.check_parser(self.cmd, arglist, verifylist) |
| 188 | + mocker = mock.Mock() |
| 189 | + mocker.return_value = None |
| 190 | + |
| 191 | + with mock.patch("openstackclient.common.utils.find_resource", mocker): |
| 192 | + columns, data = self.cmd.take_action(parsed_args) |
| 193 | + |
| 194 | + # Set expected values |
| 195 | + kwargs = { |
| 196 | + 'name': identity_fakes.project_name, |
| 197 | + 'domain': identity_fakes.domain_id, |
| 198 | + 'description': None, |
| 199 | + 'enabled': True, |
| 200 | + } |
| 201 | + self.projects_mock.create.assert_called_with( |
| 202 | + **kwargs |
| 203 | + ) |
| 204 | + collist = ('description', 'domain_id', 'enabled', 'id', 'name') |
| 205 | + self.assertEqual(columns, collist) |
| 206 | + datalist = ( |
| 207 | + identity_fakes.project_description, |
| 208 | + identity_fakes.domain_id, |
| 209 | + True, |
| 210 | + identity_fakes.project_id, |
| 211 | + identity_fakes.project_name, |
| 212 | + ) |
| 213 | + self.assertEqual(data, datalist) |
| 214 | + |
175 | 215 | def test_project_create_enable(self): |
176 | 216 | arglist = [ |
177 | 217 | '--enable', |
@@ -411,6 +451,30 @@ def test_project_list_domain(self): |
411 | 451 | ), ) |
412 | 452 | self.assertEqual(tuple(data), datalist) |
413 | 453 |
|
| 454 | + def test_project_list_domain_no_perms(self): |
| 455 | + arglist = [ |
| 456 | + '--domain', identity_fakes.domain_id, |
| 457 | + ] |
| 458 | + verifylist = [ |
| 459 | + ('domain', identity_fakes.domain_id), |
| 460 | + ] |
| 461 | + parsed_args = self.check_parser(self.cmd, arglist, verifylist) |
| 462 | + mocker = mock.Mock() |
| 463 | + mocker.return_value = None |
| 464 | + |
| 465 | + with mock.patch("openstackclient.common.utils.find_resource", mocker): |
| 466 | + columns, data = self.cmd.take_action(parsed_args) |
| 467 | + |
| 468 | + self.projects_mock.list.assert_called_with( |
| 469 | + domain=identity_fakes.domain_id) |
| 470 | + collist = ('ID', 'Name') |
| 471 | + self.assertEqual(columns, collist) |
| 472 | + datalist = (( |
| 473 | + identity_fakes.project_id, |
| 474 | + identity_fakes.project_name, |
| 475 | + ), ) |
| 476 | + self.assertEqual(tuple(data), datalist) |
| 477 | + |
414 | 478 |
|
415 | 479 | class TestProjectSet(TestProject): |
416 | 480 |
|
|
0 commit comments