mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Thread pool tweaks
This commit is contained in:
@@ -34,7 +34,7 @@ def _url(path=""):
|
||||
|
||||
def setUpModule(): # pylint: disable=invalid-name
|
||||
""" Initalizes a Home Assistant server and Slave instance. """
|
||||
global hass, slave, master_api, broken_api
|
||||
global hass, slave, master_api
|
||||
|
||||
hass = get_test_home_assistant()
|
||||
|
||||
@@ -64,8 +64,6 @@ def setUpModule(): # pylint: disable=invalid-name
|
||||
|
||||
def tearDownModule(): # pylint: disable=invalid-name
|
||||
""" Stops the Home Assistant server and slave. """
|
||||
global hass, slave
|
||||
|
||||
slave.stop()
|
||||
hass.stop()
|
||||
|
||||
@@ -73,6 +71,10 @@ def tearDownModule(): # pylint: disable=invalid-name
|
||||
class TestRemoteMethods(unittest.TestCase):
|
||||
""" Test the homeassistant.remote module. """
|
||||
|
||||
def tearDown(self):
|
||||
slave.pool.block_till_done()
|
||||
hass.pool.block_till_done()
|
||||
|
||||
def test_validate_api(self):
|
||||
""" Test Python API validate_api. """
|
||||
self.assertEqual(remote.APIStatus.OK, remote.validate_api(master_api))
|
||||
@@ -193,10 +195,24 @@ class TestRemoteMethods(unittest.TestCase):
|
||||
# Should not raise an exception
|
||||
remote.call_service(broken_api, "test_domain", "test_service")
|
||||
|
||||
def test_json_encoder(self):
|
||||
""" Test the JSON Encoder. """
|
||||
ha_json_enc = remote.JSONEncoder()
|
||||
state = hass.states.get('test.test')
|
||||
|
||||
self.assertEqual(state.as_dict(), ha_json_enc.default(state))
|
||||
|
||||
# Default method raises TypeError if non HA object
|
||||
self.assertRaises(TypeError, ha_json_enc.default, 1)
|
||||
|
||||
|
||||
class TestRemoteClasses(unittest.TestCase):
|
||||
""" Test the homeassistant.remote module. """
|
||||
|
||||
def tearDown(self):
|
||||
slave.pool.block_till_done()
|
||||
hass.pool.block_till_done()
|
||||
|
||||
def test_home_assistant_init(self):
|
||||
""" Test HomeAssistant init. """
|
||||
# Wrong password
|
||||
@@ -211,12 +227,8 @@ class TestRemoteClasses(unittest.TestCase):
|
||||
|
||||
def test_statemachine_init(self):
|
||||
""" Tests if remote.StateMachine copies all states on init. """
|
||||
self.assertEqual(len(hass.states.all()),
|
||||
len(slave.states.all()))
|
||||
|
||||
for state in hass.states.all():
|
||||
self.assertEqual(
|
||||
state, slave.states.get(state.entity_id))
|
||||
self.assertEqual(sorted(hass.states.all()),
|
||||
sorted(slave.states.all()))
|
||||
|
||||
def test_statemachine_set(self):
|
||||
""" Tests if setting the state on a slave is recorded. """
|
||||
@@ -271,13 +283,3 @@ class TestRemoteClasses(unittest.TestCase):
|
||||
hass.pool.block_till_done()
|
||||
|
||||
self.assertEqual(1, len(test_value))
|
||||
|
||||
def test_json_encoder(self):
|
||||
""" Test the JSON Encoder. """
|
||||
ha_json_enc = remote.JSONEncoder()
|
||||
state = hass.states.get('test.test')
|
||||
|
||||
self.assertEqual(state.as_dict(), ha_json_enc.default(state))
|
||||
|
||||
# Default method raises TypeError if non HA object
|
||||
self.assertRaises(TypeError, ha_json_enc.default, 1)
|
||||
|
||||
Reference in New Issue
Block a user