summaryrefslogtreecommitdiff
path: root/tests/introspection
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2014-09-21 00:00:52 +0200
committerClaude Paroz <claude@2xlibre.net>2014-09-23 20:13:31 +0200
commited297061a676e629983664031d77da1d0a70af7d (patch)
tree963e7499189d929980284139fe9c9b13d717afe7 /tests/introspection
parentb8cdc7dcc3fc6897fb2a75f90023f5c67aad327f (diff)
downloaddjango-ed297061a676e629983664031d77da1d0a70af7d.tar.gz
Fixed #18782 -- Prevented sql_flush to flush views
Thanks rodolfo_3 for the report and the initial patch, and Josh Smeaton, Shai Berger and Tim Graham for the reviews.
Diffstat (limited to 'tests/introspection')
-rw-r--r--tests/introspection/tests.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/introspection/tests.py b/tests/introspection/tests.py
index 59a9a4e5c5..c8dc5411a6 100644
--- a/tests/introspection/tests.py
+++ b/tests/introspection/tests.py
@@ -1,6 +1,7 @@
from __future__ import unicode_literals
from django.db import connection
+from django.db.utils import DatabaseError
from django.test import TestCase, skipUnlessDBFeature
from .models import Reporter, Article
@@ -34,6 +35,23 @@ class IntrospectionTests(TestCase):
tl = connection.introspection.django_table_names(only_existing=False)
self.assertIs(type(tl), list)
+ def test_table_names_with_views(self):
+ with connection.cursor() as cursor:
+ try:
+ cursor.execute(
+ 'CREATE VIEW introspection_article_view AS SELECT headline '
+ 'from introspection_article;')
+ except DatabaseError as e:
+ if 'insufficient privileges' in str(e):
+ self.skipTest("The test user has no CREATE VIEW privileges")
+ else:
+ raise
+
+ self.assertIn('introspection_article_view',
+ connection.introspection.table_names(include_views=True))
+ self.assertNotIn('introspection_article_view',
+ connection.introspection.table_names())
+
def test_installed_models(self):
tables = [Article._meta.db_table, Reporter._meta.db_table]
models = connection.introspection.installed_models(tables)