|
| 1 | +from unittest import TestCase |
| 2 | + |
| 3 | +from ovos_bus_client.message import Message |
| 4 | +from ovos_bus_client.session import Session |
| 5 | +from ovos_utils.log import LOG |
| 6 | +from ovoscope import End2EndTest, get_minicroft |
| 7 | + |
| 8 | + |
| 9 | +class TestCancelIntentMidSentence(TestCase): |
| 10 | + |
| 11 | + def setUp(self): |
| 12 | + LOG.set_level("DEBUG") |
| 13 | + self.skill_id = "ovos-skill-hello-world.openvoiceos" |
| 14 | + self.minicroft = get_minicroft([self.skill_id]) |
| 15 | + |
| 16 | + def tearDown(self): |
| 17 | + if self.minicroft: |
| 18 | + self.minicroft.stop() |
| 19 | + LOG.set_level("CRITICAL") |
| 20 | + |
| 21 | + def test_cancel_match(self): |
| 22 | + session = Session("123") |
| 23 | + message = Message("recognizer_loop:utterance", |
| 24 | + {"utterances": ["can you tell me the...ummm...oh, nevermind that"], "lang": "en-US"}, |
| 25 | + {"session": session.serialize(), "source": "A", "destination": "B"}) |
| 26 | + |
| 27 | + # utterance cancelled -> no complete_intent_failure |
| 28 | + test = End2EndTest( |
| 29 | + minicroft=self.minicroft, |
| 30 | + skill_ids=[self.skill_id], |
| 31 | + source_message=message, |
| 32 | + expected_messages=[ |
| 33 | + message, |
| 34 | + Message("mycroft.audio.play_sound", {"uri": "snd/cancel.mp3"}), |
| 35 | + Message("ovos.utterance.cancelled", {}), |
| 36 | + Message("ovos.utterance.handled", {}), |
| 37 | + |
| 38 | + ] |
| 39 | + ) |
| 40 | + |
| 41 | + test.execute(timeout=10) |
| 42 | + |
| 43 | + # ensure hello world doesnt match either |
| 44 | + message = Message("recognizer_loop:utterance", |
| 45 | + {"utterances": ["hello world cancel command"], "lang": "en-US"}, |
| 46 | + {"session": session.serialize(), "source": "A", "destination": "B"}) |
| 47 | + |
| 48 | + test = End2EndTest( |
| 49 | + minicroft=self.minicroft, |
| 50 | + skill_ids=[self.skill_id], |
| 51 | + source_message=message, |
| 52 | + expected_messages=[ |
| 53 | + message, |
| 54 | + Message("mycroft.audio.play_sound", {"uri": "snd/cancel.mp3"}), |
| 55 | + Message("ovos.utterance.cancelled", {}), |
| 56 | + Message("ovos.utterance.handled", {}), |
| 57 | + |
| 58 | + ] |
| 59 | + ) |
| 60 | + |
| 61 | + test.execute(timeout=10) |
| 62 | + |
0 commit comments