Example #1
0
 def test_hook_failure(self):
     """Test hook failure."""
     hooks = [
         Hook({
             "path": "tests.cfngin.hooks.test_utils.fail_hook",
             "required": True
         })
     ]
     with self.assertRaises(SystemExit):
         handle_hooks("fail", hooks, self.provider, self.context)
     hooks = [{
         "path": "tests.cfngin.hooks.test_utils.exception_hook",
         "required": True
     }]
     with self.assertRaises(Exception):
         handle_hooks("fail", hooks, self.provider, self.context)
     hooks = [
         Hook({
             "path": "tests.cfngin.hooks.test_utils.exception_hook",
             "required": False
         })
     ]
     # Should pass
     handle_hooks("ignore_exception", hooks, self.provider, self.context)
Example #2
0
 def test_default_required_hook(self):
     """Test default required hook."""
     hooks = [Hook({"path": "runway.cfngin.hooks.blah"})]
     with self.assertRaises(AttributeError):
         handle_hooks("missing", hooks, self.provider, self.context)
Example #3
0
 def test_missing_non_required_hook_method(self):
     """Test missing non required hook method."""
     hooks = [Hook({"path": "runway.cfngin.hooks.blah", "required": False})]
     handle_hooks("missing", hooks, self.provider, self.context)
     self.assertTrue(HOOK_QUEUE.empty())
Example #4
0
 def test_missing_required_hook_method(self):
     """Test missing required hook method."""
     hooks = [{"path": "runway.cfngin.hooks.blah", "required": True}]
     with self.assertRaises(AttributeError):
         handle_hooks("missing", hooks, self.provider, self.context)
Example #5
0
 def test_missing_required_hook(self):
     """Test missing required hook."""
     hooks = [Hook({"path": "not.a.real.path", "required": True})]
     with self.assertRaises(ImportError):
         handle_hooks("missing", hooks, self.provider, self.context)
Example #6
0
 def test_empty_hook_stage(self):
     """Test empty hook stage."""
     hooks = []
     handle_hooks("fake", hooks, self.provider, self.context)
     self.assertTrue(HOOK_QUEUE.empty())