Test that a state can be deserialized from disk with a grandchild state. Args: token: A token.
(token)
| 4302 | |
| 4303 | @pytest.mark.asyncio |
| 4304 | async def test_deserialize_gc_state_disk(token): |
| 4305 | """Test that a state can be deserialized from disk with a grandchild state. |
| 4306 | |
| 4307 | Args: |
| 4308 | token: A token. |
| 4309 | """ |
| 4310 | |
| 4311 | class Root(BaseState): |
| 4312 | pass |
| 4313 | |
| 4314 | class State(Root): |
| 4315 | num: int = 42 |
| 4316 | |
| 4317 | class Child(State): |
| 4318 | foo: str = "bar" |
| 4319 | |
| 4320 | bs_token = BaseStateToken(ident=token, cls=Root) |
| 4321 | |
| 4322 | dsm = StateManagerDisk() |
| 4323 | async with dsm.modify_state(bs_token) as root: |
| 4324 | s = await root.get_state(State) |
| 4325 | s.num += 1 |
| 4326 | c = await root.get_state(Child) |
| 4327 | assert s._get_was_touched() |
| 4328 | assert not c._get_was_touched() |
| 4329 | await dsm.close() |
| 4330 | |
| 4331 | dsm2 = StateManagerDisk() |
| 4332 | root = await dsm2.get_state(bs_token) |
| 4333 | s = await root.get_state(State) |
| 4334 | assert s.num == 43 |
| 4335 | c = await root.get_state(Child) |
| 4336 | assert c.foo == "bar" |
| 4337 | await dsm2.close() |
| 4338 | |
| 4339 | |
| 4340 | class Obj(Base): |
nothing calls this directly
no test coverage detected