MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / test_ensure_cache

Method test_ensure_cache

test/orm/test_unitofworkv2.py:3843–3872  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3841
3842class EnsureCacheTest(UOWTest):
3843 def test_ensure_cache(self):
3844 users, User = self.tables.users, self.classes.User
3845
3846 self.mapper_registry.map_imperatively(User, users)
3847
3848 cache = {}
3849 eq_(len(inspect(User)._compiled_cache), 0)
3850
3851 with testing.db.connect().execution_options(
3852 compiled_cache=cache
3853 ) as conn:
3854 s = Session(conn)
3855 u1 = User(name="adf")
3856 s.add(u1)
3857 s.flush()
3858
3859 is_(conn._execution_options["compiled_cache"], cache)
3860 eq_(len(inspect(User)._compiled_cache), 1)
3861
3862 u1.name = "newname"
3863 s.flush()
3864
3865 is_(conn._execution_options["compiled_cache"], cache)
3866 eq_(len(inspect(User)._compiled_cache), 2)
3867
3868 s.delete(u1)
3869 s.flush()
3870
3871 is_(conn._execution_options["compiled_cache"], cache)
3872 eq_(len(inspect(User)._compiled_cache), 3)
3873
3874
3875class ORMOnlyPrimaryKeyTest(fixtures.TestBase):

Callers

nothing calls this directly

Calls 11

addMethod · 0.95
flushMethod · 0.95
deleteMethod · 0.95
eq_Function · 0.90
inspectFunction · 0.90
SessionClass · 0.90
is_Function · 0.90
map_imperativelyMethod · 0.80
UserClass · 0.70
execution_optionsMethod · 0.45
connectMethod · 0.45

Tested by

no test coverage detected