Skip to content

Commit e419d22

Browse files
pUrGe12arkid15r
andauthored
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>
1 parent 04c2097 commit e419d22

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/core/test_die.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from io import StringIO
2+
from unittest.mock import patch
3+
4+
from nettacker.core.die import die_success, die_failure
5+
from nettacker.logger import TerminalCodes
6+
7+
8+
@patch("sys.stdout", new_callable=StringIO)
9+
@patch("sys.exit")
10+
def test_die_success(mock_exit, mock_stdout):
11+
reset_code = TerminalCodes.RESET.value
12+
die_success()
13+
success_message = mock_stdout.getvalue()
14+
assert reset_code in success_message
15+
mock_exit.assert_called_once_with(0)
16+
17+
18+
@patch("sys.stdout", new_callable=StringIO)
19+
@patch("sys.exit")
20+
def test_die_failure(mock_exit, mock_stdout):
21+
test_message = "Test error message"
22+
die_failure(test_message)
23+
error_message = mock_stdout.getvalue()
24+
assert test_message in error_message
25+
mock_exit.assert_called_once_with(1)

0 commit comments

Comments
 (0)