diff options
author | Patrick J Cherry <patrick@bytemark.co.uk> | 2012-04-23 16:01:44 +0100 |
---|---|---|
committer | Patrick J Cherry <patrick@bytemark.co.uk> | 2012-04-23 16:01:44 +0100 |
commit | 6561f886ed03a79ca035a1733816ab97380576d2 (patch) | |
tree | 24282c1a9f85a6a1f1eb010df7c421f3c08315bb /test/tc_mauve_notification.rb | |
parent | ca99b0dff974d2fc841d7132d03b3ad1d1bf9b1e (diff) |
Persons/PeopleLists can now specify multiple notification preferences.
Diffstat (limited to 'test/tc_mauve_notification.rb')
-rw-r--r-- | test/tc_mauve_notification.rb | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/test/tc_mauve_notification.rb b/test/tc_mauve_notification.rb index 7ff0d79..16b6489 100644 --- a/test/tc_mauve_notification.rb +++ b/test/tc_mauve_notification.rb @@ -403,4 +403,80 @@ EOF end + def test_individual_notification_preferences + config=<<EOF +server { + use_notification_buffer false +} + +notification_method("email") { + debug! + deliver_to_queue [] + disable_normal_delivery! +} + +person ("test1") { + email "test1@example.com" + all { email } + notify { + every 300 + during { !working_hours? } + } +} + +person ("test2") { + email "test2@example.com" + all { email } + notify { + every 300 + during { working_hours? } + } +} + +alert_group("test") { + level URGENT + notify("test1") + notify("test2") +} + +EOF + + Configuration.current = ConfigurationBuilder.parse(config) + notification_buffer = Configuration.current.notification_methods["email"].deliver_to_queue + + Server.instance.setup + + alert = Alert.new( + :alert_id => "test", + :source => "test", + :subject => "test" + ) + + # + # This should only alert test1 + # + alert.raise! + assert_equal(1, notification_buffer.size, "Wrong number of notifications sent") + assert_equal("test1@example.com", notification_buffer.pop[2]) + + alert.clear! + assert_equal(1, notification_buffer.size, "Wrong number of notifications sent") + assert_equal("test1@example.com", notification_buffer.pop[2]) + + # + # Wind forward to 9am (working hours) + # + Timecop.freeze(Time.now+9.hours) + assert(Time.now.working_hours?) + alert.raise! + assert_equal(1, notification_buffer.size, "Wrong number of notifications sent") + assert_equal("test2@example.com", notification_buffer.pop[2]) + + alert.clear! + assert_equal(1, notification_buffer.size, "Wrong number of notifications sent") + assert_equal("test2@example.com", notification_buffer.pop[2]) + + + end + end |