diff --git a/tests/integration/pool/test_add.py b/tests/integration/pool/test_add.py index 6540428b4..b4e5935db 100644 --- a/tests/integration/pool/test_add.py +++ b/tests/integration/pool/test_add.py @@ -154,6 +154,32 @@ def test_add_data_cache(self): _ERROR, ) + def test_add_data_cache_mock_check(self): + """ + Test that adding 1 data device that is already in the cache tier raises + an exception. + """ + devices = _DEVICE_STRATEGY() + command_line = ( + ["--propagate", "pool", "init-cache"] + [self._POOLNAME] + devices + ) + RUNNER(command_line) + # isort: LOCAL + import stratis_cli # pylint: disable=import-outside-toplevel + + with patch.object( + # pylint: disable=protected-access + stratis_cli._actions._pool, # pyright: ignore + "_check_opposite_tier", + autospec=True, + return_value=None, + ): + self.check_error( + StratisCliEngineError, + self._MENU + [self._POOLNAME] + devices, + _ERROR, + ) + def test_add_data_cache_2(self): """ Test that adding multiple (2) data devices that are already in the cache tier raises @@ -281,6 +307,24 @@ def test_add_cache_data(self): command_line = self._MENU + [self._POOLNAME] + self._DEVICES self.check_error(StratisCliInUseOtherTierError, command_line, _ERROR) + def test_add_cache_data_mock_check(self): + """ + Test that adding 1 cache device that is already in the data tier raises + an exception. + """ + command_line = self._MENU + [self._POOLNAME] + self._DEVICES + # isort: LOCAL + import stratis_cli # pylint: disable=import-outside-toplevel + + with patch.object( + # pylint: disable=protected-access + stratis_cli._actions._pool, # pyright: ignore + "_check_opposite_tier", + autospec=True, + return_value=None, + ): + self.check_error(StratisCliEngineError, command_line, _ERROR) + class AddCacheTestCase2(SimTestCase): """