Code

Ticket #526: manipulator_test.diff

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

manupulator tests

Line 
1Index: /store/django/tests/modeltests/manipulators/models.py
2===================================================================
3--- /store/django/tests/modeltests/manipulators/models.py       (revision 3508)
4+++ /store/django/tests/modeltests/manipulators/models.py       (working copy)
5@@ -21,6 +21,43 @@
6     def __str__(self):
7         return self.name
8 
9+
10+class Message(models.Model):
11+    message = models.TextField()
12+    class Meta:
13+        pass
14+    class Admin:
15+        pass
16+
17+class Translation(models.Model):
18+    message = models.ForeignKey(Message, edit_inline=models.TABULAR)
19+    language = models.CharField(maxlength=10)
20+    translation = models.TextField(core=True)
21+   
22+    class Meta:
23+        unique_together = (('language', 'message',),)
24+    class Admin:
25+        pass
26+
27+class Message2(models.Model):
28+    message = models.TextField()
29+    class Meta:
30+        pass
31+    class Admin:
32+        pass
33+   
34+class Registry(models.Model):
35+    """ this model breaks Message """
36+    message = models.ForeignKey(Message2, edit_inline=True)
37+    obj = models.CharField(maxlength=255, core=True)
38+    field = models.CharField(maxlength=255)
39+   
40+    class Meta:
41+        unique_together = (('obj', 'field'),)
42+    class Admin:
43+        pass
44+
45+
46 API_TESTS = """
47 >>> from django.utils.datastructures import MultiValueDict
48 
49@@ -88,4 +125,10 @@
50 <Album: Ultimate Ella>
51 >>> a2.release_date
52 datetime.date(2005, 2, 13)
53+
54+# Exception when using unique_together in edit_inline model -- ticket #526
55+>>> t = Message2.AddManipulator()
56+
57+# another problem, unique_together order is important, this fails when first field is not FK
58+>>> t = Message.AddManipulator()
59 """