def testCronTabParser(self): """Ensure we can extract jobs from a crontab file.""" parser = cron_file_parser.CronTabParser() results = [] path = os.path.join(self.base_path, "parser_test", "crontab") plist_file = open(path, "rb") pathspec = rdf_paths.PathSpec.OS(path=path) results.extend(list(parser.ParseFile(None, pathspec, plist_file))) self.assertLen(results, 1) for result in results: self.assertEqual(result.jobs[0].minute, "1") self.assertEqual(result.jobs[0].hour, "2") self.assertEqual(result.jobs[0].dayofmonth, "3") self.assertEqual(result.jobs[0].month, "4") self.assertEqual(result.jobs[0].dayofweek, "5") self.assertEqual(result.jobs[0].command, "/usr/bin/echo \"test\"")
def testCronTabParser(self): """Ensure we can extract jobs from a crontab file.""" parser = cron_file_parser.CronTabParser() results = [] path = os.path.join(self.base_path, "parser_test", "crontab") plist_file = open(path, "rb") stat = rdf_client_fs.StatEntry(pathspec=rdf_paths.PathSpec( path=path, pathtype=rdf_paths.PathSpec.PathType.OS), st_mode=16877) results.extend(list(parser.Parse(stat, plist_file, None))) self.assertLen(results, 1) for result in results: self.assertEqual(result.jobs[0].minute, "1") self.assertEqual(result.jobs[0].hour, "2") self.assertEqual(result.jobs[0].dayofmonth, "3") self.assertEqual(result.jobs[0].month, "4") self.assertEqual(result.jobs[0].dayofweek, "5") self.assertEqual(result.jobs[0].command, "/usr/bin/echo \"test\"")