Skip to content

Commit

Permalink
Update to handle default prompt_on_start setting
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonDaniel committed Dec 15, 2023
1 parent 9c55052 commit 4893569
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ def demo_filename(self):
"""
return self.settings.get("filename") or "demo.txt"

@property
def prompt_on_start(self):
return self.settings.get("prompt_on_start", True)

def initialize(self):
# When demo prompt enabled, wait for load and prompt user
if self.settings.get("prompt_on_start"):
Expand Down
10 changes: 6 additions & 4 deletions test/test_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_00_skill_init(self):
from neon_utils.skills import NeonSkill

self.assertIsInstance(self.skill, NeonSkill)
self.assertTrue(self.skill.settings["prompt_on_start"])
self.assertTrue(self.skill.prompt_on_start)

def test_skill_show_demo_prompt_no_response(self):
def ask_yesno(dialog):
Expand All @@ -53,8 +53,8 @@ def ask_yesno(dialog):

self.skill._show_demo_prompt(Message("mycroft.ready"))
self.skill.speak_dialog.assert_called_with("confirm_demo_disabled")
self.assertFalse(self.skill.prompt_on_start)
self.assertFalse(self.skill.settings["prompt_on_start"])

self.skill.ask_yesno = default_ask_yesno

def test_skill_show_demo_prompt_no_demo_no_response(self):
Expand All @@ -69,8 +69,8 @@ def ask_yesno(dialog):

self.skill._show_demo_prompt(Message("mycroft.ready"))
self.skill.speak_dialog.assert_called_with("confirm_demo_disabled")
self.assertFalse(self.skill.prompt_on_start)
self.assertFalse(self.skill.settings["prompt_on_start"])

self.skill.ask_yesno = default_ask_yesno

def test_skill_show_demo_prompt_no_demo_no_next_time(self):
Expand All @@ -85,6 +85,7 @@ def ask_yesno(dialog):

self.skill._show_demo_prompt(Message("mycroft.ready"))
self.skill.speak_dialog.assert_called_with("confirm_demo_disabled")
self.assertFalse(self.skill.prompt_on_start)
self.assertFalse(self.skill.settings["prompt_on_start"])

self.skill.ask_yesno = default_ask_yesno
Expand All @@ -101,8 +102,8 @@ def ask_yesno(dialog):

self.skill._show_demo_prompt(Message("mycroft.ready"))
self.skill.speak_dialog.assert_called_with("confirm_demo_enabled")
self.assertTrue(self.skill.prompt_on_start)
self.assertTrue(self.skill.settings["prompt_on_start"])

self.skill.ask_yesno = default_ask_yesno

def test_skill_show_demo_prompt_yes_demo(self):
Expand All @@ -122,6 +123,7 @@ def ask_yesno(dialog):
context={"neon_should_respond": True})
self.skill._show_demo_prompt(message)
self.skill.handle_show_demo.assert_called_with(message)
self.assertFalse(self.skill.prompt_on_start)
self.assertFalse(self.skill.settings["prompt_on_start"])

self.skill.ask_yesno = default_ask_yesno
Expand Down

0 comments on commit 4893569

Please sign in to comment.