Skip to content
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

Fixes #10773: Demo Alarm Broken #10777

Merged
merged 5 commits into from
Nov 25, 2017
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion homeassistant/components/alarm_control_panel/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import homeassistant.components.alarm_control_panel.manual as manual
from homeassistant.const import (
STATE_ALARM_ARMED_AWAY, STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_NIGHT,
STATE_ALARM_TRIGGERED, CONF_PENDING_TIME)
STATE_ALARM_ARMED_CUSTOM_BYPASS, STATE_ALARM_TRIGGERED, CONF_PENDING_TIME)


def setup_platform(hass, config, add_devices, discovery_info=None):
Expand All @@ -23,6 +23,9 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
STATE_ALARM_ARMED_NIGHT: {
CONF_PENDING_TIME: 5
},
STATE_ALARM_ARMED_CUSTOM_BYPASS: {
CONF_PENDING_TIME: 5
},
STATE_ALARM_TRIGGERED: {
CONF_PENDING_TIME: 5
},
Expand Down
11 changes: 10 additions & 1 deletion tests/components/alarm_control_panel/test_manual.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"""The tests for the manual Alarm Control Panel component."""
from datetime import timedelta
import unittest
from unittest.mock import patch
from unittest.mock import patch, MagicMock
from homeassistant.components.alarm_control_panel import demo


from homeassistant.setup import setup_component
from homeassistant.const import (
Expand All @@ -27,6 +29,13 @@ def tearDown(self): # pylint: disable=invalid-name
"""Stop down everything that was started."""
self.hass.stop()

def test_setup_demo_platform(self):
"""Test setup."""
mock = MagicMock()
add_devices = mock.MagicMock()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's the code you originally suggested. I had to import MagicMock as it wasn't already imported in this file and and to define what mock was.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be like this, since you import MagicMock:

add_devices = MagicMock()

demo.setup_platform(self.hass, {}, add_devices)
self.assertEquals(add_devices.call_count, 1)

def test_arm_home_no_pending(self):
"""Test arm home method."""
self.assertTrue(setup_component(
Expand Down