Ticket #4492: ticket-4492_r7583.diff
File ticket-4492_r7583.diff, 2.3 KB (added by , 16 years ago) |
---|
-
tests/modeltests/fixtures/fixtures/fixture4.json
1 [ 2 { 3 "pk": "6", 4 "model": "fixtures.mixedcasem2m", 5 "fields": { 6 "relatedItems": [], 7 "Title": "Poker has no place on ESPN" 8 } 9 }, 10 { 11 "pk": "7", 12 "model": "fixtures.mixedcasem2m", 13 "fields": { 14 "relatedItems": [6], 15 "Title": "Time to reform copyright" 16 } 17 } 18 ] -
tests/modeltests/fixtures/models.py
21 21 class Meta: 22 22 ordering = ('-pub_date', 'headline') 23 23 24 class MixedCaseM2M(models.Model): 25 relatedItems = models.ManyToManyField('self', blank=True, null=True) 26 Title = models.CharField(max_length=100, default='Default title') 27 28 def __unicode__(self): 29 return self.Title 30 31 class Meta: 32 ordering = ('Title',) 33 24 34 __test__ = {'API_TESTS': """ 25 35 >>> from django.core import management 26 36 >>> from django.db.models import get_app … … 82 92 # Dump the current contents of the database as a JSON fixture 83 93 >>> management.call_command('dumpdata', 'fixtures', format='json') 84 94 [{"pk": 3, "model": "fixtures.article", "fields": {"headline": "Time to reform copyright", "pub_date": "2006-06-16 13:00:00"}}, {"pk": 2, "model": "fixtures.article", "fields": {"headline": "Poker has no place on ESPN", "pub_date": "2006-06-16 12:00:00"}}, {"pk": 1, "model": "fixtures.article", "fields": {"headline": "Python program becomes self aware", "pub_date": "2006-06-16 11:00:00"}}] 95 96 # Load fixture 4: a JSON file with mixed-case column names. 97 >>> management.call_command('loaddata', 'fixture4.json', verbosity=0) 98 >>> MixedCaseM2M.objects.all() 99 [<MixedCaseM2M: Poker has no place on ESPN>, <MixedCaseM2M: Time to reform copyright>] 100 >>> mixed = MixedCaseM2M.objects.get(Title__icontains='poker') 101 >>> mixed.relatedItems.all() 102 [<MixedCaseM2M: Time to reform copyright>] 85 103 """ 86 104 87 105 from django.test import TestCase