Esempio n. 1
0
 def test_one_include(self):
     ds = [{'include': '/dev/null/includes/other_test_include.yml'}]
     res = helpers.load_list_of_tasks(
         ds,
         play=self.mock_play,
         variable_manager=self.mock_variable_manager,
         loader=self.fake_include_loader)
     self.assertEqual(len(res), 1)
     self._assert_is_task_list_or_blocks(res)
Esempio n. 2
0
 def test_one_bogus_include_static(self):
     ds = [{'include': 'somefile.yml', 'static': 'true'}]
     res = helpers.load_list_of_tasks(
         ds,
         play=self.mock_play,
         variable_manager=self.mock_variable_manager,
         loader=self.fake_loader)
     self.assertIsInstance(res, list)
     self.assertEqual(len(res), 0)
Esempio n. 3
0
 def test_one_bogus_include_role(self):
     ds = [{'include_role': {'name': 'bogus_role'}, 'collections': []}]
     res = helpers.load_list_of_tasks(
         ds,
         play=self.mock_play,
         block=self.mock_block,
         variable_manager=self.mock_variable_manager,
         loader=self.fake_role_loader)
     self.assertEqual(len(res), 1)
     self._assert_is_task_list_or_blocks(res)
Esempio n. 4
0
 def test_one_include_use_handlers(self):
     ds = [{'include': '/dev/null/includes/other_test_include.yml'}]
     res = helpers.load_list_of_tasks(
         ds,
         play=self.mock_play,
         use_handlers=True,
         variable_manager=self.mock_variable_manager,
         loader=self.fake_include_loader)
     self._assert_is_task_list_or_blocks(res)
     self.assertIsInstance(res[0], Handler)
Esempio n. 5
0
 def test_one_parent_include(self):
     ds = [{'include': '/dev/null/includes/test_include.yml'}]
     res = helpers.load_list_of_tasks(
         ds,
         play=self.mock_play,
         variable_manager=self.mock_variable_manager,
         loader=self.fake_include_loader)
     self._assert_is_task_list_or_blocks(res)
     self.assertIsInstance(res[0], Block)
     self.assertIsInstance(res[0]._parent, TaskInclude)
Esempio n. 6
0
 def test_unknown_action(self):
     action_name = 'foo_test_unknown_action'
     ds = [{'action': action_name}]
     res = helpers.load_list_of_tasks(
         ds,
         play=self.mock_play,
         variable_manager=self.mock_variable_manager,
         loader=self.fake_loader)
     self._assert_is_task_list_or_blocks(res)
     self.assertEqual(res[0].action, action_name)
Esempio n. 7
0
 def test_block_unknown_action_use_handlers(self):
     ds = [{'block': [{'action': 'foo_test_block_unknown_action'}]}]
     res = helpers.load_list_of_tasks(
         ds,
         play=self.mock_play,
         use_handlers=True,
         variable_manager=self.mock_variable_manager,
         loader=self.fake_loader)
     self._assert_is_task_list_or_blocks(res)
     self.assertIsInstance(res[0], Block)
     self._assert_default_block(res[0])
Esempio n. 8
0
 def test_one_include_tags(self):
     ds = [{
         'include': '/dev/null/includes/other_test_include.yml',
         'tags': ['test_one_include_tags_tag1', 'and_another_tagB']
     }]
     res = helpers.load_list_of_tasks(
         ds,
         play=self.mock_play,
         variable_manager=self.mock_variable_manager,
         loader=self.fake_include_loader)
     self._assert_is_task_list_or_blocks(res)
     self.assertIsInstance(res[0], Block)
     self.assertIn('test_one_include_tags_tag1', res[0].tags)
     self.assertIn('and_another_tagB', res[0].tags)
Esempio n. 9
0
 def _load_always(self, attr, ds):
     try:
         return load_list_of_tasks(
             ds,
             play=self._play,
             block=self,
             role=self._role,
             task_include=None,
             variable_manager=self._variable_manager,
             loader=self._loader,
             use_handlers=self._use_handlers,
         )
     except AssertionError as e:
         raise AssibleParserError(
             "A malformed block was encountered while loading always",
             obj=self._ds,
             orig_exc=e)
Esempio n. 10
0
 def test_one_include_not_static(self):
     ds = [{
         'include': '/dev/null/includes/static_test_include.yml',
         'static': False
     }]
     # a_block = Block()
     ti_ds = {'include': '/dev/null/includes/ssdftatic_test_include.yml'}
     a_task_include = TaskInclude()
     ti = a_task_include.load(ti_ds)
     res = helpers.load_list_of_tasks(
         ds,
         play=self.mock_play,
         block=ti,
         variable_manager=self.mock_variable_manager,
         loader=self.fake_include_loader)
     self._assert_is_task_list_or_blocks(res)
     self.assertIsInstance(res[0], Task)
     self.assertEqual(res[0].args['_raw_params'],
                      '/dev/null/includes/static_test_include.yml')