Use setup_component in tests v2 (#3537)
* setup_component - sun * setup_component - updater * setup_component - weblink
This commit is contained in:
1 parent
ea4f49f0a0
commit
cae10cfe26
4 files changed
+18
-9
No files matched your search
@@ -4,6 +4,7 @@ import unittest
|
||||
from unittest.mock import patch
|
||||
from datetime import timedelta, datetime
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
import homeassistant.core as ha
|
||||
import homeassistant.util.dt as dt_util
|
||||
import homeassistant.components.sun as sun
|
||||
@@ -31,7 +32,8 @@ class TestSun(unittest.TestCase):
|
||||
|
||||
def test_setting_rising(self):
|
||||
"""Test retrieving sun setting and rising."""
|
||||
sun.setup(self.hass, {sun.DOMAIN: {sun.CONF_ELEVATION: 0}})
|
||||
setup_component(self.hass, sun.DOMAIN, {
|
||||
sun.DOMAIN: {sun.CONF_ELEVATION: 0}})
|
||||
|
||||
from astral import Astral
|
||||
|
||||
@@ -71,7 +73,8 @@ class TestSun(unittest.TestCase):
|
||||
|
||||
def test_state_change(self):
|
||||
"""Test if the state changes at next setting/rising."""
|
||||
sun.setup(self.hass, {sun.DOMAIN: {sun.CONF_ELEVATION: 0}})
|
||||
setup_component(self.hass, sun.DOMAIN, {
|
||||
sun.DOMAIN: {sun.CONF_ELEVATION: 0}})
|
||||
|
||||
if sun.is_on(self.hass):
|
||||
test_state = sun.STATE_BELOW_HORIZON
|
||||
@@ -98,7 +101,8 @@ class TestSun(unittest.TestCase):
|
||||
|
||||
with patch('homeassistant.helpers.condition.dt_util.utcnow',
|
||||
return_value=june):
|
||||
assert sun.setup(self.hass, {sun.DOMAIN: {sun.CONF_ELEVATION: 0}})
|
||||
assert setup_component(self.hass, sun.DOMAIN, {
|
||||
sun.DOMAIN: {sun.CONF_ELEVATION: 0}})
|
||||
|
||||
state = self.hass.states.get(sun.ENTITY_ID)
|
||||
|
||||
|
||||
Reference in new issue
Block a user