skill-desktop-launcher/test/__init__.py

35 lines
1.5 KiB
Python
Raw Permalink Normal View History

2019-11-06 13:52:20 +00:00
from test.integrationtests.skills.skill_tester import SkillTest
import mock
SEARCH_BASE = 'http://www.google.com/search?&sourceid=navclient&btnI=I&q={}'
@mock.patch('mycroft.skills.mycroft_skill.mycroft_skill.DeviceApi.send_email')
def test_runner(skill, example, emitter, loader, m1):
s = [s for s in loader.skills if s and s.root_dir == skill][0]
with mock.patch('webbrowser.open') as m:
ret = SkillTest(skill, example, emitter).run(loader)
if example.endswith('find.puppies.json'):
m.assert_called_with(SEARCH_BASE.format('wikipedia%20puppies'))
elif example.endswith('find.puppies.json'):
m.assert_called_with(SEARCH_BASE.format('imgur'))
elif example.endswith('open.tumblr.json'):
m.assert_called_with(SEARCH_BASE.format('tumblr'))
elif example.endswith('search.for.kittens.json'):
m.assert_called_with(SEARCH_BASE.format('youtube%20for%20kittens'))
2019-11-06 14:07:18 +00:00
if example.endswith('launch.rocket.json'):
s.register_vocabulary('rocket', 'Application')
m = mock.Mock()
s.appmap['rocket'] = [m]
ret = SkillTest(skill, example, emitter).run(loader)
m.launch.assert_called_with()
elif example.endswith('open.notepad.json'):
s.register_vocabulary('notepad', 'Application')
m = mock.Mock()
s.appmap['notepad'] = [m]
ret = SkillTest(skill, example, emitter).run(loader)
m.launch.assert_called_with()
2019-11-06 13:52:20 +00:00
return ret