diff --git a/homeassistant/components/config/__init__.py b/homeassistant/components/config/__init__.py index 65a4d50be84..d7a1e641c67 100644 --- a/homeassistant/components/config/__init__.py +++ b/homeassistant/components/config/__init__.py @@ -24,7 +24,6 @@ SECTIONS = ( 'device_registry', 'entity_registry', 'group', - 'hassbian', 'script', ) ON_DEMAND = ('zwave',) diff --git a/homeassistant/components/config/hassbian.py b/homeassistant/components/config/hassbian.py deleted file mode 100644 index c475dc317f7..00000000000 --- a/homeassistant/components/config/hassbian.py +++ /dev/null @@ -1,86 +0,0 @@ -"""Component to interact with Hassbian tools.""" -import json -import os - -from homeassistant.components.http import HomeAssistantView - - -_TEST_OUTPUT = """ -{ - "suites":{ - "libcec":{ - "state":"Uninstalled", - "description":"Installs the libcec package for controlling CEC devices from this Pi" - }, - "mosquitto":{ - "state":"failed", - "description":"Installs the Mosquitto package for setting up a local MQTT server" - }, - "openzwave":{ - "state":"Uninstalled", - "description":"Installs the Open Z-wave package for setting up your zwave network" - }, - "samba":{ - "state":"installing", - "description":"Installs the samba package for sharing the hassbian configuration files over the Pi's network." - } - } -} -""" # noqa - - -async def async_setup(hass): - """Set up the Hassbian config.""" - # Test if is Hassbian - test_mode = 'FORCE_HASSBIAN' in os.environ - is_hassbian = test_mode - - if not is_hassbian: - return False - - hass.http.register_view(HassbianSuitesView(test_mode)) - hass.http.register_view(HassbianSuiteInstallView(test_mode)) - - return True - - -async def hassbian_status(hass, test_mode=False): - """Query for the Hassbian status.""" - # Fetch real output when not in test mode - if test_mode: - return json.loads(_TEST_OUTPUT) - - raise Exception('Real mode not implemented yet.') - - -class HassbianSuitesView(HomeAssistantView): - """Hassbian packages endpoint.""" - - url = '/api/config/hassbian/suites' - name = 'api:config:hassbian:suites' - - def __init__(self, test_mode): - """Initialize suites view.""" - self._test_mode = test_mode - - async def get(self, request): - """Request suite status.""" - inp = await hassbian_status(request.app['hass'], self._test_mode) - - return self.json(inp['suites']) - - -class HassbianSuiteInstallView(HomeAssistantView): - """Hassbian packages endpoint.""" - - url = '/api/config/hassbian/suites/{suite}/install' - name = 'api:config:hassbian:suite' - - def __init__(self, test_mode): - """Initialize suite view.""" - self._test_mode = test_mode - - async def post(self, request, suite): - """Request suite status.""" - # do real install if not in test mode - return self.json({"status": "ok"}) diff --git a/tests/components/config/test_hassbian.py b/tests/components/config/test_hassbian.py deleted file mode 100644 index 547bb612ee4..00000000000 --- a/tests/components/config/test_hassbian.py +++ /dev/null @@ -1,68 +0,0 @@ -"""Test hassbian config.""" -import asyncio -import os -from unittest.mock import patch - -from homeassistant.bootstrap import async_setup_component -from homeassistant.components import config -from homeassistant.components.config.hassbian import ( - HassbianSuitesView, HassbianSuiteInstallView) - - -def test_setup_check_env_prevents_load(hass, loop): - """Test it does not set up hassbian if environment var not present.""" - with patch.dict(os.environ, clear=True), \ - patch.object(config, 'SECTIONS', ['hassbian']), \ - patch('homeassistant.components.http.' - 'HomeAssistantHTTP.register_view') as reg_view: - loop.run_until_complete(async_setup_component(hass, 'config', {})) - assert 'config' in hass.config.components - assert reg_view.called is False - - -def test_setup_check_env_works(hass, loop): - """Test it sets up hassbian if environment var present.""" - with patch.dict(os.environ, {'FORCE_HASSBIAN': '1'}), \ - patch.object(config, 'SECTIONS', ['hassbian']), \ - patch('homeassistant.components.http.' - 'HomeAssistantHTTP.register_view') as reg_view: - loop.run_until_complete(async_setup_component(hass, 'config', {})) - assert 'config' in hass.config.components - assert len(reg_view.mock_calls) == 2 - assert isinstance(reg_view.mock_calls[0][1][0], HassbianSuitesView) - assert isinstance(reg_view.mock_calls[1][1][0], HassbianSuiteInstallView) - - -@asyncio.coroutine -def test_get_suites(hass, hass_client): - """Test getting suites.""" - with patch.dict(os.environ, {'FORCE_HASSBIAN': '1'}), \ - patch.object(config, 'SECTIONS', ['hassbian']): - yield from async_setup_component(hass, 'config', {}) - - client = yield from hass_client() - resp = yield from client.get('/api/config/hassbian/suites') - assert resp.status == 200 - result = yield from resp.json() - - assert 'mosquitto' in result - info = result['mosquitto'] - assert info['state'] == 'failed' - assert info['description'] == \ - 'Installs the Mosquitto package for setting up a local MQTT server' - - -@asyncio.coroutine -def test_install_suite(hass, hass_client): - """Test getting suites.""" - with patch.dict(os.environ, {'FORCE_HASSBIAN': '1'}), \ - patch.object(config, 'SECTIONS', ['hassbian']): - yield from async_setup_component(hass, 'config', {}) - - client = yield from hass_client() - resp = yield from client.post( - '/api/config/hassbian/suites/openzwave/install') - assert resp.status == 200 - result = yield from resp.json() - - assert result == {"status": "ok"}