Changeset 5822 for django/branches/schema-evolution/tests/regressiontests
- Timestamp:
- 08/06/07 11:50:17 (1 year ago)
- Files:
-
- django/branches/schema-evolution/tests/regressiontests/bug639/models.py (modified) (1 diff)
- django/branches/schema-evolution/tests/regressiontests/datatypes/models.py (modified) (1 diff)
- django/branches/schema-evolution/tests/regressiontests/fixtures_regress/models.py (modified) (3 diffs)
- django/branches/schema-evolution/tests/regressiontests/forms/tests.py (modified) (7 diffs)
- django/branches/schema-evolution/tests/regressiontests/initial_sql_regress/models.py (modified) (1 diff)
- django/branches/schema-evolution/tests/regressiontests/invalid_admin_options/models.py (modified) (28 diffs)
- django/branches/schema-evolution/tests/regressiontests/many_to_one_regress/models.py (modified) (1 diff)
- django/branches/schema-evolution/tests/regressiontests/maxlength (copied) (copied from django/trunk/tests/regressiontests/maxlength)
- django/branches/schema-evolution/tests/regressiontests/maxlength/__init__.py (copied) (copied from django/trunk/tests/regressiontests/maxlength/__init__.py)
- django/branches/schema-evolution/tests/regressiontests/maxlength/models.py (copied) (copied from django/trunk/tests/regressiontests/maxlength/models.py)
- django/branches/schema-evolution/tests/regressiontests/maxlength/tests.py (copied) (copied from django/trunk/tests/regressiontests/maxlength/tests.py)
- django/branches/schema-evolution/tests/regressiontests/model_regress/models.py (modified) (1 diff)
- django/branches/schema-evolution/tests/regressiontests/null_queries/models.py (modified) (2 diffs)
- django/branches/schema-evolution/tests/regressiontests/one_to_one_regress/models.py (modified) (2 diffs)
- django/branches/schema-evolution/tests/regressiontests/serializers_regress/models.py (modified) (6 diffs)
- django/branches/schema-evolution/tests/regressiontests/string_lookup/models.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/schema-evolution/tests/regressiontests/bug639/models.py
r5734 r5822 3 3 4 4 class Photo(models.Model): 5 title = models.CharField(max length=30)5 title = models.CharField(max_length=30) 6 6 image = models.FileField(upload_to=tempfile.gettempdir()) 7 7 django/branches/schema-evolution/tests/regressiontests/datatypes/models.py
r5734 r5822 8 8 9 9 class Donut(models.Model): 10 name = models.CharField(max length=100)10 name = models.CharField(max_length=100) 11 11 is_frosted = models.BooleanField(default=False) 12 12 has_sprinkles = models.NullBooleanField() django/branches/schema-evolution/tests/regressiontests/fixtures_regress/models.py
r5734 r5822 3 3 4 4 class Animal(models.Model): 5 name = models.CharField(max length=150)6 latin_name = models.CharField(max length=150)5 name = models.CharField(max_length=150) 6 latin_name = models.CharField(max_length=150) 7 7 8 8 def __unicode__(self): … … 10 10 11 11 class Plant(models.Model): 12 name = models.CharField(max length=150)12 name = models.CharField(max_length=150) 13 13 14 14 class Meta: … … 17 17 18 18 class Stuff(models.Model): 19 name = models.CharField(max length=20, null=True)19 name = models.CharField(max_length=20, null=True) 20 20 owner = models.ForeignKey(User, null=True) 21 21 django/branches/schema-evolution/tests/regressiontests/forms/tests.py
r5788 r5822 174 174 # FileInput Widget ############################################################ 175 175 176 FileInput widgets don't ever show the value, because the old value is of no use 177 if you are updating the form or if the provided file generated an error. 176 178 >>> w = FileInput() 177 179 >>> w.render('email', '') … … 180 182 u'<input type="file" name="email" />' 181 183 >>> w.render('email', 'test@example.com') 182 u'<input type="file" name="email" value="test@example.com"/>'184 u'<input type="file" name="email" />' 183 185 >>> w.render('email', 'some "quoted" & ampersanded value') 184 u'<input type="file" name="email" value="some "quoted" & ampersanded value"/>'186 u'<input type="file" name="email" />' 185 187 >>> w.render('email', 'test@example.com', attrs={'class': 'fun'}) 186 u'<input type="file" name="email" value="test@example.com"class="fun" />'188 u'<input type="file" name="email" class="fun" />' 187 189 188 190 You can also pass 'attrs' to the constructor: … … 191 193 u'<input type="file" class="fun" name="email" />' 192 194 >>> w.render('email', 'foo@example.com') 193 u'<input type="file" class="fun" value="foo@example.com"name="email" />'195 u'<input type="file" class="fun" name="email" />' 194 196 195 197 >>> w.render('email', 'ŠĐĆŽćžšđ', attrs={'class': 'fun'}) 196 u'<input type="file" class="fun" value="\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111"name="email" />'198 u'<input type="file" class="fun" name="email" />' 197 199 198 200 # Textarea Widget ############################################################# … … 1532 1534 ... 1533 1535 ValidationError: [u'Ensure this value has at most 15 characters (it has 20).'] 1536 1537 # FileField ################################################################## 1538 1539 >>> f = FileField() 1540 >>> f.clean('') 1541 Traceback (most recent call last): 1542 ... 1543 ValidationError: [u'This field is required.'] 1544 1545 >>> f.clean(None) 1546 Traceback (most recent call last): 1547 ... 1548 ValidationError: [u'This field is required.'] 1549 1550 >>> f.clean({}) 1551 Traceback (most recent call last): 1552 ... 1553 ValidationError: [u'No file was submitted.'] 1554 1555 >>> f.clean('some content that is not a file') 1556 Traceback (most recent call last): 1557 ... 1558 ValidationError: [u'No file was submitted. Check the encoding type on the form.'] 1559 1560 >>> f.clean({'filename': 'name', 'content':None}) 1561 Traceback (most recent call last): 1562 ... 1563 ValidationError: [u'The submitted file is empty.'] 1564 1565 >>> f.clean({'filename': 'name', 'content':''}) 1566 Traceback (most recent call last): 1567 ... 1568 ValidationError: [u'The submitted file is empty.'] 1569 1570 >>> type(f.clean({'filename': 'name', 'content':'Some File Content'})) 1571 <class 'django.newforms.fields.UploadedFile'> 1534 1572 1535 1573 # URLField ################################################################## … … 2574 2612 >>> class MyForm(Form): 2575 2613 ... def __init__(self, data=None, auto_id=False, field_list=[]): 2576 ... Form.__init__(self, data, auto_id )2614 ... Form.__init__(self, data, auto_id=auto_id) 2577 2615 ... for field in field_list: 2578 2616 ... self.fields[field[0]] = field[1] … … 2592 2630 ... default_field_2 = CharField() 2593 2631 ... def __init__(self, data=None, auto_id=False, field_list=[]): 2594 ... Form.__init__(self, data, auto_id )2632 ... Form.__init__(self, data, auto_id=auto_id) 2595 2633 ... for field in field_list: 2596 2634 ... self.fields[field[0]] = field[1] … … 3247 3285 </select> 3248 3286 3287 # Forms with FileFields ################################################ 3288 3289 FileFields are a special case because they take their data from the request.FILES, 3290 not request.POST. 3291 3292 >>> class FileForm(Form): 3293 ... file1 = FileField() 3294 >>> f = FileForm(auto_id=False) 3295 >>> print f 3296 <tr><th>File1:</th><td><input type="file" name="file1" /></td></tr> 3297 3298 >>> f = FileForm(data={}, files={}, auto_id=False) 3299 >>> print f 3300 <tr><th>File1:</th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="file" name="file1" /></td></tr> 3301 3302 >>> f = FileForm(data={}, files={'file1': {'filename': 'name', 'content':''}}, auto_id=False) 3303 >>> print f 3304 <tr><th>File1:</th><td><ul class="errorlist"><li>The submitted file is empty.</li></ul><input type="file" name="file1" /></td></tr> 3305 3306 >>> f = FileForm(data={}, files={'file1': 'something that is not a file'}, auto_id=False) 3307 >>> print f 3308 <tr><th>File1:</th><td><ul class="errorlist"><li>No file was submitted. Check the encoding type on the form.</li></ul><input type="file" name="file1" /></td></tr> 3309 3310 >>> f = FileForm(data={}, files={'file1': {'filename': 'name', 'content':'some content'}}, auto_id=False) 3311 >>> print f 3312 <tr><th>File1:</th><td><input type="file" name="file1" /></td></tr> 3313 >>> f.is_valid() 3314 True 3315 3249 3316 # Basic form processing in a view ############################################# 3250 3317 django/branches/schema-evolution/tests/regressiontests/initial_sql_regress/models.py
r3937 r5822 6 6 7 7 class Simple(models.Model): 8 name = models.CharField(max length = 50)8 name = models.CharField(max_length = 50) 9 9 10 10 __test__ = {'API_TESTS':""} django/branches/schema-evolution/tests/regressiontests/invalid_admin_options/models.py
r5734 r5822 13 13 #class BadAdminOption(models.Model): 14 14 # "Test nonexistent admin option" 15 # name = models.CharField(max length=30)15 # name = models.CharField(max_length=30) 16 16 # 17 17 # class Admin: … … 23 23 class ListDisplayBadOne(models.Model): 24 24 "Test list_display, list_display must be a list or tuple" 25 first_name = models.CharField(max length=30)25 first_name = models.CharField(max_length=30) 26 26 27 27 class Admin: … … 33 33 class ListDisplayBadTwo(models.Model): 34 34 "Test list_display, list_display items must be attributes, methods or properties." 35 first_name = models.CharField(max length=30)35 first_name = models.CharField(max_length=30) 36 36 37 37 class Admin: … … 42 42 class ListDisplayBadThree(models.Model): 43 43 "Test list_display, list_display items can not be a ManyToManyField." 44 first_name = models.CharField(max length=30)44 first_name = models.CharField(max_length=30) 45 45 nick_names = models.ManyToManyField('ListDisplayGood') 46 46 … … 53 53 class ListDisplayGood(models.Model): 54 54 "Test list_display, Admin list_display can be a attribute, method or property." 55 first_name = models.CharField(max length=30)55 first_name = models.CharField(max_length=30) 56 56 57 57 def _last_name(self): … … 67 67 class ListDisplayLinksBadOne(models.Model): 68 68 "Test list_display_links, item must be included in list_display." 69 first_name = models.CharField(max length=30)70 last_name = models.CharField(max length=30)69 first_name = models.CharField(max_length=30) 70 last_name = models.CharField(max_length=30) 71 71 72 72 class Admin: … … 79 79 class ListDisplayLinksBadTwo(models.Model): 80 80 "Test list_display_links, must be a list or tuple." 81 first_name = models.CharField(max length=30)82 last_name = models.CharField(max length=30)81 first_name = models.CharField(max_length=30) 82 last_name = models.CharField(max_length=30) 83 83 84 84 class Admin: … … 93 93 #class ListDisplayLinksBadThree(models.Model): 94 94 # "Test list_display_links, must define list_display to use list_display_links." 95 # first_name = models.CharField(max length=30)96 # last_name = models.CharField(max length=30)95 # first_name = models.CharField(max_length=30) 96 # last_name = models.CharField(max_length=30) 97 97 # 98 98 # class Admin: … … 104 104 class ListDisplayLinksGood(models.Model): 105 105 "Test list_display_links, Admin list_display_list can be a attribute, method or property." 106 first_name = models.CharField(max length=30)106 first_name = models.CharField(max_length=30) 107 107 108 108 def _last_name(self): … … 119 119 class ListFilterBadOne(models.Model): 120 120 "Test list_filter, must be a list or tuple." 121 first_name = models.CharField(max length=30)121 first_name = models.CharField(max_length=30) 122 122 123 123 class Admin: … … 129 129 class ListFilterBadTwo(models.Model): 130 130 "Test list_filter, must be a field not a property or method." 131 first_name = models.CharField(max length=30)131 first_name = models.CharField(max_length=30) 132 132 133 133 def _last_name(self): … … 147 147 class DateHierarchyBadOne(models.Model): 148 148 "Test date_hierarchy, must be a date or datetime field." 149 first_name = models.CharField(max length=30)149 first_name = models.CharField(max_length=30) 150 150 birth_day = models.DateField() 151 151 … … 159 159 class DateHierarchyBadTwo(models.Model): 160 160 "Test date_hieracrhy, must be a field." 161 first_name = models.CharField(max length=30)161 first_name = models.CharField(max_length=30) 162 162 birth_day = models.DateField() 163 163 … … 170 170 class DateHierarchyGood(models.Model): 171 171 "Test date_hieracrhy, must be a field." 172 first_name = models.CharField(max length=30)172 first_name = models.CharField(max_length=30) 173 173 birth_day = models.DateField() 174 174 … … 178 178 class SearchFieldsBadOne(models.Model): 179 179 "Test search_fields, must be a list or tuple." 180 first_name = models.CharField(max length=30)180 first_name = models.CharField(max_length=30) 181 181 182 182 class Admin: … … 189 189 class SearchFieldsBadTwo(models.Model): 190 190 "Test search_fields, must be a field." 191 first_name = models.CharField(max length=30)191 first_name = models.CharField(max_length=30) 192 192 193 193 def _last_name(self): … … 204 204 class SearchFieldsGood(models.Model): 205 205 "Test search_fields, must be a list or tuple." 206 first_name = models.CharField(max length=30)207 last_name = models.CharField(max length=30)206 first_name = models.CharField(max_length=30) 207 last_name = models.CharField(max_length=30) 208 208 209 209 class Admin: … … 213 213 class JsBadOne(models.Model): 214 214 "Test js, must be a list or tuple" 215 name = models.CharField(max length=30)215 name = models.CharField(max_length=30) 216 216 217 217 class Admin: … … 224 224 class SaveAsBad(models.Model): 225 225 "Test save_as, should be True or False" 226 name = models.CharField(max length=30)226 name = models.CharField(max_length=30) 227 227 228 228 class Admin: … … 235 235 class SaveOnTopBad(models.Model): 236 236 "Test save_on_top, should be True or False" 237 name = models.CharField(max length=30)237 name = models.CharField(max_length=30) 238 238 239 239 class Admin: … … 246 246 class ListSelectRelatedBad(models.Model): 247 247 "Test list_select_related, should be True or False" 248 name = models.CharField(max length=30)248 name = models.CharField(max_length=30) 249 249 250 250 class Admin: … … 257 257 class ListPerPageBad(models.Model): 258 258 "Test list_per_page, should be a positive integer value." 259 name = models.CharField(max length=30)259 name = models.CharField(max_length=30) 260 260 261 261 class Admin: … … 268 268 class FieldsBadOne(models.Model): 269 269 "Test fields, should be a tuple" 270 first_name = models.CharField(max length=30)271 last_name = models.CharField(max length=30)270 first_name = models.CharField(max_length=30) 271 last_name = models.CharField(max_length=30) 272 272 273 273 class Admin: … … 280 280 class FieldsBadTwo(models.Model): 281 281 """Test fields, 'fields' dict option is required.""" 282 first_name = models.CharField(max length=30)283 last_name = models.CharField(max length=30)282 first_name = models.CharField(max_length=30) 283 last_name = models.CharField(max_length=30) 284 284 285 285 class Admin: … … 292 292 class FieldsBadThree(models.Model): 293 293 """Test fields, 'classes' and 'description' are the only allowable extra dict options.""" 294 first_name = models.CharField(max length=30)295 last_name = models.CharField(max length=30)294 first_name = models.CharField(max_length=30) 295 last_name = models.CharField(max_length=30) 296 296 297 297 class Admin: … … 304 304 class FieldsGood(models.Model): 305 305 "Test fields, working example" 306 first_name = models.CharField(max length=30)307 last_name = models.CharField(max length=30)306 first_name = models.CharField(max_length=30) 307 last_name = models.CharField(max_length=30) 308 308 birth_day = models.DateField() 309 309 … … 316 316 class OrderingBad(models.Model): 317 317 "Test ordering, must be a field." 318 first_name = models.CharField(max length=30)319 last_name = models.CharField(max length=30)318 first_name = models.CharField(max_length=30) 319 last_name = models.CharField(max_length=30) 320 320 321 321 class Admin: … … 329 329 #class ManagerBad(models.Model): 330 330 # "Test manager, must be a manager object." 331 # first_name = models.CharField(max length=30)331 # first_name = models.CharField(max_length=30) 332 332 # 333 333 # class Admin: django/branches/schema-evolution/tests/regressiontests/many_to_one_regress/models.py
r5734 r5822 13 13 # Protect against repetition of #1839, #2415 and #2536. 14 14 class Third(models.Model): 15 name = models.CharField(max length=20)15 name = models.CharField(max_length=20) 16 16 third = models.ForeignKey('self', null=True, related_name='child_set') 17 17 18 18 class Parent(models.Model): 19 name = models.CharField(max length=20)19 name = models.CharField(max_length=20) 20 20 bestchild = models.ForeignKey('Child', null=True, related_name='favored_by') 21 21 22 22 class Child(models.Model): 23 name = models.CharField(max length=20)23 name = models.CharField(max_length=20) 24 24 parent = models.ForeignKey(Parent) 25 25 django/branches/schema-evolution/tests/regressiontests/model_regress/models.py
r5734 r5822 8 8 9 9 class Article(models.Model): 10 headline = models.CharField(max length=100, default='Default headline')10 headline = models.CharField(max_length=100, default='Default headline') 11 11 pub_date = models.DateTimeField() 12 12 status = models.IntegerField(blank=True, null=True, choices=CHOICES) django/branches/schema-evolution/tests/regressiontests/null_queries/models.py
r5734 r5822 2 2 3 3 class Poll(models.Model): 4 question = models.CharField(max length=200)4 question = models.CharField(max_length=200) 5 5 6 6 def __unicode__(self): … … 9 9 class Choice(models.Model): 10 10 poll = models.ForeignKey(Poll) 11 choice = models.CharField(max length=200)11 choice = models.CharField(max_length=200) 12 12 13 13 def __unicode__(self): django/branches/schema-evolution/tests/regressiontests/one_to_one_regress/models.py
r5734 r5822 2 2 3 3 class Place(models.Model): 4 name = models.CharField(max length=50)5 address = models.CharField(max length=80)4 name = models.CharField(max_length=50) 5 address = models.CharField(max_length=80) 6 6 7 7 def __unicode__(self): … … 17 17 18 18 class Favorites(models.Model): 19 name = models.CharField(max length = 50)19 name = models.CharField(max_length = 50) 20 20 restaurants = models.ManyToManyField(Restaurant) 21 21 django/branches/schema-evolution/tests/regressiontests/serializers_regress/models.py
r5734 r5822 17 17 18 18 class CharData(models.Model): 19 data = models.CharField(max length=30, null=True)19 data = models.CharField(max_length=30, null=True) 20 20 21 21 class DateData(models.Model): … … 91 91 92 92 class GenericData(models.Model): 93 data = models.CharField(max length=30)93 data = models.CharField(max_length=30) 94 94 95 95 tags = generic.GenericRelation(Tag) … … 103 103 something for other models to point at""" 104 104 105 data = models.CharField(max length=30)105 data = models.CharField(max_length=30) 106 106 107 107 class UniqueAnchor(models.Model): … … 109 109 something for other models to point at""" 110 110 111 data = models.CharField(unique=True, max length=30)111 data = models.CharField(unique=True, max_length=30) 112 112 113 113 class FKData(models.Model): … … 145 145 146 146 class CharPKData(models.Model): 147 data = models.CharField(max length=30, primary_key=True)147 data = models.CharField(max_length=30, primary_key=True) 148 148 149 149 # class DatePKData(models.Model): … … 209 209 210 210 class ComplexModel(models.Model): 211 field1 = models.CharField(max length=10)212 field2 = models.CharField(max length=10)213 field3 = models.CharField(max length=10)211 field1 = models.CharField(max_length=10) 212 field2 = models.CharField(max_length=10) 213 field3 = models.CharField(max_length=10) 214 214 215 215 # Tests for handling fields with pre_save functions, or django/branches/schema-evolution/tests/regressiontests/string_lookup/models.py
r5734 r5822 3 3 4 4 class Foo(models.Model): 5 name = models.CharField(max length=50)6 friend = models.CharField(max length=50, blank=True)5 name = models.CharField(max_length=50) 6 friend = models.CharField(max_length=50, blank=True) 7 7 8 8 def __unicode__(self): … … 10 10 11 11 class Bar(models.Model): 12 name = models.CharField(max length=50)12 name = models.CharField(max_length=50) 13 13 normal = models.ForeignKey(Foo, related_name='normal_foo') 14 14 fwd = models.ForeignKey("Whiz") … … 19 19 20 20 class Whiz(models.Model): 21 name = models.CharField(max length = 50)21 name = models.CharField(max_length = 50) 22 22 23 23 def __unicode__(self): … … 26 26 class Child(models.Model): 27 27 parent = models.OneToOneField('Base') 28 name = models.CharField(max length = 50)28 name = models.CharField(max_length = 50) 29 29 30 30 def __unicode__(self): … … 32 32 33 33 class Base(models.Model): 34 name = models.CharField(max length = 50)34 name = models.CharField(max_length = 50) 35 35 36 36 def __unicode__(self):
