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" }))
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())
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() )
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"} ) )