def test_hook_failure(self) -> None: """Test hook failure.""" hooks = [ CfnginHookDefinitionModel( **{ "path": "tests.unit.cfngin.hooks.test_utils.fail_hook", "required": True, }) ] with self.assertRaises(SystemExit): handle_hooks("fail", hooks, self.provider, self.context) hooks = [ CfnginHookDefinitionModel.parse_obj({ "path": "tests.unit.cfngin.hooks.test_utils.exception_hook", "required": True, }) ] with self.assertRaises(Exception): handle_hooks("fail", hooks, self.provider, self.context) hooks = [ CfnginHookDefinitionModel( **{ "path": "tests.unit.cfngin.hooks.test_utils.exception_hook", "required": False, }) ] # Should pass handle_hooks("ignore_exception", hooks, self.provider, self.context)
def test_missing_required_hook_method(self) -> None: """Test missing required hook method.""" with self.assertRaises(AttributeError): hooks = [ CfnginHookDefinitionModel.parse_obj({ "path": "runway.cfngin.hooks.blah", "required": True }) ] handle_hooks("missing", hooks, self.provider, self.context)