def test_multiple_alerts(self): self.config.env.push_cib(remove=[ "./configuration/alerts/alert[@id='alert1']", "./configuration/alerts/alert[@id='alert3']", "./configuration/alerts/alert[@id='alert4']", ]) cmd_alert.remove_alert(self.env_assist.get_env(), ["alert1", "alert3", "alert4"])
def test_one_alert(self): self.config.env.push_cib( remove="./configuration/alerts/alert[@id='alert2']" ) cmd_alert.remove_alert( self.env_assist.get_env(), ["alert2"] )
def test_success(self): cmd_alert.remove_alert(self.mock_env, "alert") assert_xml_equal( """ <cib validate-with="pacemaker-2.5"> <configuration> <alerts> <alert id="alert-1" path="/path"/> </alerts> </configuration> </cib> """, self.mock_env._get_cib_xml())
def test_multiple_alerts(self): self.config.env.push_cib( remove=[ "./configuration/alerts/alert[@id='alert1']", "./configuration/alerts/alert[@id='alert3']", "./configuration/alerts/alert[@id='alert4']", ] ) cmd_alert.remove_alert( self.env_assist.get_env(), ["alert1", "alert3", "alert4"] )
def test_multiple_alerts(self): cmd_alert.remove_alert(self.mock_env, ["alert1", "alert3", "alert4"]) assert_xml_equal( """ <cib validate-with="pacemaker-2.5"> <configuration> <alerts> <alert id="alert2" path="/path"/> </alerts> </configuration> </cib> """, self.mock_env._get_cib_xml()) self.assertEqual([], self.mock_rep.report_item_list)
def test_success(self): cmd_alert.remove_alert(self.mock_env, "alert") assert_xml_equal( """ <cib validate-with="pacemaker-2.5"> <configuration> <alerts> <alert id="alert-1" path="/path"/> </alerts> </configuration> </cib> """, self.mock_env._get_cib_xml() )
def test_multiple_alerts(self): cmd_alert.remove_alert(self.mock_env, ["alert1", "alert3", "alert4"]) assert_xml_equal( """ <cib validate-with="pacemaker-2.5"> <configuration> <alerts> <alert id="alert2" path="/path"/> </alerts> </configuration> </cib> """, self.mock_env._get_cib_xml() ) self.assertEqual([], self.mock_rep.report_item_list)
def test_alerts_dont_exist(self): self.env_assist.assert_raise_library_error( lambda: cmd_alert.remove_alert( self.env_assist.get_env(), ["unknown1", "alert1", "unknown2", "alert2"] ), [ ( Severities.ERROR, report_codes.ID_NOT_FOUND, { "context_type": "alerts", "context_id": "", "id": "unknown1", "expected_types": ["alert"], }, None ), ( Severities.ERROR, report_codes.ID_NOT_FOUND, { "context_type": "alerts", "context_id": "", "id": "unknown2", "expected_types": ["alert"], }, None ), ], expected_in_processor=True )
def test_alerts_dont_exist(self): self.env_assist.assert_raise_library_error( lambda: cmd_alert.remove_alert( self.env_assist.get_env(), ["unknown1", "alert1", "unknown2", "alert2"], )) self.env_assist.assert_reports([ ( Severities.ERROR, report_codes.ID_NOT_FOUND, { "context_type": "alerts", "context_id": "", "id": "unknown1", "expected_types": ["alert"], }, None, ), ( Severities.ERROR, report_codes.ID_NOT_FOUND, { "context_type": "alerts", "context_id": "", "id": "unknown2", "expected_types": ["alert"], }, None, ), ])
def test_not_existing_alert(self): assert_raise_library_error( lambda: cmd_alert.remove_alert(self.mock_env, "unknown"), ( Severities.ERROR, report_codes.CIB_ALERT_NOT_FOUND, {"alert": "unknown"} ) )
def test_failure(self): report_list = [(Severities.ERROR, report_codes.ID_NOT_FOUND, { "id": "unknown" }), (Severities.ERROR, report_codes.ID_NOT_FOUND, { "id": "unknown2" })] assert_raise_library_error( lambda: cmd_alert.remove_alert( self.mock_env, ["unknown", "alert1", "unknown2", "alert2"]), *report_list) assert_report_item_list_equal(self.mock_rep.report_item_list, report_list)
def test_alerts_dont_exist(self): self.env_assist.assert_raise_library_error( lambda: cmd_alert.remove_alert(self.env_assist.get_env( ), ["unknown1", "alert1", "unknown2", "alert2"]), [ (Severities.ERROR, report_codes.ID_NOT_FOUND, { "context_type": "alerts", "context_id": "", "id": "unknown1", "id_description": "alert", }, None), (Severities.ERROR, report_codes.ID_NOT_FOUND, { "context_type": "alerts", "context_id": "", "id": "unknown2", "id_description": "alert", }, None), ], expected_in_processor=True)
def test_failure(self): report_list = [ ( Severities.ERROR, report_codes.ID_NOT_FOUND, {"id": "unknown"} ), ( Severities.ERROR, report_codes.ID_NOT_FOUND, {"id": "unknown2"} ) ] assert_raise_library_error( lambda: cmd_alert.remove_alert( self.mock_env, ["unknown", "alert1", "unknown2", "alert2"] ), *report_list ) assert_report_item_list_equal( self.mock_rep.report_item_list, report_list )
def test_no_alert(self): self.config.env.push_cib() cmd_alert.remove_alert(self.env_assist.get_env(), [])
def test_no_alert(self): self.config.env.push_cib() cmd_alert.remove_alert( self.env_assist.get_env(), [] )
def test_not_existing_alert(self): assert_raise_library_error( lambda: cmd_alert.remove_alert(self.mock_env, "unknown"), (Severities.ERROR, report_codes.CIB_ALERT_NOT_FOUND, { "alert": "unknown" }))