(self)
| 3841 | |
| 3842 | class 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 | |
| 3875 | class ORMOnlyPrimaryKeyTest(fixtures.TestBase): |
nothing calls this directly
no test coverage detected