-
-
Notifications
You must be signed in to change notification settings - Fork 37.4k
Move HassIntent handler code into helpers/intent #12181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
eedb3d0
bf015c9
b3d7bf6
8651566
c842be2
04b407a
c479075
13d0d9a
ac5d2e5
2dcfe18
861cdc5
2214096
90280d7
f287689
7992a73
5e987e8
5496efd
cb8ab73
2d9becd
0d955d3
1262ba3
ed1bcf2
6cfce83
95d30c6
42273fc
a43bc92
b2ad2f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,7 +46,6 @@ | |
| 'ephem', | ||
| 'evohomeclient', | ||
| 'feedparser', | ||
| 'fuzzywuzzy', | ||
| 'gTTS-token', | ||
| 'ha-ffmpeg', | ||
| 'haversine', | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
|
|
||
| from homeassistant.setup import async_setup_component | ||
| from homeassistant.components import conversation | ||
| import homeassistant.components as component | ||
| from homeassistant.helpers import intent | ||
|
|
||
| from tests.common import async_mock_intent, async_mock_service | ||
|
|
@@ -16,6 +17,9 @@ def test_calling_intent(hass): | |
| """Test calling an intent from a conversation.""" | ||
| intents = async_mock_intent(hass, 'OrderBeer') | ||
|
|
||
| result = yield from component.async_setup(hass, {}) | ||
| assert result | ||
|
|
||
| result = yield from async_setup_component(hass, 'conversation', { | ||
| 'conversation': { | ||
| 'intents': { | ||
|
|
@@ -145,6 +149,9 @@ def async_handle(self, intent): | |
| @pytest.mark.parametrize('sentence', ('turn on kitchen', 'turn kitchen on')) | ||
| def test_turn_on_intent(hass, sentence): | ||
| """Test calling the turn on intent.""" | ||
| result = yield from component.async_setup(hass, {}) | ||
| assert result | ||
|
|
||
| result = yield from async_setup_component(hass, 'conversation', {}) | ||
| assert result | ||
|
|
||
|
|
@@ -168,6 +175,9 @@ def test_turn_on_intent(hass, sentence): | |
| @pytest.mark.parametrize('sentence', ('turn off kitchen', 'turn kitchen off')) | ||
| def test_turn_off_intent(hass, sentence): | ||
| """Test calling the turn on intent.""" | ||
| result = yield from component.async_setup(hass, {}) | ||
| assert result | ||
|
|
||
| result = yield from async_setup_component(hass, 'conversation', {}) | ||
| assert result | ||
|
|
||
|
|
@@ -187,9 +197,38 @@ def test_turn_off_intent(hass, sentence): | |
| assert call.data == {'entity_id': 'light.kitchen'} | ||
|
|
||
|
|
||
| @asyncio.coroutine | ||
| @pytest.mark.parametrize('sentence', ('toggle kitchen', 'kitchen toggle')) | ||
| def test_toggle_intent(hass, sentence): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tests for the generic intents need to be moved to
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And then they shouldn't depend on conversation.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can add test_init but I think these tests should remain here since they are also testing the utterance matching and such.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Testing the utterances is good, but we also need to add tests to the other file as that's where they are defined. We can't have core logic be only tested inside component tests. |
||
| """Test calling the turn on intent.""" | ||
| result = yield from component.async_setup(hass, {}) | ||
| assert result | ||
|
|
||
| result = yield from async_setup_component(hass, 'conversation', {}) | ||
| assert result | ||
|
|
||
| hass.states.async_set('light.kitchen', 'on') | ||
| calls = async_mock_service(hass, 'homeassistant', 'toggle') | ||
|
|
||
| yield from hass.services.async_call( | ||
| 'conversation', 'process', { | ||
| conversation.ATTR_TEXT: sentence | ||
| }) | ||
| yield from hass.async_block_till_done() | ||
|
|
||
| assert len(calls) == 1 | ||
| call = calls[0] | ||
| assert call.domain == 'homeassistant' | ||
| assert call.service == 'toggle' | ||
| assert call.data == {'entity_id': 'light.kitchen'} | ||
|
|
||
|
|
||
| @asyncio.coroutine | ||
| def test_http_api(hass, test_client): | ||
| """Test the HTTP conversation API.""" | ||
| result = yield from component.async_setup(hass, {}) | ||
| assert result | ||
|
|
||
| result = yield from async_setup_component(hass, 'conversation', {}) | ||
| assert result | ||
|
|
||
|
|
@@ -212,6 +251,9 @@ def test_http_api(hass, test_client): | |
| @asyncio.coroutine | ||
| def test_http_api_wrong_data(hass, test_client): | ||
| """Test the HTTP conversation API.""" | ||
| result = yield from component.async_setup(hass, {}) | ||
| assert result | ||
|
|
||
| result = yield from async_setup_component(hass, 'conversation', {}) | ||
| assert result | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add this back where we import fuzzywuzzy. I remember it spamming a lot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you've removed fuzzywuzzy, ok too 👍