-
-
Notifications
You must be signed in to change notification settings - Fork 28.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite homematic unittest tests to pytest style test functions (#41766)
Issue: #40856
- Loading branch information
Showing
1 changed file
with
54 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,65 @@ | ||
"""The tests for the Homematic notification platform.""" | ||
|
||
import unittest | ||
|
||
import homeassistant.components.notify as notify_comp | ||
from homeassistant.setup import setup_component | ||
|
||
from tests.common import assert_setup_component, get_test_home_assistant | ||
from homeassistant.setup import async_setup_component | ||
|
||
from tests.common import assert_setup_component | ||
|
||
class TestHomematicNotify(unittest.TestCase): | ||
"""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) | ||
async def test_setup_full(hass): | ||
"""Test valid configuration.""" | ||
await async_setup_component( | ||
hass, | ||
"homematic", | ||
{"homematic": {"hosts": {"ccu2": {"host": "127.0.0.1"}}}}, | ||
) | ||
with assert_setup_component(1) as handle_config: | ||
assert await async_setup_component( | ||
hass, | ||
"notify", | ||
{ | ||
"notify": { | ||
"name": "test", | ||
"platform": "homematic", | ||
"address": "NEQXXXXXXX", | ||
"channel": 2, | ||
"param": "SUBMIT", | ||
"value": "1,1,108000,2", | ||
"interface": "my-interface", | ||
} | ||
}, | ||
) | ||
assert handle_config[notify_comp.DOMAIN] | ||
|
||
def tear_down_cleanup(self): | ||
"""Stop down everything that was started.""" | ||
self.hass.stop() | ||
|
||
def test_setup_full(self): | ||
"""Test valid configuration.""" | ||
setup_component( | ||
self.hass, | ||
"homematic", | ||
{"homematic": {"hosts": {"ccu2": {"host": "127.0.0.1"}}}}, | ||
async def test_setup_without_optional(hass): | ||
"""Test valid configuration without optional.""" | ||
await async_setup_component( | ||
hass, | ||
"homematic", | ||
{"homematic": {"hosts": {"ccu2": {"host": "127.0.0.1"}}}}, | ||
) | ||
with assert_setup_component(1) as handle_config: | ||
assert await async_setup_component( | ||
hass, | ||
"notify", | ||
{ | ||
"notify": { | ||
"name": "test", | ||
"platform": "homematic", | ||
"address": "NEQXXXXXXX", | ||
"channel": 2, | ||
"param": "SUBMIT", | ||
"value": "1,1,108000,2", | ||
} | ||
}, | ||
) | ||
with assert_setup_component(1) as handle_config: | ||
assert setup_component( | ||
self.hass, | ||
"notify", | ||
{ | ||
"notify": { | ||
"name": "test", | ||
"platform": "homematic", | ||
"address": "NEQXXXXXXX", | ||
"channel": 2, | ||
"param": "SUBMIT", | ||
"value": "1,1,108000,2", | ||
"interface": "my-interface", | ||
} | ||
}, | ||
) | ||
assert handle_config[notify_comp.DOMAIN] | ||
assert handle_config[notify_comp.DOMAIN] | ||
|
||
def test_setup_without_optional(self): | ||
"""Test valid configuration without optional.""" | ||
setup_component( | ||
self.hass, | ||
"homematic", | ||
{"homematic": {"hosts": {"ccu2": {"host": "127.0.0.1"}}}}, | ||
) | ||
with assert_setup_component(1) as handle_config: | ||
assert setup_component( | ||
self.hass, | ||
"notify", | ||
{ | ||
"notify": { | ||
"name": "test", | ||
"platform": "homematic", | ||
"address": "NEQXXXXXXX", | ||
"channel": 2, | ||
"param": "SUBMIT", | ||
"value": "1,1,108000,2", | ||
} | ||
}, | ||
) | ||
assert handle_config[notify_comp.DOMAIN] | ||
|
||
def test_bad_config(self): | ||
"""Test invalid configuration.""" | ||
config = {notify_comp.DOMAIN: {"name": "test", "platform": "homematic"}} | ||
with assert_setup_component(0) as handle_config: | ||
assert setup_component(self.hass, notify_comp.DOMAIN, config) | ||
assert not handle_config[notify_comp.DOMAIN] | ||
async def test_bad_config(hass): | ||
"""Test invalid configuration.""" | ||
config = {notify_comp.DOMAIN: {"name": "test", "platform": "homematic"}} | ||
with assert_setup_component(0) as handle_config: | ||
assert await async_setup_component(hass, notify_comp.DOMAIN, config) | ||
assert not handle_config[notify_comp.DOMAIN] |