~ubuntu-branches/debian/sid/python-django/sid

« back to all changes in this revision

Viewing changes to tests/indexes/tests.py

  • Committer: Package Import Robot
  • Author(s): Raphaël Hertzog
  • Date: 2014-09-17 14:15:11 UTC
  • mfrom: (1.3.17) (6.2.18 experimental)
  • Revision ID: package-import@ubuntu.com-20140917141511-icneokthe9ww5sk4
Tags: 1.7-2
* Release to unstable.
* Add a migrate-south sample script to help users apply their South
  migrations. Thanks to Brian May.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from unittest import skipUnless
 
2
 
1
3
from django.core.management.color import no_style
2
 
from django.db import connection, connections, DEFAULT_DB_ALIAS
 
4
from django.db import connection
3
5
from django.test import TestCase
4
 
from django.utils.unittest import skipUnless
5
6
 
6
 
from .models import Article
 
7
from .models import Article, IndexTogetherSingleList
7
8
 
8
9
 
9
10
class IndexesTests(TestCase):
10
11
    def test_index_together(self):
11
 
        connection = connections[DEFAULT_DB_ALIAS]
12
12
        index_sql = connection.creation.sql_indexes_for_model(Article, no_style())
13
13
        self.assertEqual(len(index_sql), 1)
14
14
 
15
 
    @skipUnless(connections[DEFAULT_DB_ALIAS].vendor == 'postgresql',
 
15
    def test_index_together_single_list(self):
 
16
        # Test for using index_together with a single list (#22172)
 
17
        index_sql = connection.creation.sql_indexes_for_model(IndexTogetherSingleList, no_style())
 
18
        self.assertEqual(len(index_sql), 1)
 
19
 
 
20
    @skipUnless(connection.vendor == 'postgresql',
16
21
        "This is a postgresql-specific issue")
17
22
    def test_postgresql_text_indexes(self):
18
23
        """Test creation of PostgreSQL-specific text indexes (#12234)"""
19
24
        from .models import IndexedArticle
20
 
        connection = connections[DEFAULT_DB_ALIAS]
21
25
        index_sql = connection.creation.sql_indexes_for_model(IndexedArticle, no_style())
22
26
        self.assertEqual(len(index_sql), 5)
23
27
        self.assertIn('("headline" varchar_pattern_ops)', index_sql[1])