| 1 | """
|
|---|
| 2 | Tests for initial SQL insertion.
|
|---|
| 3 | """
|
|---|
| 4 |
|
|---|
| 5 | from django.db import models
|
|---|
| 6 |
|
|---|
| 7 | class 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 |
|
|---|