[Pkg-nagios-changes] [SCM] UNNAMED PROJECT branch, debian/master, updated. 810edbdd3feedbfe37f4a65bee50b57b2f60fa2a

Naparuba naparuba at gmail.com
Tue Feb 28 22:13:11 UTC 2012


The following commit has been merged in the debian/master branch:
commit fb0e6013be171f1478a84e4935c462b7d4f95c16
Author: Naparuba <naparuba at gmail.com>
Date:   Wed Jan 11 14:24:48 2012 +0100

    fix : last notif ways test.

diff --git a/shinken/objects/contact.py b/shinken/objects/contact.py
index 061817f..88f7248 100644
--- a/shinken/objects/contact.py
+++ b/shinken/objects/contact.py
@@ -107,7 +107,7 @@ class Contact(Item):
 
     # Search for notification_options with state and if t is
     # in service_notification_period
-    def want_service_notification(self, t, state, type, business_impact, cmd):
+    def want_service_notification(self, t, state, type, business_impact, cmd=None):
         if not self.service_notifications_enabled:
             return False
 
@@ -123,13 +123,13 @@ class Contact(Item):
             if nw_b:
                 return True
 
-        #Oh... no one is ok for it? so no, sorry
+        # Oh... no one is ok for it? so no, sorry
         return False
 
 
     #Search for notification_options with state and if t is in
     #host_notification_period
-    def want_host_notification(self, t, state, type, business_impact, cmd):
+    def want_host_notification(self, t, state, type, business_impact, cmd=None):
         if not self.host_notifications_enabled:
             return False
 
diff --git a/shinken/objects/notificationway.py b/shinken/objects/notificationway.py
index 301d5c6..554cf77 100644
--- a/shinken/objects/notificationway.py
+++ b/shinken/objects/notificationway.py
@@ -67,13 +67,13 @@ class NotificationWay(Item):
 
     #Search for notification_options with state and if t is
     #in service_notification_period
-    def want_service_notification(self, t, state, type, business_impact, cmd):
+    def want_service_notification(self, t, state, type, business_impact, cmd=None):
         if not self.service_notifications_enabled:
             return False
 
         # Maybe the command we ask for are not for us, but for another notification ways
         # on the same contact. If so, bail out
-        if not cmd in self.service_notification_commands:
+        if cmd and not cmd in self.service_notification_commands:
             return False
 
         # If the business_impact is not high enough, we bail out
@@ -105,7 +105,7 @@ class NotificationWay(Item):
 
     #Search for notification_options with state and if t is in
     #host_notification_period
-    def want_host_notification(self, t, state, type, business_impact, cmd):
+    def want_host_notification(self, t, state, type, business_impact, cmd=None):
         if not self.host_notifications_enabled:
             return False
 
@@ -115,7 +115,7 @@ class NotificationWay(Item):
 
         # Maybe the command we ask for are not for us, but for another notification ways
         # on the same contact. If so, bail out
-        if not cmd in self.host_notification_commands:
+        if cmd and not cmd in self.host_notification_commands:
             return False
 
         b = self.host_notification_period.is_time_valid(t)
diff --git a/test/test_notifway.py b/test/test_notifway.py
index 919175e..b6ccde2 100755
--- a/test/test_notifway.py
+++ b/test/test_notifway.py
@@ -48,11 +48,18 @@ class TestConfig(ShinkenTest):
         for nw in self.sched.notificationways:
             print "\t", nw.notificationway_name
 
+
+
         email_in_day = self.sched.notificationways.find_by_name('email_in_day')
         self.assert_(email_in_day in contact.notificationways)
+        email_s_cmd = email_in_day.service_notification_commands.pop()
+        email_h_cmd = email_in_day.host_notification_commands.pop()
+        
 
         sms_the_night = self.sched.notificationways.find_by_name('sms_the_night')
         self.assert_(sms_the_night in contact.notificationways)
+        sms_s_cmd = sms_the_night.service_notification_commands.pop()
+        sms_h_cmd = sms_the_night.host_notification_commands.pop()
         
         # And check the criticity values
         self.assert_(email_in_day.min_business_impact == 0)
@@ -62,35 +69,40 @@ class TestConfig(ShinkenTest):
         print "Contact notification way(s) :"
         for nw in contact.notificationways:
             print "\t", nw.notificationway_name
+            for c in nw.service_notification_commands:
+                print "\t\t", c.get_name()
+
 
         contact_simple = self.sched.contacts.find_by_name("test_contact_simple")
-        #It's the created notifway for this simple contact
+        # It's the created notifway for this simple contact
         test_contact_simple_inner_notificationway = self.sched.notificationways.find_by_name("test_contact_simple_inner_notificationway")
         print "Simple contact"
         for nw in contact_simple.notificationways:
             print "\t", nw.notificationway_name
+            for c in nw.service_notification_commands:
+                print "\t\t", c.get_name()
         self.assert_(test_contact_simple_inner_notificationway in contact_simple.notificationways)
 
         # we take as criticity a huge value from now
         huge_criticity = 5
 
-        #Now all want* functions
-        #First is ok with warning alerts
+        # Now all want* functions
+        # First is ok with warning alerts
         self.assert_(email_in_day.want_service_notification(now, 'WARNING', 'PROBLEM', huge_criticity) == True)
 
-        #But a SMS is now WAY for warning. When we sleep, we wake up for critical only guy!
+        # But a SMS is now WAY for warning. When we sleep, we wake up for critical only guy!
         self.assert_(sms_the_night.want_service_notification(now, 'WARNING', 'PROBLEM', huge_criticity) == False)
 
-        #Same with contacts now
-        #First is ok for warning in the email_in_day nw
+        # Same with contacts now
+        # First is ok for warning in the email_in_day nw
         self.assert_(contact.want_service_notification(now, 'WARNING', 'PROBLEM', huge_criticity) == True)
-        #Simple is not ok for it
+        # Simple is not ok for it
         self.assert_(contact_simple.want_service_notification(now, 'WARNING', 'PROBLEM', huge_criticity) == False)
 
-        #Then for host notification
-        #First is ok for warning in the email_in_day nw
+        # Then for host notification
+        # First is ok for warning in the email_in_day nw
         self.assert_(contact.want_host_notification(now, 'FLAPPING', 'PROBLEM', huge_criticity) == True)
-        #Simple is not ok for it
+        # Simple is not ok for it
         self.assert_(contact_simple.want_host_notification(now, 'FLAPPING', 'PROBLEM', huge_criticity) == False)
 
         # And now we check that we refuse SMS for a low level criticity

-- 
UNNAMED PROJECT



More information about the Pkg-nagios-changes mailing list