def test_raises_on_invalid_name(self, ResourceAgent, error_to_report_item): name = "ocf:heartbeat:Something:else" report = "INVALID_RESOURCE_AGENT_NAME" e = lib_ra.InvalidResourceAgentName(name, "invalid agent name") ResourceAgent.side_effect = e error_to_report_item.return_value = report with self.assertRaises(LibraryError) as context_manager: self.run(name) self.assertEqual(report, context_manager.exception.args[0]) ResourceAgent.assert_called_once_with(self.runner, name) error_to_report_item.assert_called_once_with(e)
def __init__(self, runner, name): if name == invalid_agent_name: raise lib_ra.InvalidResourceAgentName(name) self.name = name