Admin service to automatically add empty schema (#22637)

* Admin service to automatically add empty schema

* Lint
This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2019-04-02 09:34:11 -07:00
1 parent b8b3f4e88f
commit e00ae35e07
3 files changed
+25 -8

No files matched your search

+19 -2
View File
@@ -406,7 +406,11 @@ async def test_register_admin_service(hass, hass_read_only_user,
calls.append(call)
hass.helpers.service.async_register_admin_service(
'test', 'test', mock_service, vol.Schema({})
'test', 'test', mock_service
)
hass.helpers.service.async_register_admin_service(
'test', 'test2', mock_service,
vol.Schema({vol.Required('required'): cv.boolean})
)
with pytest.raises(exceptions.UnknownUser):
@@ -423,8 +427,21 @@ async def test_register_admin_service(hass, hass_read_only_user,
))
assert len(calls) == 0
with pytest.raises(vol.Invalid):
await hass.services.async_call(
'test', 'test', {'invalid': True}, blocking=True,
context=ha.Context(user_id=hass_admin_user.id))
assert len(calls) == 0
with pytest.raises(vol.Invalid):
await hass.services.async_call(
'test', 'test2', {}, blocking=True, context=ha.Context(
user_id=hass_admin_user.id
))
assert len(calls) == 0
await hass.services.async_call(
'test', 'test', {}, blocking=True, context=ha.Context(
'test', 'test2', {'required': True}, blocking=True, context=ha.Context(
user_id=hass_admin_user.id
))
assert len(calls) == 1