File: tests.py

package info (click to toggle)
python-django 1.8.18-1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 41,628 kB
  • sloc: python: 189,488; xml: 695; makefile: 194; sh: 169; sql: 11
file content (40 lines) | stat: -rw-r--r-- 1,674 bytes parent folder | download
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
35
36
37
38
39
40
from __future__ import unicode_literals

from django.apps import apps
from django.core.management import CommandError
from django.core.management.color import no_style
from django.core.management.sql import (
    sql_all, sql_create, sql_delete, sql_destroy_indexes, sql_indexes,
)
from django.db import DEFAULT_DB_ALIAS, connections
from django.test import TestCase


class SQLCommandsMigrationsTestCase(TestCase):
    """Tests that apps with migrations can not use sql commands."""

    def test_sql_create(self):
        app_config = apps.get_app_config('commands_sql_migrations')
        with self.assertRaises(CommandError):
            sql_create(app_config, no_style(), connections[DEFAULT_DB_ALIAS])

    def test_sql_delete(self):
        app_config = apps.get_app_config('commands_sql_migrations')
        with self.assertRaises(CommandError):
            sql_delete(app_config, no_style(), connections[DEFAULT_DB_ALIAS], close_connection=False)

    def test_sql_indexes(self):
        app_config = apps.get_app_config('commands_sql_migrations')
        with self.assertRaises(CommandError):
            sql_indexes(app_config, no_style(), connections[DEFAULT_DB_ALIAS])

    def test_sql_destroy_indexes(self):
        app_config = apps.get_app_config('commands_sql_migrations')
        with self.assertRaises(CommandError):
            sql_destroy_indexes(app_config, no_style(),
                                connections[DEFAULT_DB_ALIAS])

    def test_sql_all(self):
        app_config = apps.get_app_config('commands_sql_migrations')
        with self.assertRaises(CommandError):
            sql_all(app_config, no_style(), connections[DEFAULT_DB_ALIAS])