def test_name_only(self): xml = ''' <action name="required" /> ''' self.assertEqual( lib_ra._get_action(etree.XML(xml)), {"name": "required"} )
def test_name_and_params(self): xml = ''' <action name="required" param="value" another_param="same_value" /> ''' self.assertEqual( lib_ra._get_action(etree.XML(xml)), { "name": "required", "another_param": "same_value", "param": "value" } )
def test_root_is_not_resource_agent(self): xml = """ <agent> <actions> <action name="on" automatic="0"/> <action name="off" /> </actions> </agent> """ self.assertRaises( lib_ra.InvalidMetadataFormat, lambda: lib_ra._get_action(etree.XML(xml)) )
def test_action_without_name(self): xml = """ <resource-agent> <actions> <action name="on" automatic="0"/> <action /> <action name="reboot" /> <action name="status" /> </actions> </resource-agent> """ self.assertRaises( lib_ra.InvalidMetadataFormat, lambda: lib_ra._get_action(etree.XML(xml)) )
def test_not_action_element(self): xml = '<actions param="value" another_param="same_value" />' self.assertRaises( lib_ra.InvalidMetadataFormat, lambda: lib_ra._get_action(etree.XML(xml)) )
def test_empty(self): xml = '<action />' self.assertRaises( lib_ra.InvalidMetadataFormat, lambda: lib_ra._get_action(etree.XML(xml)) )