mirror of https://github.com/OWASP/Nettacker.git
Add die.py tests (#1042)
* created tests for die.py * updated * migrate to pytest * Update deps * Revert poetry.lock --------- Signed-off-by: Achintya Jai <153343775+pUrGe12@users.noreply.github.com> Co-authored-by: Arkadii Yakovets <2201626+arkid15r@users.noreply.github.com> Co-authored-by: Arkadii Yakovets <arkadii.yakovets@owasp.org>
This commit is contained in:
parent
04c2097fbe
commit
e419d227c2
|
|
@ -0,0 +1,25 @@
|
|||
from io import StringIO
|
||||
from unittest.mock import patch
|
||||
|
||||
from nettacker.core.die import die_success, die_failure
|
||||
from nettacker.logger import TerminalCodes
|
||||
|
||||
|
||||
@patch("sys.stdout", new_callable=StringIO)
|
||||
@patch("sys.exit")
|
||||
def test_die_success(mock_exit, mock_stdout):
|
||||
reset_code = TerminalCodes.RESET.value
|
||||
die_success()
|
||||
success_message = mock_stdout.getvalue()
|
||||
assert reset_code in success_message
|
||||
mock_exit.assert_called_once_with(0)
|
||||
|
||||
|
||||
@patch("sys.stdout", new_callable=StringIO)
|
||||
@patch("sys.exit")
|
||||
def test_die_failure(mock_exit, mock_stdout):
|
||||
test_message = "Test error message"
|
||||
die_failure(test_message)
|
||||
error_message = mock_stdout.getvalue()
|
||||
assert test_message in error_message
|
||||
mock_exit.assert_called_once_with(1)
|
||||
Loading…
Reference in New Issue