Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for World Wide Lightning Location Network #25001

Merged
merged 15 commits into from Jul 10, 2019

Added test

  • Loading branch information...
bachya committed Jul 7, 2019
commit cc7727a5639a17a20e07baa6b2460d4dcc6b0d29
@@ -0,0 +1 @@
"""Define tests for the WWLLN component."""
@@ -0,0 +1,77 @@
"""Define tests for the WWLLN config flow."""
import pytest

from homeassistant import data_entry_flow
from homeassistant.components.wwlln import DOMAIN, config_flow
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, CONF_RADIUS

from tests.common import MockConfigEntry


async def test_duplicate_error(hass):
"""Test that errors are shown when duplicates are added."""
conf = {
CONF_LATITUDE: 39.128712,
CONF_LONGITUDE: -104.9812612,
CONF_RADIUS: 25,
}

MockConfigEntry(domain=DOMAIN, data=conf).add_to_hass(hass)
flow = config_flow.WWLLNFlowHandler()
flow.hass = hass

result = await flow.async_step_user(user_input=conf)
assert result['errors'] == {CONF_LATITUDE: 'identifier_exists'}


async def test_show_form(hass):
"""Test that the form is served with no input."""
flow = config_flow.WWLLNFlowHandler()
flow.hass = hass

result = await flow.async_step_user(user_input=None)

assert result['type'] == data_entry_flow.RESULT_TYPE_FORM
assert result['step_id'] == 'user'


async def test_step_import(hass):
"""Test that the import step works."""
conf = {
CONF_LATITUDE: 39.128712,
CONF_LONGITUDE: -104.9812612,
CONF_RADIUS: 25,
}

flow = config_flow.WWLLNFlowHandler()
flow.hass = hass

result = await flow.async_step_import(import_config=conf)
assert result['type'] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result['title'] == '39.128712, -104.9812612'
assert result['data'] == {
CONF_LATITUDE: 39.128712,
CONF_LONGITUDE: -104.9812612,
CONF_RADIUS: 25,
}


async def test_step_user(hass):
"""Test that the user step works."""
conf = {
CONF_LATITUDE: 39.128712,
CONF_LONGITUDE: -104.9812612,
CONF_RADIUS: 25,
}

flow = config_flow.WWLLNFlowHandler()
flow.hass = hass

result = await flow.async_step_user(user_input=conf)
assert result['type'] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result['title'] == '39.128712, -104.9812612'
assert result['data'] == {
CONF_LATITUDE: 39.128712,
CONF_LONGITUDE: -104.9812612,
CONF_RADIUS: 25,
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.