Add tests for lock component
This commit is contained in:
parent
7d503e3f8b
commit
8841eef2b7
4 changed files with 57 additions and 20 deletions
0
tests/components/lock/__init__.py
Normal file
0
tests/components/lock/__init__.py
Normal file
51
tests/components/lock/test_demo.py
Normal file
51
tests/components/lock/test_demo.py
Normal file
|
@ -0,0 +1,51 @@
|
|||
"""
|
||||
tests.components.lock.test_demo
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Tests demo lock component.
|
||||
"""
|
||||
import unittest
|
||||
|
||||
import homeassistant.core as ha
|
||||
from homeassistant.components import lock
|
||||
|
||||
|
||||
FRONT = 'lock.front_door'
|
||||
KITCHEN = 'lock.kitchen_door'
|
||||
|
||||
|
||||
class TestLockDemo(unittest.TestCase):
|
||||
""" Test the demo lock. """
|
||||
|
||||
def setUp(self): # pylint: disable=invalid-name
|
||||
self.hass = ha.HomeAssistant()
|
||||
self.assertTrue(lock.setup(self.hass, {
|
||||
'lock': {
|
||||
'platform': 'demo'
|
||||
}
|
||||
}))
|
||||
|
||||
def tearDown(self): # pylint: disable=invalid-name
|
||||
""" Stop down stuff we started. """
|
||||
self.hass.stop()
|
||||
|
||||
def test_is_locked(self):
|
||||
self.assertTrue(lock.is_locked(self.hass, FRONT))
|
||||
self.hass.states.is_state(FRONT, 'locked')
|
||||
|
||||
self.assertFalse(lock.is_locked(self.hass, KITCHEN))
|
||||
self.hass.states.is_state(KITCHEN, 'unlocked')
|
||||
|
||||
def test_locking(self):
|
||||
lock.lock(self.hass, KITCHEN)
|
||||
|
||||
self.hass.pool.block_till_done()
|
||||
|
||||
self.assertTrue(lock.is_locked(self.hass, KITCHEN))
|
||||
|
||||
def test_unlocking(self):
|
||||
lock.unlock(self.hass, FRONT)
|
||||
|
||||
self.hass.pool.block_till_done()
|
||||
|
||||
self.assertFalse(lock.is_locked(self.hass, FRONT))
|
Loading…
Add table
Add a link
Reference in a new issue