forked from django-extensions/django-extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_sqldiff.py
33 lines (26 loc) · 1.28 KB
/
test_sqldiff.py
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
# -*- coding: utf-8 -*-
from django.apps import apps
from django.test import TestCase
# from django.core.management import call_command
from django_extensions.management.commands.sqldiff import SqliteSQLDiff, Command
class SqlDiffTests(TestCase):
def _include_proxy_models_testing(self, should_include_proxy_models): # type: (bool) -> ()
parser = Command().create_parser("test", "sqldiff")
args = ["-a"]
if should_include_proxy_models:
args.append("--include-proxy-models")
options = parser.parse_args(args=args)
instance = SqliteSQLDiff(
apps.get_models(include_auto_created=True),
vars(options),
)
instance.find_differences()
checked_models = {"%s.%s" % (app_label, model_name) for app_label, model_name, _ in instance.differences}
self.assertEqual(should_include_proxy_models, "testapp.PostWithTitleOrdering" in checked_models)
def test_sql_diff_without_proxy_models(self):
self._include_proxy_models_testing(False)
def test_sql_diff_with_proxy_models(self):
self._include_proxy_models_testing(True)
# def test_sql_diff_run(self):
# retcode = call_command("sqldiff", all_applications=True, migrate_for_tests=True)
# self.assertEqual(retcode, 0)