Skip to content

Commit

Permalink
fix/deactivate_in_converse/fallback
Browse files Browse the repository at this point in the history
avoid the caveats documented in #451

companion to OpenVoiceOS/OVOS-workshop#199
  • Loading branch information
JarbasAl committed May 4, 2024
1 parent dce8610 commit 5a61e93
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 12 deletions.
2 changes: 1 addition & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ovos-plugin-manager<0.1.0, >=0.0.25
ovos-config~=0.0,>=0.0.13a8
ovos-lingua-franca>=0.4.7
ovos-backend-client~=0.1.0
ovos-workshop<0.1.0, >=0.0.16a26
ovos-workshop<0.1.0, >=0.0.16a27
# provides plugins and classic machine learning framework
ovos-classifiers<0.1.0, >=0.0.0a53

Expand Down
10 changes: 0 additions & 10 deletions test/end2end/session/test_converse.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,16 +556,6 @@ def wait_for_n_messages(n):
"intent.service.skills.deactivated",
f"{self.skill_id}.deactivate",
"ovos.session.update_default",

###########
# TODO - activate is called here if converse return True
"intent.service.skills.activate",
"intent.service.skills.activated",
f"{self.skill_id}.activate",
"ovos.session.update_default",
# /TODO - ovos-workshop PR needed
###########

# needs ovos-workshop PR
"skill.converse.response", # conversed!
# session updated
Expand Down
59 changes: 58 additions & 1 deletion test/end2end/session/test_fallback.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,61 @@ def wait_for_n_messages(n):

# test that active skills list has been updated
for m in messages[10:]:
self.assertEqual(m.context["session"]["active_skills"][0][0], self.skill_id)
self.assertEqual(m.context["session"]["active_skills"][0][0], self.skill_id)

def test_deactivate_in_fallback(self):
messages = []

sess = Session("123")
sess.activate_skill(self.skill_id) # skill is active

def new_msg(msg):
nonlocal messages
m = Message.deserialize(msg)
if m.msg_type in ["ovos.skills.settings_changed", "ovos.common_play.status"]:
return # skip these, only happen in 1st run
messages.append(m)
print(len(messages), msg)

def wait_for_n_messages(n):
nonlocal messages
t = time.time()
while len(messages) < n:
sleep(0.1)
if time.time() - t > 10:
raise RuntimeError("did not get the number of expected messages under 10 seconds")

self.core.bus.on("message", new_msg)

utt = Message("fallback_deactivate")
self.core.bus.emit(utt) # set internal test skill flag
messages = []

utt = Message("recognizer_loop:utterance",
{"utterances": ["deactivate fallback"]},
{"session":sess.serialize()})
self.core.bus.emit(utt)

expected_messages = [
"recognizer_loop:utterance",
# skill is active, so we get converse events
f"{self.skill_id}.converse.ping",
"skill.converse.pong",
# FallbackV2
"ovos.skills.fallback.ping",
"ovos.skills.fallback.pong",
# skill executing
f"ovos.skills.fallback.{self.skill_id}.request",
f"ovos.skills.fallback.{self.skill_id}.start",
"enclosure.active_skill",
"speak",
# deactivate skill in fallback handler
"intent.service.skills.deactivate",
"intent.service.skills.deactivated",
f"{self.skill_id}.deactivate",
# activate events suppressed
f"ovos.skills.fallback.{self.skill_id}.response"
]
wait_for_n_messages(len(expected_messages))

self.assertEqual(len(expected_messages), len(messages))

0 comments on commit 5a61e93

Please sign in to comment.