LiteJet: Unit tests and new trigger options held_more_than and held_less_than. (#4473)
* LiteJet: Unit tests and new trigger options held_more_than and held_less_than. * Unit tests for the LiteJet component and associated platforms. Coverage is almost 100% -- just misses one line. * The automation LiteJet trigger returns an empty "removal" function to ensure the automation base is happy with it. The pylitejet library doesn't actually support a real removal. * The automation LiteJet trigger can detect hold time and act appropriately to support things like short tap or long hold. * LiteJet: Fix indent in unit test source code. * LiteJet: Fix test_include_switches_* unit tests on Python 3.5 * LiteJet: Remove wait for state existence from unit tests. Recent fixes to discovery make this no longer necessary.
This commit is contained in:
1 parent
84040892df
commit
2a6c0cfc17
7 files changed
+727
-6
No files matched your search
@@ -0,0 +1,42 @@
|
||||
"""The tests for the litejet component."""
|
||||
import logging
|
||||
import unittest
|
||||
|
||||
from homeassistant.components import litejet
|
||||
from tests.common import get_test_home_assistant
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TestLiteJet(unittest.TestCase):
|
||||
"""Test the litejet component."""
|
||||
|
||||
def setup_method(self, method):
|
||||
"""Setup things to be run when tests are started."""
|
||||
self.hass = get_test_home_assistant()
|
||||
self.hass.start()
|
||||
self.hass.block_till_done()
|
||||
|
||||
def teardown_method(self, method):
|
||||
"""Stop everything that was started."""
|
||||
self.hass.stop()
|
||||
|
||||
def test_is_ignored_unspecified(self):
|
||||
self.hass.data['litejet_config'] = {}
|
||||
assert not litejet.is_ignored(self.hass, 'Test')
|
||||
|
||||
def test_is_ignored_empty(self):
|
||||
self.hass.data['litejet_config'] = {
|
||||
litejet.CONF_EXCLUDE_NAMES: []
|
||||
}
|
||||
assert not litejet.is_ignored(self.hass, 'Test')
|
||||
|
||||
def test_is_ignored_normal(self):
|
||||
self.hass.data['litejet_config'] = {
|
||||
litejet.CONF_EXCLUDE_NAMES: ['Test', 'Other One']
|
||||
}
|
||||
assert litejet.is_ignored(self.hass, 'Test')
|
||||
assert not litejet.is_ignored(self.hass, 'Other one')
|
||||
assert not litejet.is_ignored(self.hass, 'Other 0ne')
|
||||
assert litejet.is_ignored(self.hass, 'Other One There')
|
||||
assert litejet.is_ignored(self.hass, 'Other One')
|
||||
Reference in new issue
Block a user