# Path: nosedjangotests/polls/models.py
# class Choice(models.Model):
#     content_type = models.ForeignKey('contenttypes.ContentType')
#     object_id = models.PositiveIntegerField()
#     poll = GenericForeignKey('content_type', 'object_id')
# 
#     choice = models.CharField(max_length=200)
#     votes = models.IntegerField(default=0)
# 
#     @atomic
#     def reset(self):
#         self.votes = 0
#         self.save()


from importlib import import_module
from nose.plugins.skip import SkipTest
from django.test import TestCase
from nosedjangotests.polls.models import Choice
import django
    def test_context_manager_atomic(self):
        if django.VERSION < (1, 7):
            raise SkipTest('This test is only an issue in django 1.8+')

        choice = Choice.objects.get()
        choice.votes = 42
        tester = import_module("polls.helpers")
        choice_pk = tester.ctxt_man_reset_choice(choice=choice)
        self.assertEqual(choice_pk, choice.pk)
        choice = Choice.objects.get()
        self.assertEqual(choice.votes, 0)


class TransactionTestCase(TestCase):
    use_transaction_isolation = True

    fixtures = [
        'polls1.json',
        'choices.json',
    ]

    def test_decorator_atomic(self):
        if django.VERSION < (1, 7):
            raise SkipTest('This test is only an issue in django 1.8+')

        choice = Choice.objects.get()
        choice.votes = 42
        tester = import_module("polls.helpers")
        choice_pk = tester.transaction_decorator_reset_choice(choice=choice)
        self.assertEqual(choice_pk, choice.pk)

# Path: nosedjangotests/polls/models.py
# class Choice(models.Model):
#     content_type = models.ForeignKey('contenttypes.ContentType')
#     object_id = models.PositiveIntegerField()
#     poll = GenericForeignKey('content_type', 'object_id')
# 
#     choice = models.CharField(max_length=200)
#     votes = models.IntegerField(default=0)
# 
#     @atomic
#     def reset(self):
#         self.votes = 0
#         self.save()


# Path: nosedjangotests/polls/tests/test_dummy_decorator.py
from importlib import import_module
from nose.plugins.skip import SkipTest
from django.test import TestCase
from nosedjangotests.polls.models import Choice
import django

    def test_context_manager_atomic(self):
        if django.VERSION < (1, 7):
            raise SkipTest('This test is only an issue in django 1.8+')

        choice = Choice.objects.get()
        choice.votes = 42
        tester = import_module("polls.helpers")
        choice_pk = tester.ctxt_man_reset_choice(choice=choice)
        self.assertEqual(choice_pk, choice.pk)
        choice = Choice.objects.get()
        self.assertEqual(choice.votes, 0)


class TransactionTestCase(TestCase):
    use_transaction_isolation = True

    fixtures = [
        'polls1.json',
        'choices.json',
    ]

    def test_decorator_atomic(self):
        if django.VERSION < (1, 7):
            raise SkipTest('This test is only an issue in django 1.8+')

        choice = Choice.objects.get()
        choice.votes = 42
        tester = import_module("polls.helpers")
        choice_pk = tester.transaction_decorator_reset_choice(choice=choice)
        self.assertEqual(choice_pk, choice.pk)

        choice = Choice.objects.get()