mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Black
This commit is contained in:
@@ -11,13 +11,8 @@ import homeassistant.components.mailbox as mailbox
|
||||
@pytest.fixture
|
||||
def mock_http_client(hass, hass_client):
|
||||
"""Start the Hass HTTP component."""
|
||||
config = {
|
||||
mailbox.DOMAIN: {
|
||||
'platform': 'demo'
|
||||
}
|
||||
}
|
||||
hass.loop.run_until_complete(
|
||||
async_setup_component(hass, mailbox.DOMAIN, config))
|
||||
config = {mailbox.DOMAIN: {"platform": "demo"}}
|
||||
hass.loop.run_until_complete(async_setup_component(hass, mailbox.DOMAIN, config))
|
||||
return hass.loop.run_until_complete(hass_client())
|
||||
|
||||
|
||||
@@ -29,7 +24,7 @@ def test_get_platforms_from_mailbox(mock_http_client):
|
||||
req = yield from mock_http_client.get(url)
|
||||
assert req.status == 200
|
||||
result = yield from req.json()
|
||||
assert len(result) == 1 and "DemoMailbox" == result[0].get('name', None)
|
||||
assert len(result) == 1 and "DemoMailbox" == result[0].get("name", None)
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
@@ -47,9 +42,8 @@ def test_get_messages_from_mailbox(mock_http_client):
|
||||
def test_get_media_from_mailbox(mock_http_client):
|
||||
"""Get audio from mailbox."""
|
||||
mp3sha = "3f67c4ea33b37d1710f772a26dd3fb43bb159d50"
|
||||
msgtxt = ("Message 1. "
|
||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. ")
|
||||
msgsha = sha1(msgtxt.encode('utf-8')).hexdigest()
|
||||
msgtxt = "Message 1. " "Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
|
||||
msgsha = sha1(msgtxt.encode("utf-8")).hexdigest()
|
||||
|
||||
url = "/api/mailbox/media/DemoMailbox/%s" % (msgsha)
|
||||
req = yield from mock_http_client.get(url)
|
||||
@@ -61,12 +55,10 @@ def test_get_media_from_mailbox(mock_http_client):
|
||||
@asyncio.coroutine
|
||||
def test_delete_from_mailbox(mock_http_client):
|
||||
"""Get audio from mailbox."""
|
||||
msgtxt1 = ("Message 1. "
|
||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. ")
|
||||
msgtxt2 = ("Message 3. "
|
||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. ")
|
||||
msgsha1 = sha1(msgtxt1.encode('utf-8')).hexdigest()
|
||||
msgsha2 = sha1(msgtxt2.encode('utf-8')).hexdigest()
|
||||
msgtxt1 = "Message 1. " "Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
|
||||
msgtxt2 = "Message 3. " "Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
|
||||
msgsha1 = sha1(msgtxt1.encode("utf-8")).hexdigest()
|
||||
msgsha2 = sha1(msgtxt2.encode("utf-8")).hexdigest()
|
||||
|
||||
for msg in [msgsha1, msgsha2]:
|
||||
url = "/api/mailbox/delete/DemoMailbox/%s" % (msg)
|
||||
|
||||
Reference in New Issue
Block a user