Ticket #526: manipulator_test.3.diff

File manipulator_test.3.diff, 2.3 KB (added by nesh <nesh [at] studioquattro [dot] co [dot] yu>, 18 years ago)

final ;) tests -- pls, ignore previous

  • store/django/tests/modeltests/manipulators/models.py

     
    2121    def __str__(self):
    2222        return self.name
    2323
     24
     25class Message(models.Model):
     26    message = models.TextField()
     27    class Meta:
     28        pass
     29    class Admin:
     30        pass
     31
     32class C2(models.Model):
     33    message = models.TextField()
     34    class Meta:
     35        pass
     36    class Admin:
     37        pass
     38
     39class Translation(models.Model):
     40    message = models.ForeignKey(Message, edit_inline=models.TABULAR)
     41    language = models.CharField(maxlength=10)
     42    translation = models.TextField(core=True)
     43   
     44    class Meta:
     45        unique_together = (('language', 'message',),)
     46    class Admin:
     47        pass
     48
     49class Message2(models.Model):
     50    message = models.TextField()
     51    class Meta:
     52        pass
     53    class Admin:
     54        pass
     55   
     56class Registry(models.Model):
     57    message = models.ForeignKey(Message2, edit_inline=True)
     58    c2 = models.ForeignKey(C2)
     59    obj = models.CharField(maxlength=255, core=True)
     60    field = models.CharField(maxlength=255)
     61   
     62    class Meta:
     63        unique_together = (('c2', 'field', 'obj'),)
     64    class Admin:
     65        pass
     66
     67
     68class Message3(models.Model):
     69    message = models.TextField()
     70    class Meta:
     71        pass
     72    class Admin:
     73        pass
     74   
     75class Registry2(models.Model):
     76    message = models.ForeignKey(Message2, edit_inline=True)
     77    c2 = models.ForeignKey(C2)
     78    obj = models.CharField(maxlength=255, core=True)
     79    field = models.CharField(maxlength=255)
     80   
     81    class Meta:
     82        unique_together = (('message', 'c2', 'field', 'obj'),)
     83    class Admin:
     84        pass
     85
    2486API_TESTS = """
    2587>>> from django.utils.datastructures import MultiValueDict
    2688
     
    88150<Album: Ultimate Ella>
    89151>>> a2.release_date
    90152datetime.date(2005, 2, 13)
     153
     154# Exception when using unique_together in edit_inline model -- ticket #526
     155>>> t = Message2.AddManipulator()
     156
     157# another problem, unique_together order is important, this fails when first field is not FK
     158>>> t = Message.AddManipulator()
     159
     160>>> t = Message3.AddManipulator()
     161
    91162"""
Back to Top