Rewrite homematic unittest tests to pytest style test functions (#41766)
Issue: https://github.com/home-assistant/core/issues/40856
This commit is contained in:
parent
267d97e80e
commit
7298bb32f1
1 changed files with 55 additions and 67 deletions
|
@ -1,35 +1,21 @@
|
||||||
"""The tests for the Homematic notification platform."""
|
"""The tests for the Homematic notification platform."""
|
||||||
|
|
||||||
import unittest
|
|
||||||
|
|
||||||
import homeassistant.components.notify as notify_comp
|
import homeassistant.components.notify as notify_comp
|
||||||
from homeassistant.setup import setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from tests.common import assert_setup_component, get_test_home_assistant
|
from tests.common import assert_setup_component
|
||||||
|
|
||||||
|
|
||||||
class TestHomematicNotify(unittest.TestCase):
|
async def test_setup_full(hass):
|
||||||
"""Test the Homematic notifications."""
|
|
||||||
|
|
||||||
def setUp(self): # pylint: disable=invalid-name
|
|
||||||
"""Set up things to be run when tests are started."""
|
|
||||||
self.hass = get_test_home_assistant()
|
|
||||||
self.addCleanup(self.tear_down_cleanup)
|
|
||||||
|
|
||||||
def tear_down_cleanup(self):
|
|
||||||
"""Stop down everything that was started."""
|
|
||||||
self.hass.stop()
|
|
||||||
|
|
||||||
def test_setup_full(self):
|
|
||||||
"""Test valid configuration."""
|
"""Test valid configuration."""
|
||||||
setup_component(
|
await async_setup_component(
|
||||||
self.hass,
|
hass,
|
||||||
"homematic",
|
"homematic",
|
||||||
{"homematic": {"hosts": {"ccu2": {"host": "127.0.0.1"}}}},
|
{"homematic": {"hosts": {"ccu2": {"host": "127.0.0.1"}}}},
|
||||||
)
|
)
|
||||||
with assert_setup_component(1) as handle_config:
|
with assert_setup_component(1) as handle_config:
|
||||||
assert setup_component(
|
assert await async_setup_component(
|
||||||
self.hass,
|
hass,
|
||||||
"notify",
|
"notify",
|
||||||
{
|
{
|
||||||
"notify": {
|
"notify": {
|
||||||
|
@ -45,16 +31,17 @@ class TestHomematicNotify(unittest.TestCase):
|
||||||
)
|
)
|
||||||
assert handle_config[notify_comp.DOMAIN]
|
assert handle_config[notify_comp.DOMAIN]
|
||||||
|
|
||||||
def test_setup_without_optional(self):
|
|
||||||
|
async def test_setup_without_optional(hass):
|
||||||
"""Test valid configuration without optional."""
|
"""Test valid configuration without optional."""
|
||||||
setup_component(
|
await async_setup_component(
|
||||||
self.hass,
|
hass,
|
||||||
"homematic",
|
"homematic",
|
||||||
{"homematic": {"hosts": {"ccu2": {"host": "127.0.0.1"}}}},
|
{"homematic": {"hosts": {"ccu2": {"host": "127.0.0.1"}}}},
|
||||||
)
|
)
|
||||||
with assert_setup_component(1) as handle_config:
|
with assert_setup_component(1) as handle_config:
|
||||||
assert setup_component(
|
assert await async_setup_component(
|
||||||
self.hass,
|
hass,
|
||||||
"notify",
|
"notify",
|
||||||
{
|
{
|
||||||
"notify": {
|
"notify": {
|
||||||
|
@ -69,9 +56,10 @@ class TestHomematicNotify(unittest.TestCase):
|
||||||
)
|
)
|
||||||
assert handle_config[notify_comp.DOMAIN]
|
assert handle_config[notify_comp.DOMAIN]
|
||||||
|
|
||||||
def test_bad_config(self):
|
|
||||||
|
async def test_bad_config(hass):
|
||||||
"""Test invalid configuration."""
|
"""Test invalid configuration."""
|
||||||
config = {notify_comp.DOMAIN: {"name": "test", "platform": "homematic"}}
|
config = {notify_comp.DOMAIN: {"name": "test", "platform": "homematic"}}
|
||||||
with assert_setup_component(0) as handle_config:
|
with assert_setup_component(0) as handle_config:
|
||||||
assert setup_component(self.hass, notify_comp.DOMAIN, config)
|
assert await async_setup_component(hass, notify_comp.DOMAIN, config)
|
||||||
assert not handle_config[notify_comp.DOMAIN]
|
assert not handle_config[notify_comp.DOMAIN]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue