|
16 | 16 | """ |
17 | 17 |
|
18 | 18 | # isort: STDLIB |
| 19 | +from unittest.mock import patch |
19 | 20 | from uuid import uuid4 |
20 | 21 |
|
21 | 22 | # isort: FIRSTPARTY |
22 | | -from dbus_client_gen import DbusClientUniqueResultError |
| 23 | +from dbus_client_gen import DbusClientMissingPropertyError, DbusClientUniqueResultError |
23 | 24 |
|
24 | 25 | # isort: LOCAL |
25 | 26 | from stratis_cli import StratisCliErrorCodes |
@@ -316,3 +317,46 @@ def test_list_detail(self): |
316 | 317 | Test detail view on running pool. |
317 | 318 | """ |
318 | 319 | TEST_RUNNER(self._MENU + [f"--name={self._POOLNAME}"]) |
| 320 | + |
| 321 | + def test_list_volume_key_loaded_raises_detail(self): |
| 322 | + """ |
| 323 | + Test with _volume_key_loaded raising DbusClientMissingPropertyError, |
| 324 | + in detail view. |
| 325 | + """ |
| 326 | + |
| 327 | + # isort: LOCAL |
| 328 | + import stratis_cli # pylint: disable=import-outside-toplevel |
| 329 | + |
| 330 | + with patch.object( |
| 331 | + # pylint: disable=protected-access |
| 332 | + stratis_cli._actions._list_pool.Default, # pyright: ignore |
| 333 | + "_volume_key_loaded", |
| 334 | + autospec=True, |
| 335 | + side_effect=DbusClientMissingPropertyError( |
| 336 | + "oops", |
| 337 | + stratis_cli._actions._constants.POOL_INTERFACE, # pyright: ignore |
| 338 | + "VolumeKeyLoaded", |
| 339 | + ), |
| 340 | + ): |
| 341 | + TEST_RUNNER(self._MENU + [f"--name={self._POOLNAME}"]) |
| 342 | + |
| 343 | + def test_list_volume_key_loaded_raises(self): |
| 344 | + """ |
| 345 | + Test with _volume_key_loaded raising DbusClientMissingPropertyError. |
| 346 | + """ |
| 347 | + |
| 348 | + # isort: LOCAL |
| 349 | + import stratis_cli # pylint: disable=import-outside-toplevel |
| 350 | + |
| 351 | + with patch.object( |
| 352 | + # pylint: disable=protected-access |
| 353 | + stratis_cli._actions._list_pool.Default, # pyright: ignore |
| 354 | + "_volume_key_loaded", |
| 355 | + autospec=True, |
| 356 | + side_effect=DbusClientMissingPropertyError( |
| 357 | + "oops", |
| 358 | + stratis_cli._actions._constants.POOL_INTERFACE, # pyright: ignore |
| 359 | + "VolumeKeyLoaded", |
| 360 | + ), |
| 361 | + ): |
| 362 | + TEST_RUNNER(self._MENU) |
0 commit comments