Get rid of mock http component app (#7775)

* Remove mock_http_component from config tests

* Remove mock_http_component_app from emulated hue test
This commit is contained in:
Paulus Schoutsen 2017-05-25 21:13:53 -07:00 committed by GitHub
parent 65c3201fa6
commit 81aaeaaf11
5 changed files with 26 additions and 81 deletions

View file

@ -5,7 +5,6 @@ from unittest.mock import patch
from homeassistant.bootstrap import async_setup_component
from homeassistant.components import config
from tests.common import mock_http_component_app
VIEW_NAME = 'api:config:zwave:device_config'
@ -14,14 +13,10 @@ VIEW_NAME = 'api:config:zwave:device_config'
@asyncio.coroutine
def test_get_device_config(hass, test_client):
"""Test getting device config."""
app = mock_http_component_app(hass)
with patch.object(config, 'SECTIONS', ['zwave']):
yield from async_setup_component(hass, 'config', {})
hass.http.views[VIEW_NAME].register(app.router)
client = yield from test_client(app)
client = yield from test_client(hass.http.app)
def mock_read(path):
"""Mock reading data."""
@ -47,14 +42,10 @@ def test_get_device_config(hass, test_client):
@asyncio.coroutine
def test_update_device_config(hass, test_client):
"""Test updating device config."""
app = mock_http_component_app(hass)
with patch.object(config, 'SECTIONS', ['zwave']):
yield from async_setup_component(hass, 'config', {})
hass.http.views[VIEW_NAME].register(app.router)
client = yield from test_client(app)
client = yield from test_client(hass.http.app)
orig_data = {
'hello.beer': {
@ -94,14 +85,10 @@ def test_update_device_config(hass, test_client):
@asyncio.coroutine
def test_update_device_config_invalid_key(hass, test_client):
"""Test updating device config."""
app = mock_http_component_app(hass)
with patch.object(config, 'SECTIONS', ['zwave']):
yield from async_setup_component(hass, 'config', {})
hass.http.views[VIEW_NAME].register(app.router)
client = yield from test_client(app)
client = yield from test_client(hass.http.app)
resp = yield from client.post(
'/api/config/zwave/device_config/invalid_entity', data=json.dumps({
@ -114,14 +101,10 @@ def test_update_device_config_invalid_key(hass, test_client):
@asyncio.coroutine
def test_update_device_config_invalid_data(hass, test_client):
"""Test updating device config."""
app = mock_http_component_app(hass)
with patch.object(config, 'SECTIONS', ['zwave']):
yield from async_setup_component(hass, 'config', {})
hass.http.views[VIEW_NAME].register(app.router)
client = yield from test_client(app)
client = yield from test_client(hass.http.app)
resp = yield from client.post(
'/api/config/zwave/device_config/hello.beer', data=json.dumps({
@ -134,14 +117,10 @@ def test_update_device_config_invalid_data(hass, test_client):
@asyncio.coroutine
def test_update_device_config_invalid_json(hass, test_client):
"""Test updating device config."""
app = mock_http_component_app(hass)
with patch.object(config, 'SECTIONS', ['zwave']):
yield from async_setup_component(hass, 'config', {})
hass.http.views[VIEW_NAME].register(app.router)
client = yield from test_client(app)
client = yield from test_client(hass.http.app)
resp = yield from client.post(
'/api/config/zwave/device_config/hello.beer', data='not json')