File: tests.py

package info (click to toggle)
python-django 1.7.7-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 44,872 kB
  • sloc: python: 170,757; xml: 713; makefile: 199; sh: 170; sql: 11
file content (34 lines) | stat: -rw-r--r-- 1,019 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from django.core import management
from django.test import TestCase
from django.test.utils import override_system_checks

from .models import Book


class TestNoInitialDataLoading(TestCase):
    """
    Apps with migrations should ignore initial data. This test can be removed
    in Django 1.9 when migrations become required and initial data is no longer
    supported.
    """
    available_apps = ['fixtures_migration']

    @override_system_checks([])
    def test_migrate(self):
        self.assertQuerysetEqual(Book.objects.all(), [])
        management.call_command(
            'migrate',
            verbosity=0,
        )
        self.assertQuerysetEqual(Book.objects.all(), [])

    @override_system_checks([])
    def test_flush(self):
        self.assertQuerysetEqual(Book.objects.all(), [])
        management.call_command(
            'flush',
            verbosity=0,
            interactive=False,
            load_initial_data=False
        )
        self.assertQuerysetEqual(Book.objects.all(), [])