~ubuntuone-pqm-team/django/stable

« back to all changes in this revision

Viewing changes to tests/regressiontests/indexes/tests.py

  • Committer: Natalia
  • Date: 2014-12-05 15:21:13 UTC
  • Revision ID: natalia.bidart@ubuntu.com-20141205152113-cchtmygjia45gb87
Tags: 1.6.8
- Imported Django 1.6.8 from released tarball.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from django.core.management.color import no_style
2
 
from django.db import connections, DEFAULT_DB_ALIAS
3
 
from django.test import TestCase
4
 
from django.utils.unittest import skipUnless
5
 
 
6
 
from .models import Article
7
 
 
8
 
 
9
 
class IndexesTests(TestCase):
10
 
    def test_index_together(self):
11
 
        connection = connections[DEFAULT_DB_ALIAS]
12
 
        index_sql = connection.creation.sql_indexes_for_model(Article, no_style())
13
 
        self.assertEqual(len(index_sql), 1)
14
 
 
15
 
    @skipUnless(connections[DEFAULT_DB_ALIAS].vendor == 'postgresql',
16
 
        "This is a postgresql-specific issue")
17
 
    def test_postgresql_text_indexes(self):
18
 
        """Test creation of PostgreSQL-specific text indexes (#12234)"""
19
 
        from .models import IndexedArticle
20
 
        connection = connections[DEFAULT_DB_ALIAS]
21
 
        index_sql = connection.creation.sql_indexes_for_model(IndexedArticle, no_style())
22
 
        self.assertEqual(len(index_sql), 5)
23
 
        self.assertIn('("headline" varchar_pattern_ops)', index_sql[1])
24
 
        self.assertIn('("body" text_pattern_ops)', index_sql[3])
25
 
        # unique=True and db_index=True should only create the varchar-specific
26
 
        # index (#19441).
27
 
        self.assertIn('("slug" varchar_pattern_ops)', index_sql[4])