|
15 | 15 |
|
16 | 16 | import copy |
17 | 17 |
|
| 18 | +from openstackclient.common import utils |
18 | 19 | from openstackclient.tests import fakes |
19 | 20 | from openstackclient.tests.volume.v1 import fakes as volume_fakes |
20 | 21 | from openstackclient.volume.v1 import qos_specs |
@@ -285,6 +286,52 @@ def test_qos_disassociate_with_all_volume_types(self): |
285 | 286 | self.qos_mock.disassociate_all.assert_called_with(volume_fakes.qos_id) |
286 | 287 |
|
287 | 288 |
|
| 289 | +class TestQosList(TestQos): |
| 290 | + def setUp(self): |
| 291 | + super(TestQosList, self).setUp() |
| 292 | + |
| 293 | + self.qos_mock.get.return_value = fakes.FakeResource( |
| 294 | + None, |
| 295 | + copy.deepcopy(volume_fakes.QOS_WITH_ASSOCIATIONS), |
| 296 | + loaded=True, |
| 297 | + ) |
| 298 | + self.qos_mock.list.return_value = [self.qos_mock.get.return_value] |
| 299 | + self.qos_mock.get_associations.return_value = [fakes.FakeResource( |
| 300 | + None, |
| 301 | + copy.deepcopy(volume_fakes.qos_association), |
| 302 | + loaded=True, |
| 303 | + )] |
| 304 | + |
| 305 | + # Get the command object to test |
| 306 | + self.cmd = qos_specs.ListQos(self.app, None) |
| 307 | + |
| 308 | + def test_qos_list(self): |
| 309 | + arglist = [] |
| 310 | + verifylist = [] |
| 311 | + |
| 312 | + parsed_args = self.check_parser(self.cmd, arglist, verifylist) |
| 313 | + |
| 314 | + columns, data = self.cmd.take_action(parsed_args) |
| 315 | + self.qos_mock.list.assert_called() |
| 316 | + |
| 317 | + collist = ( |
| 318 | + 'ID', |
| 319 | + 'Name', |
| 320 | + 'Consumer', |
| 321 | + 'Associations', |
| 322 | + 'Specs', |
| 323 | + ) |
| 324 | + self.assertEqual(collist, columns) |
| 325 | + datalist = (( |
| 326 | + volume_fakes.qos_id, |
| 327 | + volume_fakes.qos_name, |
| 328 | + volume_fakes.qos_consumer, |
| 329 | + volume_fakes.type_name, |
| 330 | + utils.format_dict(volume_fakes.qos_specs), |
| 331 | + ), ) |
| 332 | + self.assertEqual(datalist, tuple(data)) |
| 333 | + |
| 334 | + |
288 | 335 | class TestQosSet(TestQos): |
289 | 336 | def setUp(self): |
290 | 337 | super(TestQosSet, self).setUp() |
@@ -316,6 +363,57 @@ def test_qos_set_with_properties_with_id(self): |
316 | 363 | ) |
317 | 364 |
|
318 | 365 |
|
| 366 | +class TestQosShow(TestQos): |
| 367 | + def setUp(self): |
| 368 | + super(TestQosShow, self).setUp() |
| 369 | + |
| 370 | + self.qos_mock.get.return_value = fakes.FakeResource( |
| 371 | + None, |
| 372 | + copy.deepcopy(volume_fakes.QOS_WITH_ASSOCIATIONS), |
| 373 | + loaded=True, |
| 374 | + ) |
| 375 | + self.qos_mock.get_associations.return_value = [fakes.FakeResource( |
| 376 | + None, |
| 377 | + copy.deepcopy(volume_fakes.qos_association), |
| 378 | + loaded=True, |
| 379 | + )] |
| 380 | + |
| 381 | + # Get the command object to test |
| 382 | + self.cmd = qos_specs.ShowQos(self.app, None) |
| 383 | + |
| 384 | + def test_qos_show(self): |
| 385 | + arglist = [ |
| 386 | + volume_fakes.qos_id |
| 387 | + ] |
| 388 | + verifylist = [ |
| 389 | + ('qos_specs', volume_fakes.qos_id) |
| 390 | + ] |
| 391 | + |
| 392 | + parsed_args = self.check_parser(self.cmd, arglist, verifylist) |
| 393 | + |
| 394 | + columns, data = self.cmd.take_action(parsed_args) |
| 395 | + self.qos_mock.get.assert_called_with( |
| 396 | + volume_fakes.qos_id |
| 397 | + ) |
| 398 | + |
| 399 | + collist = ( |
| 400 | + 'associations', |
| 401 | + 'consumer', |
| 402 | + 'id', |
| 403 | + 'name', |
| 404 | + 'specs' |
| 405 | + ) |
| 406 | + self.assertEqual(collist, columns) |
| 407 | + datalist = ( |
| 408 | + volume_fakes.type_name, |
| 409 | + volume_fakes.qos_consumer, |
| 410 | + volume_fakes.qos_id, |
| 411 | + volume_fakes.qos_name, |
| 412 | + utils.format_dict(volume_fakes.qos_specs), |
| 413 | + ) |
| 414 | + self.assertEqual(datalist, tuple(data)) |
| 415 | + |
| 416 | + |
319 | 417 | class TestQosUnset(TestQos): |
320 | 418 | def setUp(self): |
321 | 419 | super(TestQosUnset, self).setUp() |
|
0 commit comments