Ejemplo n.º 1
0
    def test_process_locked(self, mock_logger):
        trigger = DummyTriggerFactory()
        with patch('djtriggers.models.redis_lock', side_effect=LockError):
            trigger.process()

        assert not mock_logger.called
Ejemplo n.º 2
0
 def test_process_process_later(self):
     trigger = DummyTriggerFactory(process_after=timezone.now() + timedelta(minutes=1))
     with raises(ProcessLaterError):
         trigger.process()
Ejemplo n.º 3
0
 def test_process_exception_during_execution(self, mock_fail):
     trigger = DummyTriggerFactory()
     with patch.object(trigger, '_process', side_effect=Exception), raises(Exception):
         trigger.process()
     assert mock_fail.called
Ejemplo n.º 4
0
    def test_process(self, mock_logger):
        trigger = DummyTriggerFactory()
        trigger.process()

        mock_logger.assert_called_with(trigger, trigger._process({}))
Ejemplo n.º 5
0
    def test_process_locked(self, mock_logger):
        trigger = DummyTriggerFactory()
        with NonBlockingLock.objects.acquire_lock(trigger):
            trigger.process()

        assert not mock_logger.called
Ejemplo n.º 6
0
 def test_process_exception_during_execution(self, mock_fail):
     trigger = DummyTriggerFactory()
     with patch.object(trigger, '_process', side_effect=Exception), raises(Exception):
         trigger.process()
     assert mock_fail.called
Ejemplo n.º 7
0
 def test_process_process_later(self):
     trigger = DummyTriggerFactory(process_after=timezone.now() + timedelta(minutes=1))
     with raises(ProcessLaterError):
         trigger.process()
Ejemplo n.º 8
0
    def test_process(self, mock_logger):
        trigger = DummyTriggerFactory()
        trigger.process()

        mock_logger.assert_called_with(trigger, trigger._process({}))