14
14
ErrorFrame ,
15
15
FailedAllConnectAttemptsError ,
16
16
FailedAllWriteAttemptsError ,
17
+ Heartbeat ,
17
18
MessageFrame ,
18
19
)
20
+ from stompman .connection_lifespan import EstablishedConnectionResult
19
21
from stompman .connection_manager import ActiveConnectionState
20
22
21
- from test_stompman .conftest import BaseMockConnection , EnrichedConnectionManager , NoopLifespan , build_dataclass
23
+ from test_stompman .conftest import BaseMockConnection , EnrichedConnectionManager , build_dataclass
22
24
23
25
pytestmark = [pytest .mark .anyio , pytest .mark .usefixtures ("mock_sleep" )]
24
26
@@ -110,8 +112,7 @@ async def connect(
110
112
)
111
113
active_connection_state = await manager ._create_connection_to_any_server ()
112
114
assert active_connection_state
113
- assert isinstance (active_connection_state .lifespan , NoopLifespan )
114
- assert active_connection_state .lifespan .connection_parameters == successful_server
115
+ assert active_connection_state [1 ] == successful_server
115
116
116
117
117
118
async def test_connect_to_any_server_fails () -> None :
@@ -169,7 +170,8 @@ class MockConnection(BaseMockConnection):
169
170
170
171
171
172
async def test_get_active_connection_state_ok_concurrent () -> None :
172
- enter = mock .AsyncMock (return_value = None )
173
+ server_heartbeat = build_dataclass (Heartbeat )
174
+ enter = mock .AsyncMock (return_value = EstablishedConnectionResult (server_heartbeat = server_heartbeat ))
173
175
lifespan_factory = mock .Mock (return_value = mock .Mock (enter = enter ))
174
176
manager = EnrichedConnectionManager (lifespan_factory = lifespan_factory , connection_class = BaseMockConnection )
175
177
@@ -185,7 +187,9 @@ async def test_get_active_connection_state_ok_concurrent() -> None:
185
187
== second_state
186
188
== third_state
187
189
== fourth_state
188
- == ActiveConnectionState (connection = BaseMockConnection (), lifespan = lifespan_factory .return_value )
190
+ == ActiveConnectionState (
191
+ connection = BaseMockConnection (), lifespan = lifespan_factory .return_value , server_heartbeat = server_heartbeat
192
+ )
189
193
)
190
194
assert first_state is second_state is third_state is fourth_state
191
195
0 commit comments