diff options
| author | Alex Gaynor <alex.gaynor@gmail.com> | 2013-11-03 09:51:49 -0800 |
|---|---|---|
| committer | Alex Gaynor <alex.gaynor@gmail.com> | 2013-11-03 09:51:49 -0800 |
| commit | 7288e1b02b2504b1694fe14df2d81e6a354c5610 (patch) | |
| tree | a4bb2a34ffc03d4939c6d8f961bddc1918b8fd9c /tests/multiple_database | |
| parent | 91078f566904e49fbf99ec6375ba627e821f6143 (diff) | |
| parent | 4f151da1e5e9bf527548a5737d9cd314e3abc68e (diff) | |
Merge pull request #1852 from jasonamyers/cleanup/PEP8
Cleanup/pep8 tests
Diffstat (limited to 'tests/multiple_database')
| -rw-r--r-- | tests/multiple_database/models.py | 6 | ||||
| -rw-r--r-- | tests/multiple_database/tests.py | 216 |
2 files changed, 123 insertions, 99 deletions
diff --git a/tests/multiple_database/models.py b/tests/multiple_database/models.py index 00534c870c..fc5b28ad92 100644 --- a/tests/multiple_database/models.py +++ b/tests/multiple_database/models.py @@ -18,10 +18,12 @@ class Review(models.Model): class Meta: ordering = ('source',) + class PersonManager(models.Manager): def get_by_natural_key(self, name): return self.get(name=name) + @python_2_unicode_compatible class Person(models.Model): objects = PersonManager() @@ -33,6 +35,7 @@ class Person(models.Model): class Meta: ordering = ('name',) + # This book manager doesn't do anything interesting; it just # exists to strip out the 'extra_arg' argument to certain # calls. This argument is used to establish that the BookManager @@ -46,6 +49,7 @@ class BookManager(models.Manager): kwargs.pop('extra_arg', None) return super(BookManager, self).get_or_create(*args, **kwargs) + @python_2_unicode_compatible class Book(models.Model): objects = BookManager() @@ -62,6 +66,7 @@ class Book(models.Model): class Meta: ordering = ('title',) + @python_2_unicode_compatible class Pet(models.Model): name = models.CharField(max_length=100) @@ -73,6 +78,7 @@ class Pet(models.Model): class Meta: ordering = ('name',) + class UserProfile(models.Model): user = models.OneToOneField(User, null=True) flavor = models.CharField(max_length=100) diff --git a/tests/multiple_database/tests.py b/tests/multiple_database/tests.py index 679c7e33f5..222d236bb0 100644 --- a/tests/multiple_database/tests.py +++ b/tests/multiple_database/tests.py @@ -50,7 +50,8 @@ class QueryTestCase(TestCase): except Book.DoesNotExist: self.fail('"Pro Django" should exist on default database') - self.assertRaises(Book.DoesNotExist, + self.assertRaises( + Book.DoesNotExist, Book.objects.using('other').get, title="Pro Django" ) @@ -61,7 +62,8 @@ class QueryTestCase(TestCase): except Book.DoesNotExist: self.fail('"Dive into Python" should exist on default database') - self.assertRaises(Book.DoesNotExist, + self.assertRaises( + Book.DoesNotExist, Book.objects.using('other').get, title="Dive into Python" ) @@ -84,11 +86,13 @@ class QueryTestCase(TestCase): except Book.DoesNotExist: self.fail('"Pro Django" should exist on other database') - self.assertRaises(Book.DoesNotExist, + self.assertRaises( + Book.DoesNotExist, Book.objects.get, title="Pro Django" ) - self.assertRaises(Book.DoesNotExist, + self.assertRaises( + Book.DoesNotExist, Book.objects.using('default').get, title="Pro Django" ) @@ -98,11 +102,13 @@ class QueryTestCase(TestCase): except Book.DoesNotExist: self.fail('"Dive into Python" should exist on other database') - self.assertRaises(Book.DoesNotExist, + self.assertRaises( + Book.DoesNotExist, Book.objects.get, title="Dive into Python" ) - self.assertRaises(Book.DoesNotExist, + self.assertRaises( + Book.DoesNotExist, Book.objects.using('default').get, title="Dive into Python" ) @@ -164,14 +170,14 @@ class QueryTestCase(TestCase): # Check that queries work across m2m joins self.assertEqual(list(Book.objects.using('default').filter(authors__name='Marty Alchin').values_list('title', flat=True)), - ['Pro Django']) + ['Pro Django']) self.assertEqual(list(Book.objects.using('other').filter(authors__name='Marty Alchin').values_list('title', flat=True)), - []) + []) self.assertEqual(list(Book.objects.using('default').filter(authors__name='Mark Pilgrim').values_list('title', flat=True)), - []) + []) self.assertEqual(list(Book.objects.using('other').filter(authors__name='Mark Pilgrim').values_list('title', flat=True)), - ['Dive into Python']) + ['Dive into Python']) # Reget the objects to clear caches dive = Book.objects.using('other').get(title="Dive into Python") @@ -179,10 +185,10 @@ class QueryTestCase(TestCase): # Retrive related object by descriptor. Related objects should be database-baound self.assertEqual(list(dive.authors.all().values_list('name', flat=True)), - ['Mark Pilgrim']) + ['Mark Pilgrim']) self.assertEqual(list(mark.book_set.all().values_list('title', flat=True)), - ['Dive into Python']) + ['Dive into Python']) def test_m2m_forward_operations(self): "M2M forward manipulations are all constrained to a single DB" @@ -198,34 +204,34 @@ class QueryTestCase(TestCase): # Add a second author john = Person.objects.using('other').create(name="John Smith") self.assertEqual(list(Book.objects.using('other').filter(authors__name='John Smith').values_list('title', flat=True)), - []) + []) dive.authors.add(john) self.assertEqual(list(Book.objects.using('other').filter(authors__name='Mark Pilgrim').values_list('title', flat=True)), - ['Dive into Python']) + ['Dive into Python']) self.assertEqual(list(Book.objects.using('other').filter(authors__name='John Smith').values_list('title', flat=True)), - ['Dive into Python']) + ['Dive into Python']) # Remove the second author dive.authors.remove(john) self.assertEqual(list(Book.objects.using('other').filter(authors__name='Mark Pilgrim').values_list('title', flat=True)), - ['Dive into Python']) + ['Dive into Python']) self.assertEqual(list(Book.objects.using('other').filter(authors__name='John Smith').values_list('title', flat=True)), - []) + []) # Clear all authors dive.authors.clear() self.assertEqual(list(Book.objects.using('other').filter(authors__name='Mark Pilgrim').values_list('title', flat=True)), - []) + []) self.assertEqual(list(Book.objects.using('other').filter(authors__name='John Smith').values_list('title', flat=True)), - []) + []) # Create an author through the m2m interface dive.authors.create(name='Jane Brown') self.assertEqual(list(Book.objects.using('other').filter(authors__name='Mark Pilgrim').values_list('title', flat=True)), - []) + []) self.assertEqual(list(Book.objects.using('other').filter(authors__name='Jane Brown').values_list('title', flat=True)), - ['Dive into Python']) + ['Dive into Python']) def test_m2m_reverse_operations(self): "M2M reverse manipulations are all constrained to a single DB" @@ -245,42 +251,42 @@ class QueryTestCase(TestCase): # Add a books to the m2m mark.book_set.add(grease) self.assertEqual(list(Person.objects.using('other').filter(book__title='Dive into Python').values_list('name', flat=True)), - ['Mark Pilgrim']) + ['Mark Pilgrim']) self.assertEqual(list(Person.objects.using('other').filter(book__title='Greasemonkey Hacks').values_list('name', flat=True)), - ['Mark Pilgrim']) + ['Mark Pilgrim']) # Remove a book from the m2m mark.book_set.remove(grease) self.assertEqual(list(Person.objects.using('other').filter(book__title='Dive into Python').values_list('name', flat=True)), - ['Mark Pilgrim']) + ['Mark Pilgrim']) self.assertEqual(list(Person.objects.using('other').filter(book__title='Greasemonkey Hacks').values_list('name', flat=True)), - []) + []) # Clear the books associated with mark mark.book_set.clear() self.assertEqual(list(Person.objects.using('other').filter(book__title='Dive into Python').values_list('name', flat=True)), - []) + []) self.assertEqual(list(Person.objects.using('other').filter(book__title='Greasemonkey Hacks').values_list('name', flat=True)), - []) + []) # Create a book through the m2m interface mark.book_set.create(title="Dive into HTML5", published=datetime.date(2020, 1, 1)) self.assertEqual(list(Person.objects.using('other').filter(book__title='Dive into Python').values_list('name', flat=True)), - []) + []) self.assertEqual(list(Person.objects.using('other').filter(book__title='Dive into HTML5').values_list('name', flat=True)), - ['Mark Pilgrim']) + ['Mark Pilgrim']) def test_m2m_cross_database_protection(self): "Operations that involve sharing M2M objects across databases raise an error" # Create a book and author on the default database pro = Book.objects.create(title="Pro Django", - published=datetime.date(2008, 12, 16)) + published=datetime.date(2008, 12, 16)) marty = Person.objects.create(name="Marty Alchin") # Create a book and author on the other database dive = Book.objects.using('other').create(title="Dive into Python", - published=datetime.date(2009, 5, 4)) + published=datetime.date(2009, 5, 4)) mark = Person.objects.using('other').create(name="Mark Pilgrim") # Set a foreign key set with an object from a different database @@ -407,14 +413,14 @@ class QueryTestCase(TestCase): # Check that queries work across foreign key joins self.assertEqual(list(Person.objects.using('default').filter(edited__title='Pro Django').values_list('name', flat=True)), - ['George Vilches']) + ['George Vilches']) self.assertEqual(list(Person.objects.using('other').filter(edited__title='Pro Django').values_list('name', flat=True)), - []) + []) self.assertEqual(list(Person.objects.using('default').filter(edited__title='Dive into Python').values_list('name', flat=True)), - []) + []) self.assertEqual(list(Person.objects.using('other').filter(edited__title='Dive into Python').values_list('name', flat=True)), - ['Chris Mills']) + ['Chris Mills']) # Reget the objects to clear caches chris = Person.objects.using('other').get(name="Chris Mills") @@ -422,12 +428,12 @@ class QueryTestCase(TestCase): # Retrive related object by descriptor. Related objects should be database-baound self.assertEqual(list(chris.edited.values_list('title', flat=True)), - ['Dive into Python']) + ['Dive into Python']) def test_foreign_key_reverse_operations(self): "FK reverse manipulations are all constrained to a single DB" dive = Book.objects.using('other').create(title="Dive into Python", - published=datetime.date(2009, 5, 4)) + published=datetime.date(2009, 5, 4)) chris = Person.objects.using('other').create(name="Chris Mills") @@ -438,48 +444,48 @@ class QueryTestCase(TestCase): # Add a second book edited by chris html5 = Book.objects.using('other').create(title="Dive into HTML5", published=datetime.date(2010, 3, 15)) self.assertEqual(list(Person.objects.using('other').filter(edited__title='Dive into HTML5').values_list('name', flat=True)), - []) + []) chris.edited.add(html5) self.assertEqual(list(Person.objects.using('other').filter(edited__title='Dive into HTML5').values_list('name', flat=True)), - ['Chris Mills']) + ['Chris Mills']) self.assertEqual(list(Person.objects.using('other').filter(edited__title='Dive into Python').values_list('name', flat=True)), - ['Chris Mills']) + ['Chris Mills']) # Remove the second editor chris.edited.remove(html5) self.assertEqual(list(Person.objects.using('other').filter(edited__title='Dive into HTML5').values_list('name', flat=True)), - []) + []) self.assertEqual(list(Person.objects.using('other').filter(edited__title='Dive into Python').values_list('name', flat=True)), - ['Chris Mills']) + ['Chris Mills']) # Clear all edited books chris.edited.clear() self.assertEqual(list(Person.objects.using('other').filter(edited__title='Dive into HTML5').values_list('name', flat=True)), - []) + []) self.assertEqual(list(Person.objects.using('other').filter(edited__title='Dive into Python').values_list('name', flat=True)), - []) + []) # Create an author through the m2m interface chris.edited.create(title='Dive into Water', published=datetime.date(2010, 3, 15)) self.assertEqual(list(Person.objects.using('other').filter(edited__title='Dive into HTML5').values_list('name', flat=True)), - []) + []) self.assertEqual(list(Person.objects.using('other').filter(edited__title='Dive into Water').values_list('name', flat=True)), - ['Chris Mills']) + ['Chris Mills']) self.assertEqual(list(Person.objects.using('other').filter(edited__title='Dive into Python').values_list('name', flat=True)), - []) + []) def test_foreign_key_cross_database_protection(self): "Operations that involve sharing FK objects across databases raise an error" # Create a book and author on the default database pro = Book.objects.create(title="Pro Django", - published=datetime.date(2008, 12, 16)) + published=datetime.date(2008, 12, 16)) marty = Person.objects.create(name="Marty Alchin") # Create a book and author on the other database dive = Book.objects.using('other').create(title="Dive into Python", - published=datetime.date(2009, 5, 4)) + published=datetime.date(2009, 5, 4)) mark = Person.objects.using('other').create(name="Mark Pilgrim") @@ -523,37 +529,37 @@ class QueryTestCase(TestCase): self.assertEqual(html5._state.db, 'other') # ... but it isn't saved yet self.assertEqual(list(Person.objects.using('other').values_list('name', flat=True)), - ['Mark Pilgrim']) + ['Mark Pilgrim']) self.assertEqual(list(Book.objects.using('other').values_list('title', flat=True)), - ['Dive into Python']) + ['Dive into Python']) # When saved (no using required), new objects goes to 'other' chris.save() html5.save() self.assertEqual(list(Person.objects.using('default').values_list('name', flat=True)), - ['Marty Alchin']) + ['Marty Alchin']) self.assertEqual(list(Person.objects.using('other').values_list('name', flat=True)), - ['Chris Mills', 'Mark Pilgrim']) + ['Chris Mills', 'Mark Pilgrim']) self.assertEqual(list(Book.objects.using('default').values_list('title', flat=True)), - ['Pro Django']) + ['Pro Django']) self.assertEqual(list(Book.objects.using('other').values_list('title', flat=True)), - ['Dive into HTML5', 'Dive into Python']) + ['Dive into HTML5', 'Dive into Python']) # This also works if you assign the FK in the constructor water = Book(title="Dive into Water", published=datetime.date(2001, 1, 1), editor=mark) self.assertEqual(water._state.db, 'other') # ... but it isn't saved yet self.assertEqual(list(Book.objects.using('default').values_list('title', flat=True)), - ['Pro Django']) + ['Pro Django']) self.assertEqual(list(Book.objects.using('other').values_list('title', flat=True)), - ['Dive into HTML5', 'Dive into Python']) + ['Dive into HTML5', 'Dive into Python']) # When saved, the new book goes to 'other' water.save() self.assertEqual(list(Book.objects.using('default').values_list('title', flat=True)), - ['Pro Django']) + ['Pro Django']) self.assertEqual(list(Book.objects.using('other').values_list('title', flat=True)), - ['Dive into HTML5', 'Dive into Python', 'Dive into Water']) + ['Dive into HTML5', 'Dive into Python', 'Dive into Water']) def test_foreign_key_deletion(self): "Cascaded deletions of Foreign Key relations issue queries on the right database" @@ -602,14 +608,14 @@ class QueryTestCase(TestCase): # Check that queries work across joins self.assertEqual(list(User.objects.using('default').filter(userprofile__flavor='chocolate').values_list('username', flat=True)), - ['alice']) + ['alice']) self.assertEqual(list(User.objects.using('other').filter(userprofile__flavor='chocolate').values_list('username', flat=True)), - []) + []) self.assertEqual(list(User.objects.using('default').filter(userprofile__flavor='crunchy frog').values_list('username', flat=True)), - []) + []) self.assertEqual(list(User.objects.using('other').filter(userprofile__flavor='crunchy frog').values_list('username', flat=True)), - ['bob']) + ['bob']) # Reget the objects to clear caches alice_profile = UserProfile.objects.using('default').get(flavor='chocolate') @@ -658,22 +664,22 @@ class QueryTestCase(TestCase): # ... but it isn't saved yet self.assertEqual(list(User.objects.using('other').values_list('username', flat=True)), - ['bob']) + ['bob']) self.assertEqual(list(UserProfile.objects.using('other').values_list('flavor', flat=True)), - ['crunchy frog']) + ['crunchy frog']) # When saved (no using required), new objects goes to 'other' charlie.save() bob_profile.save() new_bob_profile.save() self.assertEqual(list(User.objects.using('default').values_list('username', flat=True)), - ['alice']) + ['alice']) self.assertEqual(list(User.objects.using('other').values_list('username', flat=True)), - ['bob', 'charlie']) + ['bob', 'charlie']) self.assertEqual(list(UserProfile.objects.using('default').values_list('flavor', flat=True)), - ['chocolate']) + ['chocolate']) self.assertEqual(list(UserProfile.objects.using('other').values_list('flavor', flat=True)), - ['crunchy frog', 'spring surprise']) + ['crunchy frog', 'spring surprise']) # This also works if you assign the O2O relation in the constructor denise = User.objects.db_manager('other').create_user('denise', 'denise@example.com') @@ -682,16 +688,16 @@ class QueryTestCase(TestCase): self.assertEqual(denise_profile._state.db, 'other') # ... but it isn't saved yet self.assertEqual(list(UserProfile.objects.using('default').values_list('flavor', flat=True)), - ['chocolate']) + ['chocolate']) self.assertEqual(list(UserProfile.objects.using('other').values_list('flavor', flat=True)), - ['crunchy frog', 'spring surprise']) + ['crunchy frog', 'spring surprise']) # When saved, the new profile goes to 'other' denise_profile.save() self.assertEqual(list(UserProfile.objects.using('default').values_list('flavor', flat=True)), - ['chocolate']) + ['chocolate']) self.assertEqual(list(UserProfile.objects.using('other').values_list('flavor', flat=True)), - ['crunchy frog', 'spring surprise', 'tofu']) + ['crunchy frog', 'spring surprise', 'tofu']) def test_generic_key_separation(self): "Generic fields are constrained to a single database" @@ -718,7 +724,7 @@ class QueryTestCase(TestCase): # Retrive related object by descriptor. Related objects should be database-bound self.assertEqual(list(dive.reviews.all().values_list('source', flat=True)), - ['Python Weekly']) + ['Python Weekly']) def test_generic_key_reverse_operations(self): "Generic reverse manipulations are all constrained to a single DB" @@ -732,37 +738,37 @@ class QueryTestCase(TestCase): review2 = Review.objects.using('other').create(source="Python Monthly", content_object=temp) self.assertEqual(list(Review.objects.using('default').filter(object_id=dive.pk).values_list('source', flat=True)), - []) + []) self.assertEqual(list(Review.objects.using('other').filter(object_id=dive.pk).values_list('source', flat=True)), - ['Python Weekly']) + ['Python Weekly']) # Add a second review dive.reviews.add(review2) self.assertEqual(list(Review.objects.using('default').filter(object_id=dive.pk).values_list('source', flat=True)), - []) + []) self.assertEqual(list(Review.objects.using('other').filter(object_id=dive.pk).values_list('source', flat=True)), - ['Python Monthly', 'Python Weekly']) + ['Python Monthly', 'Python Weekly']) # Remove the second author dive.reviews.remove(review1) self.assertEqual(list(Review.objects.using('default').filter(object_id=dive.pk).values_list('source', flat=True)), - []) + []) self.assertEqual(list(Review.objects.using('other').filter(object_id=dive.pk).values_list('source', flat=True)), - ['Python Monthly']) + ['Python Monthly']) # Clear all reviews dive.reviews.clear() self.assertEqual(list(Review.objects.using('default').filter(object_id=dive.pk).values_list('source', flat=True)), - []) + []) self.assertEqual(list(Review.objects.using('other').filter(object_id=dive.pk).values_list('source', flat=True)), - []) + []) # Create an author through the generic interface dive.reviews.create(source='Python Daily') self.assertEqual(list(Review.objects.using('default').filter(object_id=dive.pk).values_list('source', flat=True)), - []) + []) self.assertEqual(list(Review.objects.using('other').filter(object_id=dive.pk).values_list('source', flat=True)), - ['Python Daily']) + ['Python Daily']) def test_generic_key_cross_database_protection(self): "Operations that involve sharing generic key objects across databases raise an error" @@ -804,16 +810,16 @@ class QueryTestCase(TestCase): self.assertEqual(review3._state.db, 'other') # ... but it isn't saved yet self.assertEqual(list(Review.objects.using('default').filter(object_id=pro.pk).values_list('source', flat=True)), - ['Python Monthly']) + ['Python Monthly']) self.assertEqual(list(Review.objects.using('other').filter(object_id=dive.pk).values_list('source', flat=True)), - ['Python Weekly']) + ['Python Weekly']) # When saved, John goes to 'other' review3.save() self.assertEqual(list(Review.objects.using('default').filter(object_id=pro.pk).values_list('source', flat=True)), - ['Python Monthly']) + ['Python Monthly']) self.assertEqual(list(Review.objects.using('other').filter(object_id=dive.pk).values_list('source', flat=True)), - ['Python Daily', 'Python Weekly']) + ['Python Daily', 'Python Weekly']) def test_generic_key_deletion(self): "Cascaded deletions of Generic Key relations issue queries on the right database" @@ -1354,18 +1360,18 @@ class RouterTestCase(TestCase): def test_generic_key_cross_database_protection(self): "Generic Key operations can span databases if they share a source" # Create a book and author on the default database - pro = Book.objects.using('default' - ).create(title="Pro Django", published=datetime.date(2008, 12, 16)) + pro = Book.objects.using( + 'default').create(title="Pro Django", published=datetime.date(2008, 12, 16)) - review1 = Review.objects.using('default' - ).create(source="Python Monthly", content_object=pro) + review1 = Review.objects.using( + 'default').create(source="Python Monthly", content_object=pro) # Create a book and author on the other database - dive = Book.objects.using('other' - ).create(title="Dive into Python", published=datetime.date(2009, 5, 4)) + dive = Book.objects.using( + 'other').create(title="Dive into Python", published=datetime.date(2009, 5, 4)) - review2 = Review.objects.using('other' - ).create(source="Python Weekly", content_object=dive) + review2 = Review.objects.using( + 'other').create(source="Python Weekly", content_object=dive) # Set a generic foreign key with an object from a different database try: @@ -1565,6 +1571,7 @@ class AuthTestCase(TestCase): command_output = new_io.getvalue().strip() self.assertTrue('"email": "alice@example.com"' in command_output) + class AntiPetRouter(object): # A router that only expresses an opinion on migrate, # passing pets to the 'other' database @@ -1576,6 +1583,7 @@ class AntiPetRouter(object): else: return model._meta.object_name != 'Pet' + class FixtureTestCase(TestCase): multi_db = True fixtures = ['multidb-common', 'multidb'] @@ -1598,7 +1606,8 @@ class FixtureTestCase(TestCase): except Book.DoesNotExist: self.fail('"Pro Django" should exist on default database') - self.assertRaises(Book.DoesNotExist, + self.assertRaises( + Book.DoesNotExist, Book.objects.using('other').get, title="Pro Django" ) @@ -1609,11 +1618,13 @@ class FixtureTestCase(TestCase): except Book.DoesNotExist: self.fail('"Dive into Python" should exist on other database') - self.assertRaises(Book.DoesNotExist, + self.assertRaises( + Book.DoesNotExist, Book.objects.get, title="Dive into Python" ) - self.assertRaises(Book.DoesNotExist, + self.assertRaises( + Book.DoesNotExist, Book.objects.using('default').get, title="Dive into Python" ) @@ -1634,6 +1645,7 @@ class FixtureTestCase(TestCase): # No objects will actually be loaded self.assertEqual(command_output, "Installed 0 object(s) (of 2) from 1 fixture(s)") + class PickleQuerySetTestCase(TestCase): multi_db = True @@ -1651,6 +1663,7 @@ class DatabaseReceiver(object): def __call__(self, signal, sender, **kwargs): self._database = kwargs['using'] + class WriteToOtherRouter(object): """ A router that sends all writes to the other database. @@ -1658,6 +1671,7 @@ class WriteToOtherRouter(object): def db_for_write(self, model, **hints): return "other" + class SignalTests(TestCase): multi_db = True @@ -1765,6 +1779,7 @@ class SignalTests(TestCase): self._write_to_default() self.assertEqual(receiver._database, "other") + class AttributeErrorRouter(object): "A router to test the exception handling of ConnectionRouter" def db_for_read(self, model, **hints): @@ -1773,6 +1788,7 @@ class AttributeErrorRouter(object): def db_for_write(self, model, **hints): raise AttributeError + class RouterAttributeErrorTestCase(TestCase): multi_db = True @@ -1818,12 +1834,14 @@ class RouterAttributeErrorTestCase(TestCase): router.routers = [AttributeErrorRouter()] # Install our router self.assertRaises(AttributeError, setattr, b, 'authors', [p]) + class ModelMetaRouter(object): "A router to ensure model arguments are real model classes" def db_for_write(self, model, **hints): if not hasattr(model, '_meta'): raise ValueError + class RouterModelArgumentTestCase(TestCase): multi_db = True |
