Files
pepperplus-cb/test/unit/logging/test_file_handler.py
Twirre Meulenbelt 4cda4e5e70 feat: experiment log stream, to file and UI
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
2026-01-15 17:07:49 +01:00

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