Ticket #7202: onetoone_fixtures_test_r7526.patch

File onetoone_fixtures_test_r7526.patch, 1.1 KB (added by zhaoz, 16 years ago)

Adds a test for onetoone fixture loading -- (needs the onetoone.json fixture)

  • tests/regressiontests/fixtures_regress/models.py

     
    3838        super(Absolute, self).__init__(*args, **kwargs)
    3939        Absolute.load_count += 1
    4040
     41class Parent(models.Model):
     42    name = models.CharField(max_length=60, unique=True)
     43
     44    def __unicode__(self):
     45        return self.name
     46
     47class Child(Parent):
     48    parent = models.OneToOneField(Parent, parent_link=True)
     49    number = models.IntegerField(max_length=20)
     50
     51    def __unicode__(self):
     52        return "%s - %d" % (self.name, self.number)
     53
    4154
    4255__test__ = {'API_TESTS':"""
    4356>>> from django.core import management
     
    7184>>> Absolute.load_count
    72851
    7386
     87##############################################
     88# Regression test for ticket #7202 --
     89# Make sure that children of One-to-One relations don't try to duplicate parent
     90>>> Parent.objects.all().delete()
     91>>> management.call_command('loaddata', 'onetoone', verbosity=0)
     92
     93>>> len(Parent.objects.all())
     941
     95
    7496"""}
Back to Top