LiteJet is now configured using config_flow (#44409)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
ffe42e150a
commit
6a8b5ee51b
22 changed files with 725 additions and 452 deletions
|
@ -1,41 +1,30 @@
|
|||
"""The tests for the litejet component."""
|
||||
import unittest
|
||||
|
||||
from homeassistant.components import litejet
|
||||
from homeassistant.components.litejet.const import DOMAIN
|
||||
from homeassistant.const import CONF_PORT
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import get_test_home_assistant
|
||||
from . import async_init_integration
|
||||
|
||||
|
||||
class TestLiteJet(unittest.TestCase):
|
||||
"""Test the litejet component."""
|
||||
async def test_setup_with_no_config(hass):
|
||||
"""Test that nothing happens."""
|
||||
assert await async_setup_component(hass, DOMAIN, {}) is True
|
||||
assert DOMAIN not in hass.data
|
||||
|
||||
def setup_method(self, method):
|
||||
"""Set up 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()
|
||||
async def test_setup_with_config_to_import(hass, mock_litejet):
|
||||
"""Test that import happens."""
|
||||
assert (
|
||||
await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PORT: "/dev/hello"}})
|
||||
is True
|
||||
)
|
||||
assert DOMAIN in hass.data
|
||||
|
||||
def test_is_ignored_unspecified(self):
|
||||
"""Ensure it is ignored when unspecified."""
|
||||
self.hass.data["litejet_config"] = {}
|
||||
assert not litejet.is_ignored(self.hass, "Test")
|
||||
|
||||
def test_is_ignored_empty(self):
|
||||
"""Ensure it is ignored when empty."""
|
||||
self.hass.data["litejet_config"] = {litejet.CONF_EXCLUDE_NAMES: []}
|
||||
assert not litejet.is_ignored(self.hass, "Test")
|
||||
async def test_unload_entry(hass, mock_litejet):
|
||||
"""Test being able to unload an entry."""
|
||||
entry = await async_init_integration(hass, use_switch=True, use_scene=True)
|
||||
|
||||
def test_is_ignored_normal(self):
|
||||
"""Test if usually ignored."""
|
||||
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")
|
||||
assert await litejet.async_unload_entry(hass, entry)
|
||||
assert DOMAIN not in hass.data
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue