def test_one_recipient(self): self.config.env.push_cib( remove="./configuration/alerts/alert/recipient[@id='alert-recip1']" ) cmd_alert.remove_recipient( self.env_assist.get_env(), ["alert-recip1"] )
def test_multiple_recipients(self): self.config.env.push_cib(remove=[ "./configuration/alerts/alert/recipient[@id='alert-recip1']", "./configuration/alerts/alert/recipient[@id='alert-recip2']", "./configuration/alerts/alert/recipient[@id='alert2-recip4']", ]) cmd_alert.remove_recipient( self.env_assist.get_env(), ["alert-recip1", "alert-recip2", "alert2-recip4"])
def test_multiple_recipients(self): self.config.env.push_cib( remove=[ "./configuration/alerts/alert/recipient[@id='alert-recip1']", "./configuration/alerts/alert/recipient[@id='alert-recip2']", "./configuration/alerts/alert/recipient[@id='alert2-recip4']", ] ) cmd_alert.remove_recipient( self.env_assist.get_env(), ["alert-recip1", "alert-recip2", "alert2-recip4"] )
def test_success(self): cmd_alert.remove_recipient(self.mock_env, "alert-recipient") assert_xml_equal( """ <cib validate-with="pacemaker-2.5"> <configuration> <alerts> <alert id="alert" path="path"> <recipient id="alert-recipient-1" value="value"/> </alert> </alerts> </configuration> </cib> """, self.mock_env._get_cib_xml())
def test_recipient_not_found(self): self.env_assist.assert_raise_library_error( lambda: cmd_alert.remove_recipient( self.env_assist.get_env(), ["recipient", "alert-recip1", "alert2-recip1"], )) self.env_assist.assert_reports([ ( Severities.ERROR, report_codes.ID_NOT_FOUND, { "id": "recipient", "expected_types": ["recipient"], "context_type": "alerts", "context_id": "", }, None, ), ( Severities.ERROR, report_codes.ID_NOT_FOUND, { "id": "alert2-recip1", "expected_types": ["recipient"], "context_type": "alerts", "context_id": "", }, None, ), ])
def test_success(self): cmd_alert.remove_recipient(self.mock_env, "alert-recipient") assert_xml_equal( """ <cib validate-with="pacemaker-2.5"> <configuration> <alerts> <alert id="alert" path="path"> <recipient id="alert-recipient-1" value="value"/> </alert> </alerts> </configuration> </cib> """, self.mock_env._get_cib_xml() )
def test_multiple_recipients(self): cmd_alert.remove_recipient( self.mock_env, ["alert-recipient1", "alert-recipient2", "alert2-recipient4"]) assert_xml_equal( """ <cib validate-with="pacemaker-2.5"> <configuration> <alerts> <alert id="alert" path="path"/> <alert id="alert2" path="path"> <recipient id="alert2-recipient3" value="value3"/> </alert> </alerts> </configuration> </cib> """, self.mock_env._get_cib_xml()) self.assertEqual([], self.mock_rep.report_item_list)
def test_recipient_not_found(self): self.env_assist.assert_raise_library_error( lambda: cmd_alert.remove_recipient(self.env_assist.get_env( ), ["recipient", "alert-recip1", "alert2-recip1"]), [(Severities.ERROR, report_codes.ID_NOT_FOUND, { "id": "recipient" }, None), (Severities.ERROR, report_codes.ID_NOT_FOUND, { "id": "alert2-recip1" }, None)], expected_in_processor=True)
def test_recipient_not_found(self): assert_raise_library_error( lambda: cmd_alert.remove_recipient( self.mock_env, "recipient" ), ( Severities.ERROR, report_codes.ID_NOT_FOUND, {"id": "recipient"} ) )
def test_multiple_recipients(self): cmd_alert.remove_recipient( self.mock_env, ["alert-recipient1", "alert-recipient2", "alert2-recipient4"] ) assert_xml_equal( """ <cib validate-with="pacemaker-2.5"> <configuration> <alerts> <alert id="alert" path="path"/> <alert id="alert2" path="path"> <recipient id="alert2-recipient3" value="value3"/> </alert> </alerts> </configuration> </cib> """, self.mock_env._get_cib_xml() ) self.assertEqual([], self.mock_rep.report_item_list)
def test_recipient_not_found(self): report_list = [(Severities.ERROR, report_codes.ID_NOT_FOUND, { "id": "recipient" }), (Severities.ERROR, report_codes.ID_NOT_FOUND, { "id": "alert2-recipient1" })] assert_raise_library_error( lambda: cmd_alert.remove_recipient(self.mock_env, [ "recipient", "alert-recipient1", "alert2-recipient1" ]), *report_list) assert_report_item_list_equal(self.mock_rep.report_item_list, report_list)
def test_recipient_not_found(self): self.env_assist.assert_raise_library_error( lambda: cmd_alert.remove_recipient( self.env_assist.get_env(), ["recipient", "alert-recip1", "alert2-recip1"] ), [ ( Severities.ERROR, report_codes.ID_NOT_FOUND, {"id": "recipient"}, None ), ( Severities.ERROR, report_codes.ID_NOT_FOUND, {"id": "alert2-recip1"}, None ) ], expected_in_processor=True )
def test_recipient_not_found(self): report_list = [ ( Severities.ERROR, report_codes.ID_NOT_FOUND, {"id": "recipient"} ), ( Severities.ERROR, report_codes.ID_NOT_FOUND, {"id": "alert2-recipient1"} ) ] assert_raise_library_error( lambda: cmd_alert.remove_recipient( self.mock_env, ["recipient", "alert-recipient1", "alert2-recipient1"] ), *report_list ) assert_report_item_list_equal( self.mock_rep.report_item_list, report_list )
def test_no_recipient(self): self.config.env.push_cib() cmd_alert.remove_recipient( self.env_assist.get_env(), [] )
def test_no_recipient(self): self.config.env.push_cib() cmd_alert.remove_recipient(self.env_assist.get_env(), [])
def test_recipient_not_found(self): assert_raise_library_error( lambda: cmd_alert.remove_recipient(self.mock_env, "recipient"), (Severities.ERROR, report_codes.ID_NOT_FOUND, { "id": "recipient" }))