MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_ensure_cache

Method test_ensure_cache

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

Source from the content-addressed store, hash-verified

3826
3827class EnsureCacheTest(UOWTest):
3828 def test_ensure_cache(self):
3829 users, User = self.tables.users, self.classes.User
3830
3831 self.mapper_registry.map_imperatively(User, users)
3832
3833 cache = {}
3834 eq_(len(inspect(User)._compiled_cache), 0)
3835
3836 with testing.db.connect().execution_options(
3837 compiled_cache=cache
3838 ) as conn:
3839 s = Session(conn)
3840 u1 = User(name="adf")
3841 s.add(u1)
3842 s.flush()
3843
3844 is_(conn._execution_options["compiled_cache"], cache)
3845 eq_(len(inspect(User)._compiled_cache), 1)
3846
3847 u1.name = "newname"
3848 s.flush()
3849
3850 is_(conn._execution_options["compiled_cache"], cache)
3851 eq_(len(inspect(User)._compiled_cache), 2)
3852
3853 s.delete(u1)
3854 s.flush()
3855
3856 is_(conn._execution_options["compiled_cache"], cache)
3857 eq_(len(inspect(User)._compiled_cache), 3)
3858
3859
3860class 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