summaryrefslogtreecommitdiff
path: root/tests/fixtures_migration/tests.py
blob: 81cd51d7703ebaa534cf809673523e9eb269e0ac (plain)
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
from django.core import management
from django.test import TransactionTestCase

from .models import Book


class TestNoInitialDataLoading(TransactionTestCase):
    """
    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']

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

    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(), [])