Ticket #6559: m2m_sqlite_windows.diff

File m2m_sqlite_windows.diff, 4.3 KB (added by Manoj Govindan <egmanoj@…>, 17 years ago)

Tests for the defect.

  • modeltests/m2m_sqlite_windows/fixtures/testdata.xml

     
     1<?xml version="1.0" encoding="utf-8"?>
     2<django-objects version="1.0">
     3        <object pk="1" model="auth.user">
     4                <field type="CharField" name="username">twoface</field>
     5                <field type="CharField" name="first_name">Harvey</field>
     6                <field type="CharField" name="last_name">Dent</field>
     7                <field type="CharField" name="email"></field>
     8                <field type="CharField" name="password">sha1$9d97d$677bc2aed4ea5a6c529646d2f9fe531340a2625b</field>
     9                <field type="BooleanField" name="is_staff">True</field>
     10                <field type="BooleanField" name="is_active">True</field>
     11                <field type="BooleanField" name="is_superuser">True</field>
     12                <field type="DateTimeField" name="last_login">2007-07-17 15:46:41</field>
     13                <field type="DateTimeField" name="date_joined">2007-07-17 15:46:41</field>
     14                <field to="auth.group" name="groups" rel="ManyToManyRel"></field>
     15                <field to="auth.permission" name="user_permissions" rel="ManyToManyRel"></field>
     16        </object>
     17        <object pk="2" model="auth.user">
     18                <field type="CharField" name="username">penguin</field>
     19                <field type="CharField" name="first_name">Oswald</field>
     20                <field type="CharField" name="last_name">Cobblepot</field>
     21                <field type="CharField" name="email"></field>
     22                <field type="CharField" name="password">sha1$9d97d$677bc2aed4ea5a6c529646d2f9fe531340a2625b</field>
     23                <field type="BooleanField" name="is_staff">True</field>
     24                <field type="BooleanField" name="is_active">True</field>
     25                <field type="BooleanField" name="is_superuser">True</field>
     26                <field type="DateTimeField" name="last_login">2007-07-17 15:46:41</field>
     27                <field type="DateTimeField" name="date_joined">2007-07-17 15:46:41</field>
     28                <field to="auth.group" name="groups" rel="ManyToManyRel"></field>
     29                <field to="auth.permission" name="user_permissions" rel="ManyToManyRel"></field>
     30        </object>
     31
     32    <!-- twoface's books -->
     33        <object pk="1" model="m2m_sqlite_windows.book">
     34                <field type="CharField" name="name">My Lives: Two Face</field>
     35                <field to="auth.user" name="users" rel="ManyToManyRel">
     36                        <object pk="1"></object>
     37                </field>
     38        </object>
     39
     40        <object pk="2" model="m2m_sqlite_windows.book">
     41                <field type="CharField" name="name">Why we don't need Batman</field>
     42                <field to="auth.user" name="users" rel="ManyToManyRel">
     43                        <object pk="1"></object>
     44                </field>
     45        </object>
     46
     47    <!-- penguin's books -->
     48        <object pk="3" model="m2m_sqlite_windows.book">
     49                <field type="CharField" name="name">Global Warming: The Looming Danger</field>
     50                <field to="auth.user" name="users" rel="ManyToManyRel">
     51                        <object pk="2"></object>
     52                </field>
     53        </object>
     54</django-objects>
     55 No newline at end of file
  • modeltests/m2m_sqlite_windows/models.py

     
     1"""
     2Regression tests for Sqlite adapter, particularly on Windows
     3
     4"""
     5from django.db import models
     6from django.contrib.auth.models import User
     7
     8class Book(models.Model):
     9    name = models.CharField(max_length = 255, unique = True)
     10    users = models.ManyToManyField(User)
     11
     12    def __unicode__(self):
     13        return self.name   
     14
     15__test__ = {'API_TESTS':"""
     16#Look up all books
     17>>> from django.core import management
     18>>> management.call_command('loaddata', 'testdata.xml', verbosity=0)
     19>>> Book.objects.filter()
     20[<Book: My Lives: Two Face>, <Book: Why we don't need Batman>, <Book: Global Warming: The Looming Danger>]
     21
     22# Look up books belonging to twoface
     23>>> Book.objects.filter(users__username = 'twoface')
     24[<Book: My Lives: Two Face>, <Book: Why we don't need Batman>]
     25
     26>>> Book.objects.filter(users__username__exact = 'twoface')
     27[<Book: My Lives: Two Face>, <Book: Why we don't need Batman>]
     28
     29# Look up books belonging to penguin
     30>>> Book.objects.filter(users__username = 'penguin')
     31[<Book: Global Warming: The Looming Danger>]
     32
     33>>> Book.objects.filter(users__username__exact = 'penguin')
     34[<Book: Global Warming: The Looming Danger>]
     35"""}
Back to Top