def test_job(self): job = Job('job', every='1.day', path='/tmp', environment={'key': 'value'}, output='null') self.assert_equal( job.cron, '0 0 * * * cd /tmp && key=value job ' '> /dev/null 2>&1')
def test_preprocess_at(self): job = Job('job', every='1.hour') at = job.preprocess_at('0:0') self.assert_equal(at, 'hour.0 minute.0') at = job.preprocess_at('1:00') self.assert_equal(at, 'hour.1 minute.0') at = job.preprocess_at('23:01') self.assert_equal(at, 'hour.23 minute.1') at = job.preprocess_at('23:10') self.assert_equal(at, 'hour.23 minute.10') at = job.preprocess_at('12:59') self.assert_equal(at, 'hour.12 minute.59') at = job.preprocess_at('14:09:0') self.assert_equal(at, 'hour.14 minute.9')
def test_predefined_every(self): job = Job('task', every='yearly', at='minute.2', path='/path') self.assert_equal(job.cron, '@yearly cd /path && task') job = Job('task', every='monthly', at='minute.2', path='/path') self.assert_equal(job.cron, '@monthly cd /path && task') job = Job('task', every='weekly', at='minute.2', path='/path') self.assert_equal(job.cron, '@weekly cd /path && task') job = Job('task', every='daily', at='minute.2', path='/path') self.assert_equal(job.cron, '@daily cd /path && task') job = Job('task', every='hourly', at='minute.2', path='/path') self.assert_equal(job.cron, '@hourly cd /path && task') job = Job('task', every='reboot', at='minute.2', path='/path') self.assert_equal(job.cron, '@reboot cd /path && task')
def test_raw_every(self): job = Job('task', every='0 1 2 3 *', at='minute.2', path='/path') self.assert_equal(job.cron, '0 1 2 3 * cd /path && task')