Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

Issue-2567 - Fixing not initialized dialog_render #2685

Merged
merged 5 commits into from
Sep 15, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions mycroft/skills/mycroft_skill/mycroft_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -1134,9 +1134,17 @@ def speak_dialog(self, key, data=None, expect_response=False, wait=False):
wait (bool): set to True to block while the text
is being spoken.
"""
data = data or {}
self.speak(self.dialog_renderer.render(key, data),
expect_response, wait, meta={'dialog': key, 'data': data})
if self.dialog_renderer:
data = data or {}
self.speak(
self.dialog_renderer.render(key, data),
expect_response, wait, meta={'dialog': key, 'data': data}
)
else:
self.log.warning(
'dialog_render is None, does the locale/dialog folder exists?'
katridi marked this conversation as resolved.
Show resolved Hide resolved
)
self.speak(key, expect_response, wait, {})

def acknowledge(self):
"""Acknowledge a successful request.
Expand Down
7 changes: 7 additions & 0 deletions test/unittests/skills/test_mycroft_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,13 @@ def test_translate_locations(self):
# Restore lang to en-us
s.config_core['lang'] = 'en-us'

def test_speak_dialog_render_not_intialized(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo on initialized

katridi marked this conversation as resolved.
Show resolved Hide resolved
"""Test that non-initialzed dialog_renderer won't raise an error."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Different typo on initialized

katridi marked this conversation as resolved.
Show resolved Hide resolved
s = SimpleSkill1()
s.bind(self.emitter)
s.dialog_renderer = None
s.speak_dialog(key='key')


class _TestSkill(MycroftSkill):
def __init__(self):
Expand Down