Module: check_mk
Branch: master
Commit: 2e101bb7810eba6483de82fea08234114191a0ee
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2e101bb7810eba…
Author: Óscar Nájera <on(a)mathias-kettner.de>
Date: Mon Sep 24 10:49:19 2018 +0200
Test get_bulk_notification_subject
Change-Id: Iad543ccb3a027b1561bf9c22cc142db80ca6a91a
---
tests/unit/cmk/notifications/test_utils.py | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/tests/unit/cmk/notifications/test_utils.py
b/tests/unit/cmk/notifications/test_utils.py
index cbc54e2..1c7074d 100644
--- a/tests/unit/cmk/notifications/test_utils.py
+++ b/tests/unit/cmk/notifications/test_utils.py
@@ -60,3 +60,21 @@ def test_read_bulk_contents(monkeypatch, capsys):
monkeypatch.setattr('sys.stdin', ('key=val', '\n',
'key2=val2', 'a comment'))
assert utils.read_bulk_contexts() == ({'key': 'val'},
[{'key2': 'val2'}])
assert capsys.readouterr().err == "Invalid line 'a comment' in bulked
notification context\n"
+
+
+(a)pytest.mark.parametrize("contextntext, hosts, result", [
+ ([{
+ "k": "y"
+ }], ["local", "host"], "Check_MK: 1 notifications for 2
hosts"),
+ ([{
+ "k": "y"
+ }, {
+ "l": "p"
+ }], ["first"], "Check_MK: 2 notifications for first"),
+ ([{
+ "PARAMETER_BULK_SUBJECT": "Check_MK: $FOLDER$ gone $COUNT_HOSTS$
host",
+ "HOSTTAGS": "/wato/lan cmk-agent ip-v4 prod site:heute tcp
wato"
+ }], ["first"], "Check_MK: lan gone 1 host"),
+])
+def test_get_bulk_notification_subject(context, hosts, result):
+ assert utils.get_bulk_notification_subject(context, hosts) == result