summaryrefslogtreecommitdiff
path: root/test/orm/test_inspect.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/orm/test_inspect.py')
-rw-r--r--test/orm/test_inspect.py48
1 files changed, 45 insertions, 3 deletions
diff --git a/test/orm/test_inspect.py b/test/orm/test_inspect.py
index 61c1fd93e..5f5457943 100644
--- a/test/orm/test_inspect.py
+++ b/test/orm/test_inspect.py
@@ -130,8 +130,8 @@ class TestORMInspection(_fixtures.FixtureTest):
User = self.classes.User
insp = inspect(User)
eq_(
- set(insp.attrs.keys()),
- set(['addresses', 'orders', 'id', 'name', 'name_syn'])
+ list(insp.attrs.keys()),
+ ['addresses', 'orders', 'id', 'name', 'name_syn']
)
def test_col_filter(self):
@@ -365,7 +365,7 @@ class TestORMInspection(_fixtures.FixtureTest):
[]
)
- def test_instance_state_attr_hist(self):
+ def test_instance_state_collection_attr_hist(self):
User = self.classes.User
u1 = User(name='ed')
insp = inspect(u1)
@@ -379,6 +379,48 @@ class TestORMInspection(_fixtures.FixtureTest):
hist.unchanged, []
)
+ def test_instance_state_scalar_attr_hist(self):
+ User = self.classes.User
+ u1 = User(name='ed')
+ sess = Session()
+ sess.add(u1)
+ sess.commit()
+ assert 'name' not in u1.__dict__
+ insp = inspect(u1)
+ hist = insp.attrs.name.history
+ eq_(
+ hist.unchanged, None
+ )
+ assert 'name' not in u1.__dict__
+
+ def test_instance_state_collection_attr_load_hist(self):
+ User = self.classes.User
+ u1 = User(name='ed')
+ insp = inspect(u1)
+ hist = insp.attrs.addresses.load_history()
+ eq_(
+ hist.unchanged, ()
+ )
+ u1.addresses
+ hist = insp.attrs.addresses.load_history()
+ eq_(
+ hist.unchanged, []
+ )
+
+ def test_instance_state_scalar_attr_hist_load(self):
+ User = self.classes.User
+ u1 = User(name='ed')
+ sess = Session()
+ sess.add(u1)
+ sess.commit()
+ assert 'name' not in u1.__dict__
+ insp = inspect(u1)
+ hist = insp.attrs.name.load_history()
+ eq_(
+ hist.unchanged, ['ed']
+ )
+ assert 'name' in u1.__dict__
+
def test_instance_state_ident_transient(self):
User = self.classes.User
u1 = User(name='ed')