Ticket #4562: 4562_tests.diff

File 4562_tests.diff, 968 bytes (added by Philippe Raoult, 17 years ago)

tests unique_together with models

  • tests/modeltests/validation/models.py

     
    1717    favorite_moment = models.DateTimeField()
    1818    email = models.EmailField()
    1919
     20    class Meta:
     21        unique_together = ("name", "email")
     22   
    2023    def __unicode__(self):
    2124        return self.name
    2225
     
    150153>>> Person(name='John Doe', is_child=True, email='abc@def.com').validate()
    151154{'favorite_moment': [u'This field is required.'], 'birthdate': [u'This field is required.']}
    152155
     156# check if unique_together lets us create persons which only differ by the case.
     157# This test will pass under sqlite but fail with mysql
     158>>> p = Person.objects.create(**valid_params)
     159>>> p
     160<Person: John>
     161
     162>>> valid_params['name'] = 'JoHn'
     163>>> p = Person.objects.create(**valid_params)
     164>>> p
     165<Person: JoHn>
     166
    153167"""}
Back to Top