def test_read_from_file(self): my_cron = CronTab() my_cron.read('/tmp/output.tab') cron = my_cron.find_comment('echo') for result in cron: print result.last_run self.assertEqual(result.command, "echo `date`") self.assertTrue(cron)
def test_change_enable_cron_to_disable(self): my_cron = CronTab() my_cron.read('/tmp/output.tab') crons = my_cron.find_comment('ls') for cron in crons: if cron.is_enabled(): cron.enable(False) my_cron.write('/tmp/output.tab') test_cron = CronTab() test_cron.read('/tmp/output.tab') crons = test_cron.find_comment('ls') for cron in crons: self.assertFalse(cron.is_enabled())