diff --git a/tests/regressiontests/multiple_database_regress/__init__.py b/tests/regressiontests/multiple_database_regress/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/tests/regressiontests/multiple_database_regress/models.py b/tests/regressiontests/multiple_database_regress/models.py
new file mode 100644
index 0000000..5f370dc
-
|
+
|
|
| 1 | from django.db import models |
| 2 | |
| 3 | class Author(models.Model): |
| 4 | name = models.CharField(max_length=100) |
| 5 | |
| 6 | def __unicode__(self): |
| 7 | return self.name |
| 8 | |
| 9 | class Book(models.Model): |
| 10 | title = models.CharField(max_length=100) |
| 11 | authors = models.ManyToManyField(Author, through='Authorship') |
| 12 | |
| 13 | def __unicode__(self): |
| 14 | return self.title |
| 15 | |
| 16 | class Authorship(models.Model): |
| 17 | author = models.ForeignKey(Author, db_column='Author_ID') |
| 18 | book = models.ForeignKey(Book, db_column='Book_ID') |
diff --git a/tests/regressiontests/multiple_database_regress/tests.py b/tests/regressiontests/multiple_database_regress/tests.py
new file mode 100644
index 0000000..84c534d
-
|
+
|
|
| 1 | from django.test import TestCase |
| 2 | |
| 3 | from models import Author, Book, Authorship |
| 4 | |
| 5 | class ManyToManyWithCustomColumnTestCase(TestCase): |
| 6 | def setUp(self): |
| 7 | self.a = Author.objects.create(name="J.R.R. Tolkien") |
| 8 | self.b1 = Book.objects.create(title="The Hobbit") |
| 9 | self.b2 = Book.objects.create(title="The Fellowship of the Ring") |
| 10 | self.auth1 = Authorship.objects.create(author=self.a, book=self.b1) |
| 11 | self.auth2 = Authorship.objects.create(author=self.a, book=self.b2) |
| 12 | |
| 13 | def test_query(self): |
| 14 | self.assertEqual(list(self.a.book_set.all()), [self.b1, self.b2]) |
| 15 | self.assertEqual(list(self.b1.authors.all()), [self.a]) |
| 16 | self.assertEqual(list(self.a.authorship_set.all()), [self.auth1, self.auth2]) |
| 17 | self.assertEqual(list(self.b1.authorship_set.all()), [self.auth1]) |