Ticket #8036: 8036-tests-r8571.diff

File 8036-tests-r8571.diff, 2.0 KB (added by Tai Lee, 16 years ago)

Client.country wasn't essential to the tests.

  • tests/regressiontests/select_related_regress/models.py

     
    4949    std = models.ForeignKey(Student)
    5050    cls = models.ForeignKey(Class)
    5151
     52# Models for testing bug #8036.
     53class Country(models.Model):
     54    name = models.CharField(max_length=50)
     55
     56class State(models.Model):
     57    name = models.CharField(max_length=50)
     58    country = models.ForeignKey(Country)
     59
     60class ClientStatus(models.Model):
     61    name = models.CharField(max_length=50)
     62
     63class Client(models.Model):
     64    name = models.CharField(max_length=50)
     65    state = models.ForeignKey(State, null=True)
     66    status = models.ForeignKey(ClientStatus)
     67
    5268__test__ = {'API_TESTS': """
    5369Regression test for bug #7110. When using select_related(), we must query the
    5470Device and Building tables using two different aliases (each) in order to
     
    100116u"std"
    101117>>> e_related.cls.org.person.user.name
    102118u"org"
     119
     120Regression test for bug #8036.
     121
     122>>> australia = Country.objects.create(name='Australia')
     123>>> active = ClientStatus.objects.create(name='active')
     124>>> client = Client.objects.create(name='client', status=active)
     125
     126>>> client.status
     127<ClientStatus: ClientStatus object>
     128>>> Client.objects.select_related().latest('id').status
     129<ClientStatus: ClientStatus object>
     130>>> Client.objects.select_related('state').latest('id').status
     131<ClientStatus: ClientStatus object>
     132>>> Client.objects.select_related('state', 'status').latest('id').status
     133<ClientStatus: ClientStatus object>
     134>>> Client.objects.select_related('state__country').latest('id').status
     135<ClientStatus: ClientStatus object>
     136>>> Client.objects.select_related('state__country', 'status').latest('id').status
     137<ClientStatus: ClientStatus object>
     138>>> Client.objects.select_related('status').latest('id').status
     139<ClientStatus: ClientStatus object>
    103140"""}
Back to Top