summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEugeniya Kudryashova <ekudryashova@mirantis.com>2014-07-11 15:38:23 +0300
committerEugeniya Kudryashova <ekudryashova@mirantis.com>2014-07-11 18:22:01 +0300
commit817fd44675d981a12c7126d065661b99f9fc2884 (patch)
treebf9a9cd65dd8d8dadd4b8d9fafcbc762c42bf98f /tests
parentf4074f7086033fb2cc7a76337851ee4043eb0913 (diff)
downloadoslo-db-817fd44675d981a12c7126d065661b99f9fc2884.tar.gz
Allow usage of several iterators on ModelBase
Storing iterator object as attribute of model doesn't allow to use several iterators at the same time Now the new Iterator object which is created by iter() stores model object, and in such way several iterators can be created and work without interfering Change-Id: I5806877a2d15d449b948307a522bf2fb56bf8110
Diffstat (limited to 'tests')
-rw-r--r--tests/sqlalchemy/test_models.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/sqlalchemy/test_models.py b/tests/sqlalchemy/test_models.py
index ea15532..fe5d2f0 100644
--- a/tests/sqlalchemy/test_models.py
+++ b/tests/sqlalchemy/test_models.py
@@ -89,6 +89,15 @@ class ModelBaseTest(test_base.DbTestCase):
self.assertEqual(min_items, found_items)
+ def test_modelbase_several_iters(self):
+ mb = ExtraKeysModel()
+ it1 = iter(mb)
+ it2 = iter(mb)
+
+ self.assertFalse(it1 is it2)
+ self.assertEqual(dict(it1), dict(mb))
+ self.assertEqual(dict(it2), dict(mb))
+
def test_extra_keys_empty(self):
"""Test verifies that by default extra_keys return empty list."""
mb = models.ModelBase()