Skip to content

Commit

Permalink
adds new test
Browse files Browse the repository at this point in the history
  • Loading branch information
saxix committed Jan 2, 2014
1 parent e0acbeb commit ba541d5
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/test_triggerversionfield.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from django.core import signals
from django.db import connections
from django.db import connections, IntegrityError
import mock
import pytest
from concurrency.exceptions import RecordModifiedError
from concurrency.utils import refetch
Expand Down Expand Up @@ -80,3 +81,15 @@ def test_trigger():

with pytest.raises(RecordModifiedError):
instance.save()


@pytest.mark.django_db
def test_trigger_do_not_increase_version_if_error():
instance = TriggerConcurrentModel()
assert instance.pk is None
assert instance.version == 0
with mock.patch('tests.models.TriggerConcurrentModel.save', side_effect=IntegrityError):
with pytest.raises(IntegrityError):
instance.save()

assert instance.version == 0

0 comments on commit ba541d5

Please sign in to comment.