Fixed isolation of RouterTestCase.test_m2m_cross_database_protection().
Hardcoded pks are necessary for this test case, however we need to set them for all new rows because the sequence will not increment automatically. It works when the sequence is incremented by other test cases.
This commit is contained in:
parent
edde2a0699
commit
49ca6bbc44
|
@ -1344,14 +1344,14 @@ class RouterTestCase(TestCase):
|
||||||
# If you create an object through a M2M relation, it will be
|
# If you create an object through a M2M relation, it will be
|
||||||
# written to the write database, even if the original object
|
# written to the write database, even if the original object
|
||||||
# was on the read database
|
# was on the read database
|
||||||
alice = dive.authors.create(name='Alice')
|
alice = dive.authors.create(name='Alice', pk=3)
|
||||||
self.assertEqual(alice._state.db, 'default')
|
self.assertEqual(alice._state.db, 'default')
|
||||||
|
|
||||||
# Same goes for get_or_create, regardless of whether getting or creating
|
# Same goes for get_or_create, regardless of whether getting or creating
|
||||||
alice, created = dive.authors.get_or_create(name='Alice')
|
alice, created = dive.authors.get_or_create(name='Alice')
|
||||||
self.assertEqual(alice._state.db, 'default')
|
self.assertEqual(alice._state.db, 'default')
|
||||||
|
|
||||||
bob, created = dive.authors.get_or_create(name='Bob')
|
bob, created = dive.authors.get_or_create(name='Bob', defaults={'pk': 4})
|
||||||
self.assertEqual(bob._state.db, 'default')
|
self.assertEqual(bob._state.db, 'default')
|
||||||
|
|
||||||
def test_o2o_cross_database_protection(self):
|
def test_o2o_cross_database_protection(self):
|
||||||
|
|
Loading…
Reference in New Issue