-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Merge pull request #142 from thorinaboenke/132_increasing_logs
132 append to log files
Showing
4 changed files
with
60 additions
and
13 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
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,33 @@ | ||
import pytest | ||
from unittest.mock import patch, MagicMock | ||
from attackmate.logging_setup import create_file_handler | ||
|
||
|
||
@patch('attackmate.logging_setup.logging.FileHandler') | ||
def test_create_file_handler_append_mode(MockFileHandler): | ||
mock_handler = MagicMock() | ||
MockFileHandler.return_value = mock_handler | ||
|
||
file_name = 'test.log' | ||
append_logs = True | ||
formatter = MagicMock() | ||
|
||
create_file_handler(file_name, append_logs, formatter) | ||
|
||
MockFileHandler.assert_called_with(file_name, mode='a') | ||
mock_handler.setFormatter.assert_called_with(formatter) | ||
|
||
|
||
@patch('attackmate.logging_setup.logging.FileHandler') | ||
def test_create_file_handler_write_mode(MockFileHandler): | ||
mock_handler = MagicMock() | ||
MockFileHandler.return_value = mock_handler | ||
|
||
file_name = 'test.log' | ||
append_logs = False | ||
formatter = MagicMock() | ||
|
||
create_file_handler(file_name, append_logs, formatter) | ||
|
||
MockFileHandler.assert_called_with(file_name, mode='w') | ||
mock_handler.setFormatter.assert_called_with(formatter) |