Code

Ticket #526: manipulator_test.3.diff

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

final ;) tests -- pls, ignore previous

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,68 @@
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 C2(models.Model):
18+    message = models.TextField()
19+    class Meta:
20+        pass
21+    class Admin:
22+        pass
23+
24+class Translation(models.Model):
25+    message = models.ForeignKey(Message, edit_inline=models.TABULAR)
26+    language = models.CharField(maxlength=10)
27+    translation = models.TextField(core=True)
28+   
29+    class Meta:
30+        unique_together = (('language', 'message',),)
31+    class Admin:
32+        pass
33+
34+class Message2(models.Model):
35+    message = models.TextField()
36+    class Meta:
37+        pass
38+    class Admin:
39+        pass
40+   
41+class Registry(models.Model):
42+    message = models.ForeignKey(Message2, edit_inline=True)
43+    c2 = models.ForeignKey(C2)
44+    obj = models.CharField(maxlength=255, core=True)
45+    field = models.CharField(maxlength=255)
46+   
47+    class Meta:
48+        unique_together = (('c2', 'field', 'obj'),)
49+    class Admin:
50+        pass
51+
52+
53+class Message3(models.Model):
54+    message = models.TextField()
55+    class Meta:
56+        pass
57+    class Admin:
58+        pass
59+   
60+class Registry2(models.Model):
61+    message = models.ForeignKey(Message2, edit_inline=True)
62+    c2 = models.ForeignKey(C2)
63+    obj = models.CharField(maxlength=255, core=True)
64+    field = models.CharField(maxlength=255)
65+   
66+    class Meta:
67+        unique_together = (('message', 'c2', 'field', 'obj'),)
68+    class Admin:
69+        pass
70+
71 API_TESTS = """
72 >>> from django.utils.datastructures import MultiValueDict
73 
74@@ -88,4 +150,13 @@
75 <Album: Ultimate Ella>
76 >>> a2.release_date
77 datetime.date(2005, 2, 13)
78+
79+# Exception when using unique_together in edit_inline model -- ticket #526
80+>>> t = Message2.AddManipulator()
81+
82+# another problem, unique_together order is important, this fails when first field is not FK
83+>>> t = Message.AddManipulator()
84+
85+>>> t = Message3.AddManipulator()
86+
87 """