This commit is contained in:
Paulus Schoutsen committed 2019-07-31 12:25:30 -07:00
1 parent da05dfe708
commit 4de97abc3a
2676 files changed
+163166 -140084

No files matched your search

+17 -17
View File
@@ -10,16 +10,16 @@ _LOGGER = logging.getLogger(__name__)
async def mbddns_update_mock(domain, password, host, ttl=60, session=None):
"""Mock out mythic beasts updater."""
if password == 'incorrect':
if password == "incorrect":
_LOGGER.error("Updating Mythic Beasts failed: Not authenticated")
return False
if host[0] == '$':
if host[0] == "$":
_LOGGER.error("Updating Mythic Beasts failed: Invalid Character")
return False
return True
@asynctest.mock.patch('mbddns.update', new=mbddns_update_mock)
@asynctest.mock.patch("mbddns.update", new=mbddns_update_mock)
async def test_update(hass):
"""Run with correct values and check true is returned."""
result = await async_setup_component(
@@ -27,16 +27,16 @@ async def test_update(hass):
mythicbeastsdns.DOMAIN,
{
mythicbeastsdns.DOMAIN: {
'domain': 'example.org',
'password': 'correct',
'host': 'hass'
"domain": "example.org",
"password": "correct",
"host": "hass",
}
}
},
)
assert result
@asynctest.mock.patch('mbddns.update', new=mbddns_update_mock)
@asynctest.mock.patch("mbddns.update", new=mbddns_update_mock)
async def test_update_fails_if_wrong_token(hass):
"""Run with incorrect token and check false is returned."""
result = await async_setup_component(
@@ -44,16 +44,16 @@ async def test_update_fails_if_wrong_token(hass):
mythicbeastsdns.DOMAIN,
{
mythicbeastsdns.DOMAIN: {
'domain': 'example.org',
'password': 'incorrect',
'host': 'hass'
"domain": "example.org",
"password": "incorrect",
"host": "hass",
}
}
},
)
assert not result
@asynctest.mock.patch('mbddns.update', new=mbddns_update_mock)
@asynctest.mock.patch("mbddns.update", new=mbddns_update_mock)
async def test_update_fails_if_invalid_host(hass):
"""Run with invalid characters in host and check false is returned."""
result = await async_setup_component(
@@ -61,10 +61,10 @@ async def test_update_fails_if_invalid_host(hass):
mythicbeastsdns.DOMAIN,
{
mythicbeastsdns.DOMAIN: {
'domain': 'example.org',
'password': 'correct',
'host': '$hass'
"domain": "example.org",
"password": "correct",
"host": "$hass",
}
}
},
)
assert not result