aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/tc_mauve_configuration_builders_people_list.rb11
-rw-r--r--test/tc_mauve_configuration_builders_person.rb11
-rw-r--r--test/tc_mauve_notification.rb76
3 files changed, 89 insertions, 9 deletions
diff --git a/test/tc_mauve_configuration_builders_people_list.rb b/test/tc_mauve_configuration_builders_people_list.rb
index 61494d8..7e0840f 100644
--- a/test/tc_mauve_configuration_builders_people_list.rb
+++ b/test/tc_mauve_configuration_builders_people_list.rb
@@ -16,13 +16,13 @@ class TcMauveConfigurationBuildersPeopleList < Mauve::UnitTest
def test_people_list
config =<<EOF
-people_list "team sky", %w(
+people_list("team sky", %w(
geraint
edvald
bradley
rigoberto
ben
-)
+))
people_list("garmin-cervelo", %w(
thor
@@ -30,8 +30,10 @@ people_list("garmin-cervelo", %w(
tyler
julian
)) {
- every 20.minutes
- during { working_hours? }
+ notify {
+ every 20.minutes
+ during { working_hours? }
+ }
}
EOF
@@ -40,7 +42,6 @@ EOF
assert_equal(2, x.people_lists.keys.length)
assert_equal(["team sky","garmin-cervelo"].sort,x.people_lists.keys.sort)
assert_equal(%w(geraint edvald bradley rigoberto ben), x.people_lists["team sky"].list)
-
end
def test_duplicate_people_list
diff --git a/test/tc_mauve_configuration_builders_person.rb b/test/tc_mauve_configuration_builders_person.rb
index 391d796..d889a03 100644
--- a/test/tc_mauve_configuration_builders_person.rb
+++ b/test/tc_mauve_configuration_builders_person.rb
@@ -10,12 +10,14 @@ class TcMauveConfigurationBuildersPerson < Mauve::UnitTest
config=<<EOF
person("test1") {
all { "this should email on every level" }
- during { "this is the during block" }
- every 300
email "test1@example.com"
sms "01234567890"
xmpp "test1@chat.example.com"
password "topsekrit"
+ notify {
+ during { "this is the during block" }
+ every 300
+ }
}
EOF
@@ -23,13 +25,14 @@ EOF
assert_nothing_raised { x = Mauve::ConfigurationBuilder.parse(config) }
assert_equal(1, x.people.length)
assert_equal(%w(test1), x.people.keys)
- assert_equal(300, x.people["test1"].every)
assert_equal("test1@example.com", x.people["test1"].email)
assert_equal("01234567890", x.people["test1"].sms)
assert_equal("test1@chat.example.com", x.people["test1"].xmpp)
assert_equal("topsekrit", x.people["test1"].password)
- assert_equal("this is the during block", x.people["test1"].during.call)
+# assert_equal(300, x.people["test1"].every)
+# assert_equal("this is the during block", x.people["test1"].during.call)
+#
assert_equal("this should email on every level", x.people["test1"].urgent.call)
assert_equal("this should email on every level", x.people["test1"].normal.call)
assert_equal("this should email on every level", x.people["test1"].low.call)
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