Fix buienradar component and add smoke tests (#27965)

* Fixes the buienradar component and add smoke tests

  * Fix errors due to circular imports after imports were moved.
  * Add smoke test so this situation will be caught in the future.

* Add buienradar.util to coveragerc

* Refactor tests to standalone pytest test function style

* Add __init__ to buienradar tests
This commit is contained in:
Ties de Kock authored and cgtobi committed 2019-10-21 13:52:25 +02:00
1 parent ea1401d0b6
commit a05144bb8b
8 files changed
+294 -211

No files matched your search

+1
View File
@@ -0,0 +1 @@
"""Tests for the buienradar component."""
@@ -0,0 +1,26 @@
"""The tests for the Buienradar sensor platform."""
from homeassistant.setup import async_setup_component
from homeassistant.components import sensor
CONDITIONS = ["stationname", "temperature"]
BASE_CONFIG = {
"sensor": [
{
"platform": "buienradar",
"name": "volkel",
"latitude": 51.65,
"longitude": 5.7,
"monitored_conditions": CONDITIONS,
}
]
}
async def test_smoke_test_setup_component(hass):
"""Smoke test for successfully set-up with default config."""
assert await async_setup_component(hass, sensor.DOMAIN, BASE_CONFIG)
for cond in CONDITIONS:
state = hass.states.get(f"sensor.volkel_{cond}")
assert state.state == "unknown"
@@ -0,0 +1,25 @@
"""The tests for the buienradar weather component."""
from homeassistant.components import weather
from homeassistant.setup import async_setup_component
# Example config snippet from documentation.
BASE_CONFIG = {
"weather": [
{
"platform": "buienradar",
"name": "volkel",
"latitude": 51.65,
"longitude": 5.7,
"forecast": True,
}
]
}
async def test_smoke_test_setup_component(hass):
"""Smoke test for successfully set-up with default config."""
assert await async_setup_component(hass, weather.DOMAIN, BASE_CONFIG)
state = hass.states.get("weather.volkel")
assert state.state == "unknown"