Black
This commit is contained in:
1 parent
da05dfe708
commit
4de97abc3a
2676 files changed
+163166
-140084
No files matched your search
@@ -10,46 +10,43 @@ from homeassistant.util.dt import utcnow
|
||||
|
||||
from tests.common import async_fire_time_changed
|
||||
|
||||
HOST = 'test'
|
||||
DOMAIN = 'bla'
|
||||
PASSWORD = 'abcdefgh'
|
||||
HOST = "test"
|
||||
DOMAIN = "bla"
|
||||
PASSWORD = "abcdefgh"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def setup_namecheapdns(hass, aioclient_mock):
|
||||
"""Fixture that sets up NamecheapDNS."""
|
||||
aioclient_mock.get(namecheapdns.UPDATE_URL, params={
|
||||
'host': HOST,
|
||||
'domain': DOMAIN,
|
||||
'password': PASSWORD,
|
||||
}, text='<interface-response><ErrCount>0</ErrCount></interface-response>')
|
||||
aioclient_mock.get(
|
||||
namecheapdns.UPDATE_URL,
|
||||
params={"host": HOST, "domain": DOMAIN, "password": PASSWORD},
|
||||
text="<interface-response><ErrCount>0</ErrCount></interface-response>",
|
||||
)
|
||||
|
||||
hass.loop.run_until_complete(async_setup_component(
|
||||
hass, namecheapdns.DOMAIN, {
|
||||
'namecheapdns': {
|
||||
'host': HOST,
|
||||
'domain': DOMAIN,
|
||||
'password': PASSWORD,
|
||||
}
|
||||
}))
|
||||
hass.loop.run_until_complete(
|
||||
async_setup_component(
|
||||
hass,
|
||||
namecheapdns.DOMAIN,
|
||||
{"namecheapdns": {"host": HOST, "domain": DOMAIN, "password": PASSWORD}},
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_setup(hass, aioclient_mock):
|
||||
"""Test setup works if update passes."""
|
||||
aioclient_mock.get(namecheapdns.UPDATE_URL, params={
|
||||
'host': HOST,
|
||||
'domain': DOMAIN,
|
||||
'password': PASSWORD
|
||||
}, text='<interface-response><ErrCount>0</ErrCount></interface-response>')
|
||||
aioclient_mock.get(
|
||||
namecheapdns.UPDATE_URL,
|
||||
params={"host": HOST, "domain": DOMAIN, "password": PASSWORD},
|
||||
text="<interface-response><ErrCount>0</ErrCount></interface-response>",
|
||||
)
|
||||
|
||||
result = yield from async_setup_component(hass, namecheapdns.DOMAIN, {
|
||||
'namecheapdns': {
|
||||
'host': HOST,
|
||||
'domain': DOMAIN,
|
||||
'password': PASSWORD,
|
||||
}
|
||||
})
|
||||
result = yield from async_setup_component(
|
||||
hass,
|
||||
namecheapdns.DOMAIN,
|
||||
{"namecheapdns": {"host": HOST, "domain": DOMAIN, "password": PASSWORD}},
|
||||
)
|
||||
assert result
|
||||
assert aioclient_mock.call_count == 1
|
||||
|
||||
@@ -61,18 +58,16 @@ def test_setup(hass, aioclient_mock):
|
||||
@asyncio.coroutine
|
||||
def test_setup_fails_if_update_fails(hass, aioclient_mock):
|
||||
"""Test setup fails if first update fails."""
|
||||
aioclient_mock.get(namecheapdns.UPDATE_URL, params={
|
||||
'host': HOST,
|
||||
'domain': DOMAIN,
|
||||
'password': PASSWORD,
|
||||
}, text='<interface-response><ErrCount>1</ErrCount></interface-response>')
|
||||
aioclient_mock.get(
|
||||
namecheapdns.UPDATE_URL,
|
||||
params={"host": HOST, "domain": DOMAIN, "password": PASSWORD},
|
||||
text="<interface-response><ErrCount>1</ErrCount></interface-response>",
|
||||
)
|
||||
|
||||
result = yield from async_setup_component(hass, namecheapdns.DOMAIN, {
|
||||
'namecheapdns': {
|
||||
'host': HOST,
|
||||
'domain': DOMAIN,
|
||||
'password': PASSWORD,
|
||||
}
|
||||
})
|
||||
result = yield from async_setup_component(
|
||||
hass,
|
||||
namecheapdns.DOMAIN,
|
||||
{"namecheapdns": {"host": HOST, "domain": DOMAIN, "password": PASSWORD}},
|
||||
)
|
||||
assert not result
|
||||
assert aioclient_mock.call_count == 1
|
||||
Reference in new issue
Block a user