1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Migrate no_ip tests from coroutine to async/await (#30370)

This commit is contained in:
Franck Nijhof
2020-01-02 00:18:41 +01:00
committed by Andrew Sayre
parent 47aa0043bf
commit 8814e1eadc

View File

@@ -1,5 +1,4 @@
"""Test the NO-IP component."""
import asyncio
from datetime import timedelta
import pytest
@@ -39,12 +38,11 @@ def setup_no_ip(hass, aioclient_mock):
)
@asyncio.coroutine
def test_setup(hass, aioclient_mock):
async def test_setup(hass, aioclient_mock):
"""Test setup works if update passes."""
aioclient_mock.get(UPDATE_URL, params={"hostname": DOMAIN}, text="nochg 0.0.0.0")
result = yield from async_setup_component(
result = await async_setup_component(
hass,
no_ip.DOMAIN,
{no_ip.DOMAIN: {"domain": DOMAIN, "username": USERNAME, "password": PASSWORD}},
@@ -53,16 +51,15 @@ def test_setup(hass, aioclient_mock):
assert aioclient_mock.call_count == 1
async_fire_time_changed(hass, utcnow() + timedelta(minutes=5))
yield from hass.async_block_till_done()
await hass.async_block_till_done()
assert aioclient_mock.call_count == 2
@asyncio.coroutine
def test_setup_fails_if_update_fails(hass, aioclient_mock):
async def test_setup_fails_if_update_fails(hass, aioclient_mock):
"""Test setup fails if first update fails."""
aioclient_mock.get(UPDATE_URL, params={"hostname": DOMAIN}, text="nohost")
result = yield from async_setup_component(
result = await async_setup_component(
hass,
no_ip.DOMAIN,
{no_ip.DOMAIN: {"domain": DOMAIN, "username": USERNAME, "password": PASSWORD}},
@@ -71,12 +68,11 @@ def test_setup_fails_if_update_fails(hass, aioclient_mock):
assert aioclient_mock.call_count == 1
@asyncio.coroutine
def test_setup_fails_if_wrong_auth(hass, aioclient_mock):
async def test_setup_fails_if_wrong_auth(hass, aioclient_mock):
"""Test setup fails if first update fails through wrong authentication."""
aioclient_mock.get(UPDATE_URL, params={"hostname": DOMAIN}, text="badauth")
result = yield from async_setup_component(
result = await async_setup_component(
hass,
no_ip.DOMAIN,
{no_ip.DOMAIN: {"domain": DOMAIN, "username": USERNAME, "password": PASSWORD}},