Exemplo n.º 1
0
 def test_not_exist(self):
     xml = """
         <cib>
             <configuration>
                 <alerts>
                     <alert id="alert-1"/>
                 </alerts>
             </configuration>
         </cib>
     """
     assert_raise_library_error(
         lambda: alert.get_alert_by_id(etree.XML(xml), "alert-2"),
         (severities.ERROR, report_codes.CIB_ALERT_NOT_FOUND, {
             "alert": "alert-2"
         }))
Exemplo n.º 2
0
 def test_found(self):
     xml = """
         <cib>
             <configuration>
                 <alerts>
                     <alert id="alert-1"/>
                     <alert id="alert-2"/>
                 </alerts>
             </configuration>
         </cib>
     """
     assert_xml_equal(
         '<alert id="alert-2"/>',
         etree.tostring(alert.get_alert_by_id(etree.XML(xml),
                                              "alert-2")).decode())
Exemplo n.º 3
0
 def test_found(self):
     xml = """
         <cib>
             <configuration>
                 <alerts>
                     <alert id="alert-1"/>
                     <alert id="alert-2"/>
                 </alerts>
             </configuration>
         </cib>
     """
     assert_xml_equal(
         '<alert id="alert-2"/>',
         etree.tostring(
             alert.get_alert_by_id(etree.XML(xml), "alert-2")
         ).decode()
     )
Exemplo n.º 4
0
 def test_not_exist(self):
     xml = """
         <cib>
             <configuration>
                 <alerts>
                     <alert id="alert-1"/>
                 </alerts>
             </configuration>
         </cib>
     """
     assert_raise_library_error(
         lambda: alert.get_alert_by_id(etree.XML(xml), "alert-2"),
         (
             severities.ERROR,
             report_codes.CIB_ALERT_NOT_FOUND,
             {"alert": "alert-2"}
         )
     )