Adds a few new logging utility classes. One to save to files with a date, one to support optional fields in formats, last to filter partial log messages. ref: N25B-401
19 lines
593 B
Python
19 lines
593 B
Python
from unittest.mock import MagicMock, patch
|
|
|
|
from control_backend.logging.dated_file_handler import DatedFileHandler
|
|
|
|
|
|
@patch("control_backend.logging.file_handler.DatedFileHandler._open")
|
|
def test_reset(open_):
|
|
stream = MagicMock()
|
|
open_.return_value = stream
|
|
|
|
# A file should be opened when the logger is created
|
|
handler = DatedFileHandler(prefix="anything")
|
|
assert open_.call_count == 1
|
|
|
|
# Upon reset, the current file should be closed, and a new one should be opened
|
|
handler.do_rollover()
|
|
assert stream.close.call_count == 1
|
|
assert open_.call_count == 2
|