Skip to content

Commit 06270b3

Browse files
committed
remove simulated pre-hydrated states
1 parent 465e6d0 commit 06270b3

2 files changed

Lines changed: 3 additions & 23 deletions

File tree

tests/units/test_app.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,9 +1771,6 @@ async def test_dynamic_route_var_route_change_completed_on_load(
17711771
assert constants.ROUTER in app._state()._var_dependencies
17721772

17731773
substate_token = BaseStateToken(ident=token, cls=DynamicState)
1774-
async with app.state_manager.modify_state(substate_token) as state:
1775-
state.router_data = {"simulate": "hydrated"}
1776-
assert state.dynamic == "" # pyright: ignore[reportAttributeAccessIssue]
17771774
exp_vals = ["foo", "foobar", "baz"]
17781775

17791776
def _event(name, val, **kwargs):
@@ -1915,10 +1912,6 @@ async def test_process_events(
19151912
payload={"c": 5},
19161913
router_data={},
19171914
)
1918-
async with mock_root_event_context.state_manager.modify_state(
1919-
BaseStateToken(ident=token, cls=GenState),
1920-
) as state:
1921-
state.router_data = {"simulate": "hydrated"}
19221915

19231916
async with mock_base_state_event_processor as processor:
19241917
await processor.enqueue(

tests/units/test_state.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,10 +2242,6 @@ class BackgroundTaskState(BaseState):
22422242
dict_list: dict[str, list[int]] = {"foo": [1, 2, 3]}
22432243
dc: ModelDC = ModelDC()
22442244

2245-
def __init__(self, **kwargs): # noqa: D107
2246-
super().__init__(**kwargs)
2247-
self.router_data = {"simulate": "hydrate"}
2248-
22492245
@rx.var(cache=False)
22502246
def computed_order(self) -> list[str]:
22512247
"""Get the order as a computed var.
@@ -2909,7 +2905,7 @@ class BaseFieldSetterState(BaseState):
29092905
assert "c2" in bfss.dirty_vars
29102906

29112907

2912-
def exp_is_hydrated(state: BaseState, is_hydrated: bool = True) -> dict[str, Any]:
2908+
def exp_is_hydrated(state: type[BaseState], is_hydrated: bool = True) -> dict[str, Any]:
29132909
"""Expected IS_HYDRATED delta that would be emitted by HydrateMiddleware.
29142910
29152911
Args:
@@ -3006,11 +3002,6 @@ def index():
30063002
app.add_page(index, on_load=test_state.test_handler)
30073003
app._compile_page("index")
30083004

3009-
async with mock_root_event_context.state_manager.modify_state(
3010-
BaseStateToken(ident=token, cls=State)
3011-
) as state:
3012-
state.router_data = {"simulate": "hydrate"}
3013-
30143005
on_load_internal_name = format.format_event_handler(
30153006
OnLoadInternalState.on_load_internal # pyright: ignore[reportArgumentType]
30163007
)
@@ -3035,7 +3026,7 @@ def index():
30353026
assert len(emitted_deltas) >= 2
30363027
first_delta = emitted_deltas[0][1]
30373028
assert first_delta[State.get_full_name()].pop("router" + FIELD_MARKER) is not None
3038-
assert first_delta == exp_is_hydrated(state, False)
3029+
assert first_delta == exp_is_hydrated(State, False)
30393030

30403031
# Find the delta containing the test handler's state change
30413032
handler_deltas = [
@@ -3085,10 +3076,6 @@ def index():
30853076

30863077
app.add_page(index, on_load=[OnLoadState.test_handler, OnLoadState.test_handler])
30873078
app._compile_page("index")
3088-
async with mock_root_event_context.state_manager.modify_state(
3089-
BaseStateToken(ident=token, cls=State)
3090-
) as state:
3091-
state.router_data = {"simulate": "hydrate"}
30923079

30933080
on_load_internal_name = format.format_event_handler(
30943081
OnLoadInternalState.on_load_internal # pyright: ignore[reportArgumentType]
@@ -3112,7 +3099,7 @@ def index():
31123099
assert len(emitted_deltas) >= 2
31133100
first_delta = emitted_deltas[0][1]
31143101
assert first_delta[State.get_full_name()].pop("router" + FIELD_MARKER) is not None
3115-
assert first_delta == exp_is_hydrated(state, False)
3102+
assert first_delta == exp_is_hydrated(State, False)
31163103

31173104
# Find deltas containing the test handler's state change (num incremented twice)
31183105
handler_deltas = [

0 commit comments

Comments
 (0)