mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-10-02 02:35:05 -04:00
fix: use valid notification fallback log level
Co-authored-by: jokob-sk <96159884+jokob-sk@users.noreply.github.com>
This commit is contained in:
1 parent
44ed53cb69
commit
13da2ddbf1
3 files changed
+8
-2
No files matched your search
@@ -24,6 +24,7 @@ description: NetAlertX coding standards and conventions. Use this when writing c
|
||||
- follow existing code style and structure, and ensure backward compatibility with existing installations when submitting PRs
|
||||
- all code needs to be scalable to handle large networks with thousands of devices (10k+) without performance degradation
|
||||
- no inline imports, all imports must be at the top of the file
|
||||
- when using `server/logger.py` `mylog()`, only use valid levels: `none`, `minimal`, `verbose`, `debug`, `trace`; invalid levels silently degrade to `none`
|
||||
|
||||
|
||||
## File Length
|
||||
|
||||
@@ -421,7 +421,7 @@ def finalize_html(mail_html, preheaders):
|
||||
)
|
||||
except XMLTokenError as err:
|
||||
mylog(
|
||||
"warn",
|
||||
"none",
|
||||
f"[Notification] Failed to pretty-print HTML report, sending unindented HTML instead: {err}",
|
||||
)
|
||||
return mail_html
|
||||
|
||||
@@ -334,8 +334,9 @@ class TestConstructNotificationsTemplates(unittest.TestCase):
|
||||
# -----------------------------------------------------------------
|
||||
# Final HTML escapes preheaders and tolerates indent failures
|
||||
# -----------------------------------------------------------------
|
||||
@patch("models.notification_instance.mylog")
|
||||
@patch("models.notification_instance.indent")
|
||||
def test_finalize_html_escapes_preheader_and_falls_back(self, mock_indent):
|
||||
def test_finalize_html_escapes_preheader_and_falls_back(self, mock_indent, mock_mylog):
|
||||
from models.notification_instance import finalize_html, XMLTokenError
|
||||
|
||||
mock_indent.side_effect = XMLTokenError("broken html")
|
||||
@@ -351,6 +352,10 @@ class TestConstructNotificationsTemplates(unittest.TestCase):
|
||||
|
||||
self.assertEqual(final_html, expected_html)
|
||||
mock_indent.assert_called_once()
|
||||
mock_mylog.assert_called_once_with(
|
||||
"none",
|
||||
"[Notification] Failed to pretty-print HTML report, sending unindented HTML instead: broken html",
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in new issue
Block a user