Sonos responsiveness improvements + enhancements (#4063)

* Sonos responsiveness improvements (async_ coroutines, event based updating, album art caching) + Better radio station information

* Docstring fixes.

* Docstring fixes.

* Updated SoCo dependency + fixed file permissions.

* Only fetch speaker info if needed.

* PEP8 fixes

* Fixed SoCoMock.get_speaker_info to get test to pass.

* Regenerated requirements_all.txt + async fetching of album art with caching + added http_session to HomeAssistant object.

* Unit test fixed.

* Add blank line as per flake8

* Fixed media image proxy unit test.

* Removed async stuff.

* Removed last remnants of async stuff.
This commit is contained in:
Bjarni Ivarsson authored and Robbie Trencheny committed 2016-11-01 10:42:38 -07:00
1 parent dad54bb993
commit c549ea115d
5 files changed
+390 -99

No files matched your search

+28 -5
View File
@@ -1,6 +1,7 @@
"""The tests for the Demo Media player platform."""
import unittest
from unittest.mock import patch
import asyncio
from homeassistant.bootstrap import setup_component
from homeassistant.const import HTTP_HEADER_HA_AUTH
@@ -8,7 +9,6 @@ import homeassistant.components.media_player as mp
import homeassistant.components.http as http
import requests
import requests_mock
import time
from tests.common import get_test_home_assistant, get_test_instance_port
@@ -260,12 +260,35 @@ class TestMediaPlayerWeb(unittest.TestCase):
"""Stop everything that was started."""
self.hass.stop()
@requests_mock.Mocker(real_http=True)
def test_media_image_proxy(self, m):
def test_media_image_proxy(self):
"""Test the media server image proxy server ."""
fake_picture_data = 'test.test'
m.get('https://graph.facebook.com/v2.5/107771475912710/'
'picture?type=large', text=fake_picture_data)
class MockResponse():
def __init__(self):
self.status = 200
self.headers = {'Content-Type': 'sometype'}
@asyncio.coroutine
def read(self):
return fake_picture_data.encode('ascii')
@asyncio.coroutine
def release(self):
pass
class MockWebsession():
@asyncio.coroutine
def get(self, url):
return MockResponse()
@asyncio.coroutine
def close(self):
pass
self.hass._websession = MockWebsession()
self.hass.block_till_done()
assert setup_component(
self.hass, mp.DOMAIN,
+1 -1
View File
@@ -42,7 +42,7 @@ class SoCoMock():
"""Clear the sleep timer."""
return
def get_speaker_info(self):
def get_speaker_info(self, force):
"""Return a dict with various data points about the speaker."""
return {'serial_number': 'B8-E9-37-BO-OC-BA:2',
'software_version': '32.11-30071',