summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarten Kenbeek <marten.knbk@gmail.com>2015-04-06 18:02:46 +0200
committerTim Graham <timograham@gmail.com>2015-04-20 14:42:23 -0400
commit039d7881b441c6b358a963d652ffa2eada3a8892 (patch)
tree5ae39821c0bff00dce3e74f1fb4d14e819ba9fdd /tests
parent6387d9d41fa9c4292a010bdae16feb349cb3c94a (diff)
Refs #24397 -- Sped up model reloading in ProjectState.
Created bulk_update() context manager on StateApps. Sped up unregistering models in reload_models() by using this context mananger.
Diffstat (limited to 'tests')
-rw-r--r--tests/migrations/test_state.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/migrations/test_state.py b/tests/migrations/test_state.py
index 530ca60c6f..551ca11459 100644
--- a/tests/migrations/test_state.py
+++ b/tests/migrations/test_state.py
@@ -160,6 +160,22 @@ class StateTests(TestCase):
self.assertEqual([mgr.args for name, mgr in food_order_manager_state.managers],
[('a', 'b', 1, 2), ('x', 'y', 3, 4)])
+ def test_apps_bulk_update(self):
+ """
+ StateApps.bulk_update() should update apps.ready to False and reset
+ the value afterwards.
+ """
+ project_state = ProjectState()
+ apps = project_state.apps
+ with apps.bulk_update():
+ self.assertFalse(apps.ready)
+ self.assertTrue(apps.ready)
+ with self.assertRaises(ValueError):
+ with apps.bulk_update():
+ self.assertFalse(apps.ready)
+ raise ValueError()
+ self.assertTrue(apps.ready)
+
def test_render(self):
"""
Tests rendering a ProjectState into an Apps.