Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding tests for multiple column indexes

  • Loading branch information...
commit 22a61584c68c63d58b3b5e0d4ac94f183949f46f 1 parent ca7bd0b
Charles Leifer authored
Showing with 23 additions and 2 deletions.
  1. +23 −2 tests.py
25 tests.py
View
@@ -167,9 +167,20 @@ class SeqModelB(TestModel):
id = IntegerField(primary_key=True, sequence='just_testing_seq')
other_num = IntegerField()
+class MultiIndexModel(TestModel):
+ f1 = CharField()
+ f2 = CharField()
+ f3 = CharField()
+
+ class Meta:
+ indexes = (
+ (('f1', 'f2'), True),
+ (('f2', 'f3'), False),
+ )
+
MODELS = [User, Blog, Comment, Relationship, NullModel, UniqueModel, OrderedModel, Category, UserCategory,
- NonIntModel, NonIntRelModel, DBUser, DBBlog, SeqModelA, SeqModelB]
+ NonIntModel, NonIntRelModel, DBUser, DBBlog, SeqModelA, SeqModelB, MultiIndexModel]
INT = test_db.interpolation
def drop_tables(only=None):
@@ -1133,7 +1144,7 @@ class CustomFormatsModel(Model):
class UniqueTestCase(ModelTestCase):
- requires = [UniqueModel]
+ requires = [UniqueModel, MultiIndexModel]
def test_unique(self):
uniq1 = UniqueModel.create(name='a')
@@ -1141,6 +1152,16 @@ def test_unique(self):
self.assertRaises(Exception, UniqueModel.create, name='a')
test_db.rollback()
+ def test_multi_index(self):
+ mi1 = MultiIndexModel.create(f1='a', f2='a', f3='a')
+ mi2 = MultiIndexModel.create(f1='b', f2='b', f3='b')
+ self.assertRaises(Exception, MultiIndexModel.create, f1='a', f2='a', f3='b')
+ test_db.rollback()
+ self.assertRaises(Exception, MultiIndexModel.create, f1='b', f2='b', f3='a')
+ test_db.rollback()
+
+ mi3 = MultiIndexModel.create(f1='a', f2='b', f3='b')
+
class NonIntPKTestCase(ModelTestCase):
requires = [NonIntModel, NonIntRelModel]
Please sign in to comment.
Something went wrong with that request. Please try again.