Skip to content

Commit

Permalink
Fixes #10773: Demo Alarm Broken (#10777)
Browse files Browse the repository at this point in the history
* Fixes #10773: Demo Alarm Broken

* Added test for platform setup

* Remove unused import

* Lint fix

* Rework assert to work with python 3.5
  • Loading branch information
uchagani authored and balloob committed Nov 25, 2017
1 parent fcc164c commit 2817f03
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
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()
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

0 comments on commit 2817f03

Please sign in to comment.