Exemplo n.º 1
0
 def test_ok(self):
     reports = [
         PlaybookChecker(path, self.check_config).info
         for path in Path(tests._folder).glob('**/syntax/playbooks/ok*.yml')
     ]
     #         pprint(reports)
     self.check_ok_reports(reports)
Exemplo n.º 2
0
 def test_warning(self):
     reports = [
         PlaybookChecker(path, self.check_config).info for path in Path(
             tests._folder).glob('**/doc/playbooks/warning*.yml')
     ]
     self.check_warning_reports(reports)
     self.assertEqual(reports[0]['warnings'][0]['msg'], 'Doc missing')
Exemplo n.º 3
0
 def test_warning(self):
     reports = [
         PlaybookChecker(path, self.check_config).info for path in Path(
             tests._folder).glob('**/permissions/playbooks/warning*.yml')
     ]
     pprint(reports)
     self.check_warning_reports(reports)
     msg = reports[0]['warnings'][0]['msg']
     self.assertEqual(msg, '0o644 instead 0o664')
Exemplo n.º 4
0
 def test_warning(self):
     reports = [
         PlaybookChecker(path, self.check_config).info for path in Path(
             tests._folder).glob('**/syntax/playbooks/warning*.yml')
     ]
     self.check_warning_reports(reports)
     #         pprint(reports)
     msg = reports[0]['warnings'][0]['msg']
     expected_warning_pattern = ' [WARNING]: (Could not match supplied host pattern|provided hosts list is empty).*'
     expected_warning_pattern = r' \[WARNING\]: (Could not match supplied host pattern|provided hosts list is empty).*.*'
     self.assertIsNotNone(re.match(expected_warning_pattern, msg))
Exemplo n.º 5
0
 def test_env(self):
     check_config = copy.deepcopy(self.check_config)
     check_config["syntax"] = {
         "env": {
             "ANSIBLE_FORCE_COLOR": "true",
         }
     }
     reports = [
         PlaybookChecker(path, check_config).info for path in Path(
             tests._folder).glob('**/syntax/playbooks/warning*.yml')
     ]
     msg = reports[0]['warnings'][0]['msg']
     self.assertTrue(msg.startswith('\x1b[1;35m [WARNING]'))
Exemplo n.º 6
0
 def test_error(self):
     reports = [
         PlaybookChecker(path, self.check_config).info for path in sorted(
             Path(tests._folder).glob('**/syntax/playbooks/error*.yml'))
     ]
     self.check_error_reports(reports)
     #         pprint(reports)
     msg = reports[0]['errors'][0]['msg']
     self.assertTrue(
         msg.startswith("ERROR! The field 'hosts' has an invalid value"))
     msg = reports[1]['errors'][0]['msg']
     self.assertTrue(msg.startswith('while parsing a block collection'))
     msg = reports[2]['errors'][0]['msg']
     self.assertTrue(
         msg.startswith(
             'ERROR! no action detected in task. This often indicates'))
Exemplo n.º 7
0
 def test_error(self):
     reports = [
         PlaybookChecker(path, self.check_config).info
         for path in Path(tests._folder).glob('**/doc/playbooks/error*.yml')
     ]
     self.check_error_reports(reports)
Exemplo n.º 8
0
 def _test_all(self):
     reports = [
         PlaybookChecker(path, self.check_config).info for path in Path(
             tests._folder).glob('**/permissions/playbooks/*.yml')
     ]
     self._debug(reports)