Ticket #3485: models.py

File models.py, 932 bytes (added by Craig Ogg <cogg@…>, 17 years ago)

Should go in trunk/tests/modeltests/initial_sql/

Line 
1"""
2Tests for initial SQL insertion.
3"""
4
5from django.db import models
6
7class Simple(models.Model):
8 name = models.CharField(max_length = 50)
9
10 def __unicode__(self):
11 return self.name
12
13
14__test__ = {'API_TESTS':"""
15# Syncdb introduces these records from custom SQL.
16>>> from django.conf import settings
17>>> from django.core import management
18>>> from django.db.models import get_app
19
20# Error only occurs when adding the SQL query to the debug output
21# so need to be in debug mode
22>>> _debug_setting_old = settings.DEBUG
23>>> settings.DEBUG = True
24
25# Reset the database representation of this app in a way that will
26# trigger initial SQL loading while in DEBUG mode
27>>> management.reset(get_app('initial_sql'), interactive=False)
28
29>>> Simple.objects.all()
30[<Simple: John & Kathy>, <Simple: Miles O'Brien>, <Simple: "100%" of % are not placeholders>]
31
32# Restore DEBUG setting
33>>> settings.DEBUG = _debug_setting_old
34"""}
35
Back to Top