diff options
| author | Alex Cucu <alexandruioan.cucu@gmail.com> | 2013-02-26 11:51:56 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2013-08-06 09:50:59 -0400 |
| commit | 1c64a0f29e47a3da1dfac06b04ef84280bd809a7 (patch) | |
| tree | bd8ed1e2f5e30e68b3e1a7a3fa61bbf62b23e347 /tests/select_for_update | |
| parent | 12806758347dfd63a3cd1bfc0d925c09fdbd9cff (diff) | |
Fixed #19918 -- Modified select_for_update to run on the write database.
Diffstat (limited to 'tests/select_for_update')
| -rw-r--r-- | tests/select_for_update/tests.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/select_for_update/tests.py b/tests/select_for_update/tests.py index 3bd35448b1..f9e7e96ac1 100644 --- a/tests/select_for_update/tests.py +++ b/tests/select_for_update/tests.py @@ -5,11 +5,13 @@ import time import unittest from django.conf import settings -from django.db import transaction, connection +from django.db import transaction, connection, router from django.db.utils import ConnectionHandler, DEFAULT_DB_ALIAS, DatabaseError from django.test import (TransactionTestCase, skipIfDBFeature, skipUnlessDBFeature) +from multiple_database.tests import TestRouter + from .models import Person # Some tests require threading, which might not be available. So create a @@ -254,3 +256,13 @@ class SelectForUpdateTests(TransactionTestCase): """ people = list(Person.objects.select_for_update()) self.assertTrue(transaction.is_dirty()) + + @skipUnlessDBFeature('has_select_for_update') + def test_select_for_update_on_multidb(self): + old_routers = router.routers + try: + router.routers = [TestRouter()] + query = Person.objects.select_for_update() + self.assertEqual(router.db_for_write(Person), query.db) + finally: + router.routers = old_routers |
