Support for html5 notifications to suggest their names (#19965)

* support for devices to suggest their names

* houndci fixes

* Lint
This commit is contained in:
Tommy Jonsson authored and Paulus Schoutsen committed 2019-01-11 20:44:29 -08:00
1 parent 2208563de4
commit 3bdee57066
2 files changed
+47 -3

No files matched your search

+38
View File
@@ -165,6 +165,23 @@ async def test_registering_new_device_view(hass, hass_client):
}
async def test_registering_new_device_view_with_name(hass, hass_client):
"""Test that the HTML view works with name attribute."""
client = await mock_client(hass, hass_client)
SUB_WITH_NAME = SUBSCRIPTION_1.copy()
SUB_WITH_NAME['name'] = 'test device'
with patch('homeassistant.components.notify.html5.save_json') as mock_save:
resp = await client.post(REGISTER_URL, data=json.dumps(SUB_WITH_NAME))
assert resp.status == 200
assert len(mock_save.mock_calls) == 1
assert mock_save.mock_calls[0][1][1] == {
'test device': SUBSCRIPTION_1,
}
async def test_registering_new_device_expiration_view(hass, hass_client):
"""Test that the HTML view works."""
client = await mock_client(hass, hass_client)
@@ -209,6 +226,27 @@ async def test_registering_existing_device_view(hass, hass_client):
}
async def test_registering_existing_device_view_with_name(hass, hass_client):
"""Test subscription is updated when reg'ing existing device with name."""
registrations = {}
client = await mock_client(hass, hass_client, registrations)
SUB_WITH_NAME = SUBSCRIPTION_1.copy()
SUB_WITH_NAME['name'] = 'test device'
with patch('homeassistant.components.notify.html5.save_json') as mock_save:
await client.post(REGISTER_URL, data=json.dumps(SUB_WITH_NAME))
resp = await client.post(REGISTER_URL, data=json.dumps(SUBSCRIPTION_4))
assert resp.status == 200
assert mock_save.mock_calls[0][1][1] == {
'test device': SUBSCRIPTION_4,
}
assert registrations == {
'test device': SUBSCRIPTION_4,
}
async def test_registering_existing_device_fails_view(hass, hass_client):
"""Test sub. is not updated when registering existing device fails."""
registrations = {}