This commit is contained in:
Paulus Schoutsen committed 2019-07-31 12:25:30 -07:00
1 parent da05dfe708
commit 4de97abc3a
2676 files changed
+163166 -140084

No files matched your search

+13 -16
View File
@@ -9,19 +9,16 @@ from tests.common import MockDependency
async def test_config_flow_registers_webhook(hass, aiohttp_client):
"""Test setting up Twilio and sending webhook."""
with MockDependency('twilio', 'rest'), MockDependency('twilio', 'twiml'):
with patch('homeassistant.util.get_local_ip',
return_value='example.com'):
with MockDependency("twilio", "rest"), MockDependency("twilio", "twiml"):
with patch("homeassistant.util.get_local_ip", return_value="example.com"):
result = await hass.config_entries.flow.async_init(
'twilio', context={
'source': 'user'
})
assert result['type'] == data_entry_flow.RESULT_TYPE_FORM, result
"twilio", context={"source": "user"}
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM, result
result = await hass.config_entries.flow.async_configure(
result['flow_id'], {})
assert result['type'] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
webhook_id = result['result'].data['webhook_id']
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
webhook_id = result["result"].data["webhook_id"]
twilio_events = []
@@ -33,10 +30,10 @@ async def test_config_flow_registers_webhook(hass, aiohttp_client):
hass.bus.async_listen(twilio.RECEIVED_DATA, handle_event)
client = await aiohttp_client(hass.http.app)
await client.post('/api/webhook/{}'.format(webhook_id), data={
'hello': 'twilio'
})
await client.post(
"/api/webhook/{}".format(webhook_id), data={"hello": "twilio"}
)
assert len(twilio_events) == 1
assert twilio_events[0].data['webhook_id'] == webhook_id
assert twilio_events[0].data['hello'] == 'twilio'
assert twilio_events[0].data["webhook_id"] == webhook_id
assert twilio_events[0].data["hello"] == "twilio"