コード例 #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
コード例 #2
0
 def test_process_process_later(self):
     trigger = DummyTriggerFactory(process_after=timezone.now() + timedelta(minutes=1))
     with raises(ProcessLaterError):
         trigger.process()
コード例 #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
コード例 #4
0
    def test_process(self, mock_logger):
        trigger = DummyTriggerFactory()
        trigger.process()

        mock_logger.assert_called_with(trigger, trigger._process({}))
コード例 #5
0
    def test_process_locked(self, mock_logger):
        trigger = DummyTriggerFactory()
        with NonBlockingLock.objects.acquire_lock(trigger):
            trigger.process()

        assert not mock_logger.called
コード例 #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
コード例 #7
0
 def test_process_process_later(self):
     trigger = DummyTriggerFactory(process_after=timezone.now() + timedelta(minutes=1))
     with raises(ProcessLaterError):
         trigger.process()
コード例 #8
0
    def test_process(self, mock_logger):
        trigger = DummyTriggerFactory()
        trigger.process()

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