@@ -188,24 +188,14 @@ async def test_refresh_sends_op_list(q10_api: Q10PropertiesApi, fake_channel: Fa
188188 )
189189
190190
191- async def test_refresh_detail_publishes_without_waiting_for_push (
191+ async def test_refresh_detail_sends_op_select (
192192 clean_history : CleanHistoryTrait ,
193193 fake_channel : FakeB01Q10Channel ,
194194) -> None :
195195 record = CleanRecordConverter .parse_record (RECORD_A )
196196 assert record is not None
197- updates = []
198- clean_history .add_update_listener (lambda : updates .append (clean_history .detail ))
199197 await clean_history .refresh_detail (record )
200198 assert fake_channel .published_commands == [(B01_Q10_DP .COMMON , {"52" : {"op" : "select" , "id" : RECORD_A }})]
201- assert clean_history .detail is None
202- assert updates == []
203- detail = _detail ()
204- clean_history .update_from_detail (detail )
205- assert clean_history .detail is detail
206- assert clean_history .detail_packet is detail .map
207- assert clean_history .detail_image_content is not None
208- assert updates == [detail ]
209199
210200
211201def _detail () -> Q10CleanRecordDetail :
@@ -220,68 +210,39 @@ async def test_refresh_detail_rejects_record_without_map(clean_history: CleanHis
220210 await clean_history .refresh_detail (record )
221211
222212
223- async def test_missing_push_does_not_block_further_selections (
224- clean_history : CleanHistoryTrait ,
225- fake_channel : FakeB01Q10Channel ,
226- ) -> None :
227- first = CleanRecordConverter .parse_record (RECORD_A )
228- second = CleanRecordConverter .parse_record (RECORD_B )
229- assert first is not None and second is not None
230- await clean_history .refresh_detail (first )
231- await clean_history .refresh_detail (second )
232- assert [params ["52" ]["id" ] for _ , params in fake_channel .published_commands ] == [RECORD_A , RECORD_B ]
233- detail = _detail ()
234- clean_history .update_from_detail (detail )
235- assert clean_history .detail is detail
236- # The received payload has no record identifier; no association is invented.
237- assert "detailRecord" not in clean_history .as_dict ()
238-
239-
240- @pytest .mark .parametrize ("failure" , ["cancel" , "send_error" ])
241- async def test_failed_publication_releases_lock (
213+ async def test_refresh_detail_after_cancelled_publication (
242214 clean_history : CleanHistoryTrait ,
243215 fake_channel : FakeB01Q10Channel ,
244- failure : str ,
245216) -> None :
246217 record = CleanRecordConverter .parse_record (RECORD_A )
247218 assert record is not None
248- if failure == "cancel" :
249- fake_channel .send_gate = asyncio .Event ()
250- else :
251- fake_channel .send_error = RoborockException ("publish failed" )
219+ fake_channel .send_gate = asyncio .Event ()
252220 request = asyncio .create_task (clean_history .refresh_detail (record ))
253221 await fake_channel .send_started .wait ()
254- if failure == "cancel" :
255- request .cancel ()
256- with pytest .raises (asyncio .CancelledError if failure == "cancel" else RoborockException ):
222+ request .cancel ()
223+ with pytest .raises (asyncio .CancelledError ):
257224 await request
225+ assert fake_channel .published_commands == []
226+
258227 fake_channel .send_gate = None
259- fake_channel .send_error = None
260228 await clean_history .refresh_detail (record )
261- assert len (fake_channel .published_commands ) == 1
262- clean_history .update_from_detail (_detail ())
263- assert clean_history .detail_image_content is not None
229+ assert fake_channel .published_commands == [(B01_Q10_DP .COMMON , {"52" : {"op" : "select" , "id" : RECORD_A }})]
264230
265231
266- async def test_concurrent_selections_serialize_publication (
232+ async def test_refresh_detail_after_publication_error (
267233 clean_history : CleanHistoryTrait ,
268234 fake_channel : FakeB01Q10Channel ,
269235) -> None :
270- first = CleanRecordConverter .parse_record (RECORD_A )
271- second = CleanRecordConverter .parse_record (RECORD_B )
272- assert first is not None and second is not None
273- gate = asyncio .Event ()
274- fake_channel .send_gate = gate
275- first_request = asyncio .create_task (clean_history .refresh_detail (first ))
276- await fake_channel .send_started .wait ()
277- fake_channel .send_started .clear ()
278- second_request = asyncio .create_task (clean_history .refresh_detail (second ))
279- await asyncio .sleep (0 )
280- assert not fake_channel .send_started .is_set ()
281- assert not second_request .done ()
282- gate .set ()
283- await asyncio .gather (first_request , second_request )
284- assert [params ["52" ]["id" ] for _ , params in fake_channel .published_commands ] == [RECORD_A , RECORD_B ]
236+ record = CleanRecordConverter .parse_record (RECORD_A )
237+ assert record is not None
238+ fake_channel .send_error = RoborockException ("publish failed" )
239+ with pytest .raises (RoborockException , match = "publish failed" ):
240+ await clean_history .refresh_detail (record )
241+ assert fake_channel .published_commands == []
242+
243+ fake_channel .send_error = None
244+ await clean_history .refresh_detail (record )
245+ assert fake_channel .published_commands == [(B01_Q10_DP .COMMON , {"52" : {"op" : "select" , "id" : RECORD_A }})]
285246
286247
287248def test_received_detail_is_serializable_and_path_list_is_defensive (q10_api : Q10PropertiesApi ) -> None :
0 commit comments