Moved service decorator to service helpers
Moved the service decorator to the service helpers module and moved the associated tests.
This commit is contained in:
parent
f66aeb2e73
commit
5830da63b1
5 changed files with 40 additions and 17 deletions
|
@ -7,7 +7,6 @@ Test service helpers.
|
|||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.const import SERVICE_TURN_ON
|
||||
from homeassistant.helpers import service
|
||||
|
||||
from tests.common import get_test_home_assistant, mock_service
|
||||
|
@ -23,10 +22,23 @@ class TestServiceHelpers(unittest.TestCase):
|
|||
self.hass = get_test_home_assistant()
|
||||
self.calls = mock_service(self.hass, 'test_domain', 'test_service')
|
||||
|
||||
service.HASS = self.hass
|
||||
|
||||
def tearDown(self): # pylint: disable=invalid-name
|
||||
""" Stop down stuff we started. """
|
||||
self.hass.stop()
|
||||
|
||||
def test_service(self):
|
||||
""" Test service registration decorator. """
|
||||
runs = []
|
||||
|
||||
decor = service.service('test', 'test')
|
||||
decor(lambda x, y: runs.append(1))
|
||||
|
||||
self.hass.services.call('test', 'test')
|
||||
self.hass.pool.block_till_done()
|
||||
self.assertEqual(1, len(runs))
|
||||
|
||||
def test_split_entity_string(self):
|
||||
service.call_from_config(self.hass, {
|
||||
'service': 'test_domain.test_service',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue