Ticket #4492: ticket-4492_r7583.diff

File ticket-4492_r7583.diff, 2.3 KB (added by John Shaffer, 16 years ago)

Patch against [7583].

  • 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

     
    2121    class Meta:
    2222        ordering = ('-pub_date', 'headline')
    2323
     24class 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
    2434__test__ = {'API_TESTS': """
    2535>>> from django.core import management
    2636>>> from django.db.models import get_app
     
    8292# Dump the current contents of the database as a JSON fixture
    8393>>> management.call_command('dumpdata', 'fixtures', format='json')
    8494[{"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>]
    85103"""
    86104
    87105from django.test import TestCase
Back to Top