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
def test_process_process_later(self): trigger = DummyTriggerFactory(process_after=timezone.now() + timedelta(minutes=1)) with raises(ProcessLaterError): trigger.process()
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
def test_process(self, mock_logger): trigger = DummyTriggerFactory() trigger.process() mock_logger.assert_called_with(trigger, trigger._process({}))
def test_process_locked(self, mock_logger): trigger = DummyTriggerFactory() with NonBlockingLock.objects.acquire_lock(trigger): trigger.process() assert not mock_logger.called
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
def test_process_process_later(self): trigger = DummyTriggerFactory(process_after=timezone.now() + timedelta(minutes=1)) with raises(ProcessLaterError): trigger.process()
def test_process(self, mock_logger): trigger = DummyTriggerFactory() trigger.process() mock_logger.assert_called_with(trigger, trigger._process({}))