Ejemplo n.º 1
0
 def test_disable_job(self):
     '''
     Test if it disable a job in the minion's schedule.
     '''
     with patch.dict(schedule.__opts__, {'schedule': {}}):
         self.assertDictEqual(schedule.disable_job('job1'), {
             'comment': 'Job job1 does not exist.',
             'result': False
         })
Ejemplo n.º 2
0
 def test_disable_job(self):
     '''
     Test if it disable a job in the minion's schedule.
     '''
     with patch.dict(schedule.__opts__, {'schedule': {}, 'sock_dir': self.sock_dir}):
         mock = MagicMock(return_value=True)
         with patch.dict(schedule.__salt__, {'event.fire': mock}):
             _ret_value = {'complete': True, 'schedule': {}}
             with patch.object(SaltEvent, 'get_event', return_value=_ret_value):
                 self.assertDictEqual(schedule.disable_job('job1'),
                                      {'comment': 'Job job1 does not exist.',
                                       'result': False})
Ejemplo n.º 3
0
 def test_disable_job(self):
     '''
     Test if it disable a job in the minion's schedule.
     '''
     with patch.dict(schedule.__opts__, {'schedule': {}, 'sock_dir': SOCK_DIR}):
         mock = MagicMock(return_value=True)
         with patch.dict(schedule.__salt__, {'event.fire': mock}):
             _ret_value = {'complete': True, 'schedule': {}}
             with patch.object(SaltEvent, 'get_event', return_value=_ret_value):
                 self.assertDictEqual(schedule.disable_job('job1'),
                                      {'comment': 'Job job1 does not exist.',
                                       'result': False})
Ejemplo n.º 4
0
 def test_disable_job(self):
     """
     Test if it disable a job in the minion's schedule.
     """
     with patch.dict(schedule.__opts__, {"schedule": {}, "sock_dir": self.sock_dir}):
         mock = MagicMock(return_value=True)
         with patch.dict(schedule.__salt__, {"event.fire": mock}):
             _ret_value = {"complete": True, "schedule": {}}
             with patch.object(SaltEvent, "get_event", return_value=_ret_value):
                 self.assertDictEqual(
                     schedule.disable_job("job1"),
                     {"comment": "Job job1 does not exist.", "result": False},
                 )
Ejemplo n.º 5
0
    def test_run_job(self):
        """
        Test if it run a scheduled job on the minion immediately.
        '''
        with patch.dict(schedule.__opts__, {'schedule': {}, 'sock_dir': self.sock_dir}):
            mock = MagicMock(return_value=True)
            with patch.dict(schedule.__salt__, {"event.fire": mock}):
                _ret_value = {"complete": True, "schedule": {"job1": JOB1}}
                with patch.object(SaltEvent, "get_event", return_value=_ret_value):
                    self.assertDictEqual(
                        schedule.run_job("job1"),
                        {"comment": "Scheduling Job job1 on minion.", "result": True},
                    )

    # 'enable_job' function tests: 1

    @skipIf(True, "SLOWTEST skip")
    def test_enable_job(self):
        """
        Test if it enable a job in the minion's schedule.
        '''
        with patch.dict(schedule.__opts__, {'schedule': {}, 'sock_dir': self.sock_dir}):
            mock = MagicMock(return_value=True)
            with patch.dict(schedule.__salt__, {"event.fire": mock}):
                _ret_value = {"complete": True, "schedule": {}}
                with patch.object(SaltEvent, "get_event", return_value=_ret_value):
                    self.assertDictEqual(
                        schedule.enable_job("job1"),
                        {"comment": "Job job1 does not exist.", "result": False},
                    )

    # 'disable_job' function tests: 1

    @skipIf(True, "SLOWTEST skip")
    def test_disable_job(self):
        """
        Test if it disable a job in the minion's schedule.
        '''
        with patch.dict(schedule.__opts__, {'schedule': {}, 'sock_dir': self.sock_dir}):
            mock = MagicMock(return_value=True)
            with patch.dict(schedule.__salt__, {"event.fire": mock}):
                _ret_value = {"complete": True, "schedule": {}}
                with patch.object(SaltEvent, "get_event", return_value=_ret_value):
                    self.assertDictEqual(
                        schedule.disable_job("job1"),
                        {"comment": "Job job1 does not exist.", "result": False},
                    )