本文整理汇总了Python中salt.utils.schedule.Schedule.delete_job方法的典型用法代码示例。如果您正苦于以下问题:Python Schedule.delete_job方法的具体用法?Python Schedule.delete_job怎么用?Python Schedule.delete_job使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类salt.utils.schedule.Schedule
的用法示例。
在下文中一共展示了Schedule.delete_job方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ScheduleTestCase
# 需要导入模块: from salt.utils.schedule import Schedule [as 别名]
# 或者: from salt.utils.schedule.Schedule import delete_job [as 别名]
class ScheduleTestCase(TestCase):
'''
Unit tests for salt.utils.schedule module
'''
def setUp(self):
with patch('salt.utils.schedule.clean_proc_dir', MagicMock(return_value=None)):
self.schedule = Schedule({}, {}, returners={})
# delete_job tests
def test_delete_job_exists(self):
'''
Tests ensuring the job exists and deleting it
'''
self.schedule.opts = {'schedule': {'foo': 'bar'}, 'pillar': '',
'sock_dir': SOCK_DIR}
self.schedule.delete_job('foo')
self.assertNotIn('foo', self.schedule.opts)
def test_delete_job_in_pillar(self):
'''
Tests deleting job in pillar
'''
self.schedule.opts = {'pillar': {'schedule': {'foo': 'bar'}}, 'schedule': '',
'sock_dir': SOCK_DIR}
self.schedule.delete_job('foo')
self.assertNotIn('foo', self.schedule.opts)
def test_delete_job_intervals(self):
'''
Tests removing job from intervals
'''
self.schedule.opts = {'pillar': '', 'schedule': '',
'sock_dir': SOCK_DIR}
self.schedule.intervals = {'foo': 'bar'}
self.schedule.delete_job('foo')
self.assertNotIn('foo', self.schedule.intervals)
# add_job tests
def test_add_job_data_not_dict(self):
'''
Tests if data is a dictionary
'''
data = 'foo'
self.assertRaises(ValueError, Schedule.add_job, self.schedule, data)
def test_add_job_multiple_jobs(self):
'''
Tests if more than one job is scheduled at a time
'''
data = {'key1': 'value1', 'key2': 'value2'}
self.assertRaises(ValueError, Schedule.add_job, self.schedule, data)
def test_add_job(self):
'''
Tests adding a job to the schedule
'''
data = {'foo': {'bar': 'baz'}}
ret = {'schedule': {'foo': {'bar': 'baz', 'enabled': True},
'hello': {'world': 'peace', 'enabled': True}}}
self.schedule.opts = {'schedule': {'hello': {'world': 'peace', 'enabled': True}},
'sock_dir': SOCK_DIR}
Schedule.add_job(self.schedule, data)
del self.schedule.opts['sock_dir']
self.assertEqual(self.schedule.opts, ret)
# enable_job tests
def test_enable_job(self):
'''
Tests enabling a job
'''
self.schedule.opts = {'schedule': {'name': {'enabled': 'foo'}},
'sock_dir': SOCK_DIR}
Schedule.enable_job(self.schedule, 'name')
del self.schedule.opts['sock_dir']
self.assertTrue(self.schedule.opts['schedule']['name']['enabled'])
def test_enable_job_pillar(self):
'''
Tests enabling a job in pillar
'''
self.schedule.opts = {'pillar': {'schedule': {'name': {'enabled': 'foo'}}},
'sock_dir': SOCK_DIR}
Schedule.enable_job(self.schedule, 'name', persist=False, where='pillar')
del self.schedule.opts['sock_dir']
self.assertTrue(self.schedule.opts['pillar']['schedule']['name']['enabled'])
# disable_job tests
def test_disable_job(self):
'''
Tests disabling a job
'''
self.schedule.opts = {'schedule': {'name': {'enabled': 'foo'}},
'sock_dir': SOCK_DIR}
Schedule.disable_job(self.schedule, 'name')
del self.schedule.opts['sock_dir']
#.........这里部分代码省略.........