forked from teemtee/tmt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Require --feeling-safe for local provisioning (teemtee#3103)
- Loading branch information
1 parent
26a265b
commit 0fc9c26
Showing
6 changed files
with
89 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from unittest.mock import MagicMock, patch | ||
|
||
import pytest | ||
|
||
import tmt | ||
from tmt.steps import Phase | ||
from tmt.utils import GeneralError | ||
|
||
|
||
class TestPhaseAssertFeelingSafe: | ||
|
||
def setup_method(self): | ||
self.mock_logger = MagicMock() | ||
self.phase = Phase(logger=self.mock_logger) | ||
|
||
@pytest.mark.parametrize( | ||
("tmt_version", "deprecated_version", "expect_warn", "expect_exception"), [ | ||
('1.30', '1.38', True, False), # warn for older version | ||
('1.40', '1.38', False, True), # raise exception for newer version | ||
('1.38', '1.38', False, True) # raise exception for same version | ||
]) | ||
def test_assert_feeling_safe( | ||
self, | ||
tmt_version, | ||
deprecated_version, | ||
expect_warn, | ||
expect_exception): | ||
with patch.object(self.phase, 'warn') as mock_warn: | ||
tmt.__version__ = tmt_version | ||
|
||
if expect_exception: | ||
with pytest.raises(GeneralError): | ||
self.phase.assert_feeling_safe(deprecated_version, 'Local provision plugin') | ||
else: | ||
self.phase.assert_feeling_safe(deprecated_version, 'Local provision plugin') | ||
|
||
assert mock_warn.called == expect_warn | ||
|
||
def test_assert_feeling_safe_feeling_safe(self): | ||
with (patch.object(Phase, 'is_feeling_safe', True), | ||
patch.object(self.phase, 'warn') as mock_warn): | ||
tmt.__version__ = '1.40' | ||
self.phase.assert_feeling_safe('1.38', 'Local provision plugin') | ||
|
||
# Check that warn is not called when feeling safe | ||
assert not mock_warn.called |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters