@@ -60,7 +60,7 @@ def test_sg_gocdb_to_contacts_notify_flag(self):
6060 exp_json = json .loads (json_data )
6161
6262 use_notif_flag = True
63- contacts = argoalert .gocdb_to_contacts (xml_data , use_notif_flag )
63+ contacts = argoalert .gocdb_to_contacts (xml_data , use_notif_flag , None )
6464
6565 self .assertEqual (contacts , exp_json )
6666
@@ -70,7 +70,7 @@ def test_sg_gocdb_to_contacts_notify_flag(self):
7070 exp_json = json .loads (json_data )
7171
7272 use_notif_flag = False
73- contacts = argoalert .gocdb_to_contacts (xml_data , use_notif_flag )
73+ contacts = argoalert .gocdb_to_contacts (xml_data , use_notif_flag , None )
7474
7575 self .assertEqual (contacts , exp_json )
7676
@@ -90,7 +90,7 @@ def test_site_gocdb_to_contacts_notify_flag(self):
9090 exp_json = json .loads (json_data )
9191
9292 use_notif_flag = True
93- contacts = argoalert .gocdb_to_contacts (xml_data , use_notif_flag )
93+ contacts = argoalert .gocdb_to_contacts (xml_data , use_notif_flag , None )
9494
9595 self .assertEqual (contacts , exp_json )
9696
@@ -100,7 +100,7 @@ def test_site_gocdb_to_contacts_notify_flag(self):
100100 exp_json = json .loads (json_data )
101101
102102 use_notif_flag = False
103- contacts = argoalert .gocdb_to_contacts (xml_data , use_notif_flag )
103+ contacts = argoalert .gocdb_to_contacts (xml_data , use_notif_flag , None )
104104
105105 self .assertEqual (contacts , exp_json )
106106
@@ -139,4 +139,46 @@ def test_site_contacts_to_alerta(self):
139139 exp_out = json .dumps (exp_json , sort_keys = True )
140140 self .assertEqual (rules_out , exp_out )
141141
142+ # Test gocdb xml with test emails to final rules
143+ def test_site_gocdb_test_mails (self ):
144+ xml_fn = "./tests/files/site_gocdb.xml"
145+ site_rules_fn = "./tests/files/site_rules_test_emails.json"
146+
147+ with open (xml_fn , 'r' ) as xml_file :
148+ xml_data = xml_file .read ().replace ('\n ' , '' )
149+
150+ # Select contacts using notification flag on
151+ with open (site_rules_fn , 'r' ) as json_file :
152+ json_data = json_file .read ().replace ('\n ' , '' )
153+ exp_json = json .loads (json_data )
154+
155+ use_notif_flag = True
156+ test_emails = ["test1@email.foo" , "test2@email.foo" , "test3@email.foo" ]
157+ contacts = argoalert .gocdb_to_contacts (xml_data , use_notif_flag , test_emails )
158+
159+ rules = argoalert .contacts_to_alerta (contacts )
160+ print rules
161+ self .assertEqual (exp_json , rules )
162+
163+ # Test gocdb xml with test emails to final rules
164+ def test_sg_gocdb_test_mails (self ):
165+ xml_fn = "./tests/files/sg_gocdb.xml"
166+ site_rules_fn = "./tests/files/sg_rules_test_emails.json"
167+
168+ with open (xml_fn , 'r' ) as xml_file :
169+ xml_data = xml_file .read ().replace ('\n ' , '' )
170+
171+ # Select contacts using notification flag on
172+ with open (site_rules_fn , 'r' ) as json_file :
173+ json_data = json_file .read ().replace ('\n ' , '' )
174+ exp_json = json .loads (json_data )
175+
176+ use_notif_flag = True
177+ test_emails = ["test1@email.foo" , "test2@email.foo" ]
178+ contacts = argoalert .gocdb_to_contacts (xml_data , use_notif_flag , test_emails )
179+
180+ rules = argoalert .contacts_to_alerta (contacts )
181+ print rules
182+ self .assertEqual (exp_json , rules )
183+
142184
0 commit comments