Skip to content

Commit 040042f

Browse files
committed
fix: stop DRY
no need for 2 handlers, decrease complexity the only difference is an emitted event that is not listened too anywhere
1 parent e2a1b08 commit 040042f

File tree

1 file changed

+29
-45
lines changed

1 file changed

+29
-45
lines changed

test/end2end/session/test_stop.py

Lines changed: 29 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -67,22 +67,12 @@ def wait_for_n_messages(n):
6767
"recognizer_loop:utterance",
6868
# global stop trigger
6969
"mycroft.stop",
70-
# intent pipelines
71-
"common_query.openvoiceos.stop",
72-
"common_query.openvoiceos.stop.response", # reporting nothing to stop
73-
"ovos.common_play.stop",
74-
"ovos.common_play.stop.response", # reporting nothing to stop
75-
76-
# skill reporting
77-
f"{self.skill_id}.stop", # internal, @killable_events
78-
f"{self.skill_id}.stop.response", # skill reporting nothing to stop
79-
70+
"common_query.openvoiceos.stop.response",
71+
"ovos.common_play.stop.response",
72+
f"{self.skill_id}.stop.response",
8073
# sanity check in test skill that method was indeed called
8174
"speak", # "utterance":"old stop called"
82-
83-
# NOTE: messages below might show up before enclosure.active_skill
84-
f"{self.new_skill_id}.stop", # internal, @killable_events
85-
f"{self.new_skill_id}.stop.response", # skill reporting nothing to stop
75+
f"{self.new_skill_id}.stop.response", # nothing to stop
8676

8777
"ovos.utterance.handled"
8878
]
@@ -151,30 +141,17 @@ def wait_for_n_messages(n):
151141
f"{self.skill_id}.stop.ping", # check if active skill wants to stop
152142
"skill.stop.pong", # "can_handle":true
153143
f"{self.skill_id}.stop", # skill specific stop trigger
154-
f"{self.skill_id}.stop.response", # skill fails to stop (old style)
144+
"speak", # "old stop called" in the test skill stop method
145+
f"{self.skill_id}.stop.response", # skill stops and reports back
155146

156-
# stop medium
157-
f"{self.skill_id}.stop.ping",
158-
"skill.stop.pong",
159-
f"{self.skill_id}.stop", # skill specific stop trigger
160-
f"{self.skill_id}.stop.response", # skill fails to stop (old style)
147+
# skill reports it stopped, so core ensures any threaded activity is also killed
148+
"mycroft.skills.abort_question", # core kills any ongoing get_response
149+
"ovos.skills.converse.force_timeout", # core kills any ongoing converse
150+
"mycroft.audio.speech.stop", # core kills any ongoing TTS
161151

162-
# stop fallback
163-
"mycroft.stop", # global stop for backwards compat
164-
f"{self.skill_id}.stop",
165-
f"{self.skill_id}.stop.response", # apparently fails to stop (old style)
166-
167-
# test in skill that global stop was called
168-
"speak", # "utterance":"stop"
169-
170-
# report old-style stop handled event
171-
"mycroft.stop.handled", # {"by":"skill:skill-old-stop.openvoiceos"}
152+
f"{self.skill_id}.activate", # update of skill last usage timestamp
153+
"ovos.utterance.handled"
172154

173-
# old style unwanted side effects (global stop is global)
174-
f"{self.new_skill_id}.stop",
175-
f"{self.new_skill_id}.stop.response",
176-
# other test skill also speaks
177-
"speak" # "utterance":"old stop called"
178155
]
179156

180157
wait_for_n_messages(len(expected_messages))
@@ -246,14 +223,15 @@ def wait_for_n_messages(n):
246223
"recognizer_loop:utterance",
247224
# global stop trigger
248225
"mycroft.stop",
249-
f"{self.skill_id}.stop", # internal, @killable_events
226+
"common_query.openvoiceos.stop.response", # common_query framework reporting nothing to stop
227+
"ovos.common_play.stop.response", # OCP framework reporting nothing to stop
250228
f"{self.skill_id}.stop.response", # skill reporting nothing to stop
251-
f"{self.new_skill_id}.stop", # internal, @killable_events
252-
f"{self.new_skill_id}.stop.response", # skill reporting nothing to stop
253229

254230
# sanity check in test skill that method was indeed called
255231
"speak", # "utterance":"old stop called"
256232

233+
f"{self.new_skill_id}.stop.response", # skill reporting it stopped
234+
257235
"ovos.utterance.handled",
258236

259237
]
@@ -331,8 +309,11 @@ def wait_for_n_messages(n):
331309

332310
# test session specific stop was called
333311
"speak", # "utterance":"stop 123"
334-
335312
f"{self.new_skill_id}.stop.response", # skill reports it stopped (new style),
313+
314+
"mycroft.skills.abort_question", # core kills any ongoing get_response
315+
"ovos.skills.converse.force_timeout", # core kills any ongoing converse
316+
"mycroft.audio.speech.stop", # core kills any ongoing TTS
336317
f"{self.new_skill_id}.activate", # update timestamp of last interaction with skill
337318
"ovos.utterance.handled" # handle_utterance returned (intent service)
338319
]
@@ -350,7 +331,7 @@ def wait_for_n_messages(n):
350331
self.assertEqual(m.data["utterance"], "stop 123")
351332

352333
# confirm "skill-new-stop" was the one that reported success
353-
handler = messages[-3]
334+
handler = messages[-6]
354335
self.assertEqual(handler.msg_type, f"{self.new_skill_id}.stop.response")
355336
self.assertEqual(handler.data["result"], True)
356337

@@ -373,24 +354,27 @@ def wait_for_n_messages(n):
373354
f"{self.new_skill_id}.stop.ping", # check if active skill wants to stop
374355
"skill.stop.pong", # "can_handle":true
375356
f"{self.new_skill_id}.stop", # skill specific stop trigger
357+
"speak", # it's in the stop method even if it returns False!
376358
f"{self.new_skill_id}.stop.response", # dont want to stop (new style)
377359

378360
# rest of pipeline
379361
# stop low
380362
f"{self.new_skill_id}.stop.ping",
381363
"skill.stop.pong",
382364
f"{self.new_skill_id}.stop", # skill specific stop trigger
365+
"speak", # it's in the stop method even if it returns False!
383366
f"{self.new_skill_id}.stop.response", # dont want to stop (new style)
384367

385368
# global stop fallback
386369
"mycroft.stop",
387-
f"{self.skill_id}.stop", # skill specific stop trigger
370+
"common_query.openvoiceos.stop.response", # dont want to stop
371+
"ovos.common_play.stop.response", # dont want to stop
372+
388373
f"{self.skill_id}.stop.response", # old style, never stops
389-
f"{self.new_skill_id}.stop", # skill specific stop trigger
390-
f"{self.skill_id}.stop.response", # dont want to stop (new style)
374+
"speak", # it's in the stop method even if it returns False!
375+
f"{self.new_skill_id}.stop.response", # dont want to stop (new style)
391376

392-
# check the global stop handlers are called
393-
"speak", # "utterance":"old stop called"
377+
"ovos.utterance.handled"
394378
]
395379

396380
wait_for_n_messages(len(expected_messages))

0 commit comments

Comments
 (0)