def test_with_id(self): cmd_alert.add_recipient( self.mock_env, "alert", "value", {"attr1": "val1"}, { "attr2": "val2", "attr1": "val1" }, recipient_id="my-recipient" ) assert_xml_equal( """ <cib validate-with="pacemaker-2.5"> <configuration> <alerts> <alert id="alert" path="path"> <recipient id="alert-recipient" value="value1"/> <recipient id="my-recipient" value="value"> <meta_attributes id="my-recipient-meta_attributes" > <nvpair id="my-recipient-meta_attributes-attr1" name="attr1" value="val1" /> <nvpair id="my-recipient-meta_attributes-attr2" name="attr2" value="val2" /> </meta_attributes> <instance_attributes id="my-recipient-instance_attributes" > <nvpair id="my-recipient-instance_attributes-attr1" name="attr1" value="val1" /> </instance_attributes> </recipient> </alert> </alerts> </configuration> </cib> """, self.mock_env._get_cib_xml() )
def test_alert_not_found(self): assert_raise_library_error( lambda: cmd_alert.add_recipient(self.mock_env, "unknown", "recipient", {}, {}), (Severities.ERROR, report_codes.CIB_ALERT_NOT_FOUND, { "alert": "unknown" }))
def test_with_id(self): self.config.env.push_cib( replace={ './/alert[@id="alert"]': """ <alert id="alert" path="path"> <recipient id="alert-recipient" value="value1"/> <recipient id="my-recipient" value="value"> <meta_attributes id="my-recipient-meta_attributes" > <nvpair id="my-recipient-meta_attributes-attr1" name="attr1" value="val1" /> <nvpair id="my-recipient-meta_attributes-attr2" name="attr2" value="val2" /> </meta_attributes> <instance_attributes id="my-recipient-instance_attributes" > <nvpair id="my-recipient-instance_attributes-attr1" name="attr1" value="val1" /> </instance_attributes> </recipient> </alert> """ } ) cmd_alert.add_recipient( self.env_assist.get_env(), "alert", "value", {"attr1": "val1"}, { "attr2": "val2", "attr1": "val1" }, recipient_id="my-recipient" )
def test_with_id(self): cmd_alert.add_recipient(self.mock_env, "alert", "value", {"attr1": "val1"}, { "attr2": "val2", "attr1": "val1" }, recipient_id="my-recipient") assert_xml_equal( """ <cib validate-with="pacemaker-2.5"> <configuration> <alerts> <alert id="alert" path="path"> <recipient id="alert-recipient" value="value1"/> <recipient id="my-recipient" value="value"> <meta_attributes id="my-recipient-meta_attributes" > <nvpair id="my-recipient-meta_attributes-attr1" name="attr1" value="val1" /> <nvpair id="my-recipient-meta_attributes-attr2" name="attr2" value="val2" /> </meta_attributes> <instance_attributes id="my-recipient-instance_attributes" > <nvpair id="my-recipient-instance_attributes-attr1" name="attr1" value="val1" /> </instance_attributes> </recipient> </alert> </alerts> </configuration> </cib> """, self.mock_env._get_cib_xml())
def test_recipient_already_exists(self): assert_raise_library_error( lambda: cmd_alert.add_recipient(self.mock_env, "alert", "value1", {}, {}, recipient_id="alert-recipient"), (Severities.ERROR, report_codes.ID_ALREADY_EXISTS, { "id": "alert-recipient" }))
def test_value_not_defined(self): self.config.remove("runner.cib.load") self.env_assist.assert_raise_library_error( lambda: cmd_alert.add_recipient(self.env_assist.get_env(), "unknown", "", {}, {}), [(Severities.ERROR, report_codes.REQUIRED_OPTIONS_ARE_MISSING, { "option_names": ["value"] })], )
def test_value_not_defined(self): assert_raise_library_error( lambda: cmd_alert.add_recipient( self.mock_env, "unknown", "", {}, {} ), ( Severities.ERROR, report_codes.REQUIRED_OPTION_IS_MISSING, {"option_name": "value"} ) )
def test_alert_not_found(self): assert_raise_library_error( lambda: cmd_alert.add_recipient( self.mock_env, "unknown", "recipient", {}, {} ), ( Severities.ERROR, report_codes.CIB_ALERT_NOT_FOUND, {"alert": "unknown"} ) )
def test_recipient_already_exists(self): assert_raise_library_error( lambda: cmd_alert.add_recipient( self.mock_env, "alert", "value1", {}, {}, recipient_id="alert-recipient" ), ( Severities.ERROR, report_codes.ID_ALREADY_EXISTS, {"id": "alert-recipient"} ) )
def test_value_not_defined(self): self.config.remove("runner.cib.load") self.env_assist.assert_raise_library_error( lambda: cmd_alert.add_recipient( self.env_assist.get_env(), "unknown", "", {}, {} ), [ ( Severities.ERROR, report_codes.REQUIRED_OPTION_IS_MISSING, {"option_names": ["value"]} ) ], )
def test_recipient_already_exists(self): self.env_assist.assert_raise_library_error( lambda: cmd_alert.add_recipient( self.env_assist.get_env(), "alert", "value1", {}, {}, recipient_id="alert-recipient", ), [( Severities.ERROR, report_codes.ID_ALREADY_EXISTS, { "id": "alert-recipient" }, )], )
def test_value_not_defined(self): assert_raise_library_error( lambda: cmd_alert.add_recipient(self.mock_env, "unknown", "", {}, { }), (Severities.ERROR, report_codes.REQUIRED_OPTION_IS_MISSING, { "option_name": "value" }))