8000 Update unit tests for remote.py by kellerza · Pull Request #2782 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

Update unit tests for remote.py #2782

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 11, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions tests/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def setUpModule(): # pylint: disable=invalid-name
bootstrap.setup_component(
hass, http.DOMAIN,
{http.DOMAIN: {http.CONF_API_PASSWORD: API_PASSWORD,
http.CONF_SERVER_PORT: MASTER_PORT}})
http.CONF_SERVER_PORT: MASTER_PORT}})

bootstrap.setup_component(hass, 'api')

Expand All @@ -57,7 +57,7 @@ def setUpModule(): # pylint: disable=invalid-name
bootstrap.setup_component(
slave, http.DOMAIN,
{http.DOMAIN: {http.CONF_API_PASSWORD: API_PASSWORD,
http.CONF_SERVER_PORT: SLAVE_PORT}})
http.CONF_SERVER_PORT: SLAVE_PORT}})

slave.start()

Expand Down Expand Up @@ -109,7 +109,7 @@ def listener(event):
"""Helper method that will verify our event got called."""
test_value.append(1)

hass.bus.listen_once("test.event_no_data", listener)
hass.bus.listen("test.event_no_data", listener)
remote.fire_event(master_api, "test.event_no_data")
hass.pool.block_till_done()
self.assertEqual(1, len(test_value))
Expand Down Expand Up @@ -150,7 +150,7 @@ def test_set_state(self):
self.assertFalse(remote.set_state(broken_api, 'test.test', 'set_test'))

def test_set_state_with_push(self):
"""TestPython API set_state with push option."""
"""Test Python API set_state with push option."""
events = []
hass.bus.listen(EVENT_STATE_CHANGED, events.append)

Expand Down Expand Up @@ -259,11 +259,13 @@ def test_statemachine_remove_from_master(self):
"""Remove statemachine from master."""
hass.states.set("remote.master_remove", "remove me!")
hass.pool.block_till_done()
slave.pool.block_till_done()

self.assertIn('remote.master_remove', slave.states.entity_ids())

hass.states.remove("remote.master_remove")
hass.pool.block_till_done()
slave.pool.block_till_done()

self.assertNotIn('remote.master_remove', slave.states.entity_ids())

Expand All @@ -282,21 +284,20 @@ def test_statemachine_remove_from_slave(self):

def test_eventbus_fire(self):
"""Test if events fired from the eventbus get fired."""
test_value = []

def listener(event):
"""Helper method that will verify our event got called."""
test_value.append(1)
hass_call = []
slave_call = []

slave.bus.listen_once("test.event_no_data", listener)
hass.bus.listen("test.event_no_data", lambda _: hass_call.append(1))
slave.bus.listen("test.event_no_data", lambda _: slave_call.append(1))
slave.bus.fire("test.event_no_data")

# Wait till slave tells master
slave.pool.block_till_done()
# Wait till master gives updated event
hass.pool.block_till_done()

self.assertEqual(1, len(test_value))
self.assertEqual(1, len(hass_call))
self.assertEqual(1, len(slave_call))

def test_get_config(self):
"""Test the return of the configuration."""
Expand Down
0