示例#1
0
 def test_valid_hook(self):
     hooks = [{'path': 'stacker.tests.test_util.mock_hook',
               'required': True}]
     handle_hooks('missing', hooks, 'us-east-1', 'stage', {}, {})
     good = hook_queue.get_nowait()
     self.assertEqual(good[0], 'us-east-1')
     with self.assertRaises(Queue.Empty):
         hook_queue.get_nowait()
示例#2
0
文件: test_util.py 项目: 40a/stacker
 def test_valid_hook(self):
     hooks = [{"path": "stacker.tests.test_util.mock_hook",
               "required": True}]
     handle_hooks("missing", hooks, "us-east-1", self.context)
     good = hook_queue.get_nowait()
     self.assertEqual(good[0], "us-east-1")
     with self.assertRaises(Queue.Empty):
         hook_queue.get_nowait()
示例#3
0
 def test_context_provided_to_hook(self):
     hooks = [
         Hook({
             "path": "stacker.tests.test_util.context_hook",
             "required": True
         })
     ]
     handle_hooks("missing", hooks, "us-east-1", self.context)
示例#4
0
 def test_valid_hook(self):
     hooks = [{"path": "stacker.tests.test_util.mock_hook",
               "required": True}]
     handle_hooks("missing", hooks, self.provider, self.context)
     good = hook_queue.get_nowait()
     self.assertEqual(good["provider"].region, "us-east-1")
     with self.assertRaises(Queue.Empty):
         hook_queue.get_nowait()
示例#5
0
 def test_valid_enabled_hook(self):
     hooks = [
         Hook({"path": "stacker.tests.test_util.mock_hook",
               "required": True, "enabled": True})]
     handle_hooks("missing", hooks, self.provider, self.context)
     good = hook_queue.get_nowait()
     self.assertEqual(good["provider"].region, "us-east-1")
     with self.assertRaises(queue.Empty):
         hook_queue.get_nowait()
示例#6
0
 def test_valid_enabled_false_hook(self):
     hooks = [
         Hook({
             "path": "stacker.tests.test_util.mock_hook",
             "required": True,
             "enabled": False
         })
     ]
     handle_hooks("missing", hooks, self.provider, self.context)
     self.assertTrue(hook_queue.empty())
示例#7
0
    def test_return_data_hook_duplicate_key(self):
        hooks = [{
            "path": "stacker.tests.test_util.result_hook",
            "data_key": "my_hook_results"
        }, {
            "path": "stacker.tests.test_util.result_hook",
            "data_key": "my_hook_results"
        }]

        with self.assertRaises(KeyError):
            handle_hooks("result", hooks, "us-east-1", self.context)
示例#8
0
    def test_return_data_hook_duplicate_key(self):
        hooks = [
            Hook({
                "path": "stacker.tests.test_util.result_hook",
                "data_key": "my_hook_results"
            }),
            Hook({
                "path": "stacker.tests.test_util.result_hook",
                "data_key": "my_hook_results"
            })
        ]

        with self.assertRaises(KeyError):
            handle_hooks("result", hooks, "us-east-1", self.context)
示例#9
0
    def test_return_data_hook(self):
        hooks = [
            Hook({
                "path": "stacker.tests.test_util.result_hook",
                "data_key": "my_hook_results"
            }),
            # Shouldn't return data
            Hook({"path": "stacker.tests.test_util.context_hook"})
        ]
        handle_hooks("result", hooks, "us-east-1", self.context)

        self.assertEqual(self.context.hook_data["my_hook_results"]["foo"],
                         "bar")
        # Verify only the first hook resulted in stored data
        self.assertEqual(self.context.hook_data.keys(), ["my_hook_results"])
示例#10
0
 def test_hook_with_sys_path(self):
     config = Config({
         "namespace": "test",
         "sys_path": "stacker/tests",
         "pre_build": [
             {
                 "data_key": "myHook",
                 "path": "fixtures.mock_hooks.mock_hook",
                 "required": True,
                 "args": {
                     "value": "mockResult"}}]})
     load(config)
     context = Context(config=config)
     stage = "pre_build"
     handle_hooks(stage, context.config[stage], "mock-region-1", context)
     self.assertEqual("mockResult", context.hook_data["myHook"]["result"])
示例#11
0
 def test_hook_with_sys_path(self):
     config = Config({
         "namespace": "test",
         "sys_path": "stacker/tests",
         "pre_build": [
             {
                 "data_key": "myHook",
                 "path": "fixtures.mock_hooks.mock_hook",
                 "required": True,
                 "args": {
                     "value": "mockResult"}}]})
     load(config)
     context = Context(config=config)
     stage = "pre_build"
     handle_hooks(stage, context.config[stage], "mock-region-1", context)
     self.assertEqual("mockResult", context.hook_data["myHook"]["result"])
示例#12
0
    def test_return_data_hook(self):
        hooks = [
            Hook({
                "path": "stacker.tests.test_util.result_hook",
                "data_key": "my_hook_results"
            }),
            # Shouldn't return data
            Hook({
                "path": "stacker.tests.test_util.context_hook"
            })
        ]
        handle_hooks("result", hooks, "us-east-1", self.context)

        self.assertEqual(
            self.context.hook_data["my_hook_results"]["foo"],
            "bar"
        )
        # Verify only the first hook resulted in stored data
        self.assertEqual(
            list(self.context.hook_data.keys()), ["my_hook_results"]
        )
示例#13
0
 def test_hook_failure(self):
     hooks = [{'path': 'stacker.tests.test_util.fail_hook',
               'required': True}]
     with self.assertRaises(SystemExit):
         handle_hooks('fail', hooks, 'us-east-1', 'stage', {}, {})
     hooks = [{'path': 'stacker.tests.test_util.exception_hook',
               'required': True}]
     with self.assertRaises(Exception):
         handle_hooks('fail', hooks, 'us-east-1', 'stage', {}, {})
     hooks = [{'path': 'stacker.tests.test_util.exception_hook',
               'required': False}]
     # Should pass
     handle_hooks('ignore_exception', hooks, 'us-east-1', 'stage', {}, {})
示例#14
0
 def test_hook_failure(self):
     hooks = [{"path": "stacker.tests.test_util.fail_hook",
               "required": True}]
     with self.assertRaises(SystemExit):
         handle_hooks("fail", hooks, self.provider, self.context)
     hooks = [{"path": "stacker.tests.test_util.exception_hook",
               "required": True}]
     with self.assertRaises(Exception):
         handle_hooks("fail", hooks, self.provider, self.context)
     hooks = [{"path": "stacker.tests.test_util.exception_hook",
               "required": False}]
     # Should pass
     handle_hooks("ignore_exception", hooks, self.provider, self.context)
示例#15
0
文件: test_util.py 项目: 40a/stacker
 def test_hook_failure(self):
     hooks = [{"path": "stacker.tests.test_util.fail_hook",
               "required": True}]
     with self.assertRaises(SystemExit):
         handle_hooks("fail", hooks, "us-east-1", self.context)
     hooks = [{"path": "stacker.tests.test_util.exception_hook",
               "required": True}]
     with self.assertRaises(Exception):
         handle_hooks("fail", hooks, "us-east-1", self.context)
     hooks = [{"path": "stacker.tests.test_util.exception_hook",
               "required": False}]
     # Should pass
     handle_hooks("ignore_exception", hooks, "us-east-1", self.context)
示例#16
0
文件: test_util.py 项目: 40a/stacker
 def test_default_required_hook(self):
     hooks = [{"path": "stacker.hooks.blah"}]
     with self.assertRaises(AttributeError):
         handle_hooks("missing", hooks, "us-east-1", self.context)
示例#17
0
文件: test_util.py 项目: 40a/stacker
 def test_missing_non_required_hook_method(self):
     hooks = [{"path": "stacker.hooks.blah", "required": False}]
     handle_hooks("missing", hooks, "us-east-1", self.context)
     self.assertTrue(hook_queue.empty())
示例#18
0
文件: test_util.py 项目: 40a/stacker
 def test_missing_required_hook_method(self):
     hooks = [{"path": "stacker.hooks.blah", "required": True}]
     with self.assertRaises(AttributeError):
         handle_hooks("missing", hooks, "us-east-1", self.context)
示例#19
0
 def test_missing_non_required_hook_method(self):
     hooks = [Hook({"path": "stacker.hooks.blah", "required": False})]
     handle_hooks("missing", hooks, self.provider, self.context)
     self.assertTrue(hook_queue.empty())
示例#20
0
 def test_empty_hook_stage(self):
     hooks = []
     handle_hooks('fake', hooks, 'us-east-1', 'stage', {}, {})
     self.assertTrue(hook_queue.empty())
示例#21
0
 def test_missing_non_required_hook_method(self):
     hooks = [{"path": "stacker.hooks.blah", "required": False}]
     handle_hooks("missing", hooks, self.provider, self.context)
     self.assertTrue(hook_queue.empty())
示例#22
0
 def test_missing_required_hook(self):
     hooks = [{"path": "not.a.real.path", "required": True}]
     with self.assertRaises(ImportError):
         handle_hooks("missing", hooks, self.provider, self.context)
示例#23
0
 def test_missing_required_hook_method(self):
     hooks = [{'path': 'stacker.hooks.blah', 'required': True}]
     with self.assertRaises(AttributeError):
         handle_hooks('missing', hooks, 'us-east-1', 'stage', {}, {})
示例#24
0
 def test_missing_non_required_hook_method(self):
     hooks = [{'path': 'stacker.hooks.blah', 'required': False}]
     handle_hooks('missing', hooks, 'us-east-1', 'stage', {}, {})
     self.assertTrue(hook_queue.empty())
示例#25
0
 def test_context_provided_to_hook(self):
     hooks = [
         Hook({"path": "stacker.tests.test_util.context_hook",
               "required": True})]
     handle_hooks("missing", hooks, "us-east-1", self.context)
示例#26
0
 def test_default_required_hook(self):
     hooks = [{'path': 'stacker.hooks.blah'}]
     with self.assertRaises(AttributeError):
         handle_hooks('missing', hooks, 'us-east-1', 'stage', {}, {})
示例#27
0
 def test_empty_hook_stage(self):
     hooks = []
     handle_hooks("fake", hooks, self.provider, self.context)
     self.assertTrue(hook_queue.empty())
示例#28
0
 def test_default_required_hook(self):
     hooks = [Hook({"path": "stacker.hooks.blah"})]
     with self.assertRaises(AttributeError):
         handle_hooks("missing", hooks, self.provider, self.context)
示例#29
0
 def test_missing_required_hook(self):
     hooks = [{'path': 'not.a.real.path', 'required': True}]
     with self.assertRaises(ImportError):
         handle_hooks('missing', hooks, 'us-east-1', 'stage', {}, {})
示例#30
0
 def test_empty_hook_stage(self):
     hooks = []
     handle_hooks("fake", hooks, self.provider, self.context)
     self.assertTrue(hook_queue.empty())
示例#31
0
 def test_empty_hook_stage(self):
     hooks = []
     handle_hooks("fake", hooks, "us-east-1", self.context)
     self.assertTrue(hook_queue.empty())
示例#32
0
 def test_missing_required_hook_method(self):
     hooks = [{"path": "stacker.hooks.blah", "required": True}]
     with self.assertRaises(AttributeError):
         handle_hooks("missing", hooks, self.provider, self.context)
示例#33
0
文件: test_util.py 项目: 40a/stacker
 def test_empty_hook_stage(self):
     hooks = []
     handle_hooks("fake", hooks, "us-east-1", self.context)
     self.assertTrue(hook_queue.empty())
示例#34
0
 def test_default_required_hook(self):
     hooks = [{"path": "stacker.hooks.blah"}]
     with self.assertRaises(AttributeError):
         handle_hooks("missing", hooks, self.provider, self.context)
示例#35
0
文件: test_util.py 项目: 40a/stacker
 def test_missing_required_hook(self):
     hooks = [{"path": "not.a.real.path", "required": True}]
     with self.assertRaises(ImportError):
         handle_hooks("missing", hooks, "us-east-1", self.context)
示例#36
0
 def test_valid_enabled_false_hook(self):
     hooks = [
         Hook({"path": "stacker.tests.test_util.mock_hook",
               "required": True, "enabled": False})]
     handle_hooks("missing", hooks, self.provider, self.context)
     self.assertTrue(hook_queue.empty())
示例#37
0
 def test_missing_required_hook(self):
     hooks = [Hook({"path": "not.a.real.path", "required": True})]
     with self.assertRaises(ImportError):
         handle_hooks("missing", hooks, self.provider, self.context)