MCPcopy Index your code
hub / github.com/sqlalchemy/sqlalchemy / test_history_get

Method test_history_get

test/orm/test_unitofwork.py:2158–2201  ·  view source on GitHub ↗

The history lazy-fetches data when it wasn't otherwise loaded.

(self)

Source from the content-addressed store, hash-verified

2156 assert u.name == "imnew"
2157
2158 def test_history_get(self):
2159 """The history lazy-fetches data when it wasn't otherwise loaded."""
2160
2161 users, Address, addresses, User = (
2162 self.tables.users,
2163 self.classes.Address,
2164 self.tables.addresses,
2165 self.classes.User,
2166 )
2167
2168 self.mapper_registry.map_imperatively(
2169 User,
2170 users,
2171 properties={
2172 "addresses": relationship(
2173 Address, cascade="all, delete-orphan"
2174 )
2175 },
2176 )
2177 self.mapper_registry.map_imperatively(Address, addresses)
2178
2179 u = User(name="u1")
2180 u.addresses.append(Address(email_address="u1@e1"))
2181 u.addresses.append(Address(email_address="u1@e2"))
2182 session = fixture_session()
2183 session.add(u)
2184 session.flush()
2185 session.expunge_all()
2186
2187 u = session.get(User, u.id)
2188 session.delete(u)
2189 session.flush()
2190 eq_(
2191 session.connection().scalar(
2192 select(func.count("*")).select_from(users)
2193 ),
2194 0,
2195 )
2196 eq_(
2197 session.connection().scalar(
2198 select(func.count("*")).select_from(addresses)
2199 ),
2200 0,
2201 )
2202
2203 def test_batch_mode(self):
2204 """The 'batch=False' flag on mapper()"""

Callers

nothing calls this directly

Calls 15

relationshipFunction · 0.90
fixture_sessionFunction · 0.90
eq_Function · 0.90
selectFunction · 0.90
map_imperativelyMethod · 0.80
UserClass · 0.70
AddressClass · 0.70
appendMethod · 0.45
addMethod · 0.45
flushMethod · 0.45
expunge_allMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected