Add support for arcam fmj receivers (#24621)

* Add arcam_fmj support

* Just use use state in player avoid direct client access

* Avoid leaking exceptions on invalid data

* Fix return value for volume in case of 0

* Mark component as having no coverage

* Add new requirement

* Add myself as maintainer

* Correct linting errors

* Use async_create_task instead of async_add_job

* Use new style string format instead of concat

* Don't call init of base class without init

* Annotate callbacks with @callback

Otherwise they won't be called in loop

* Reduce log level to debug

* Use async_timeout instead of wait_for

* Bump to version of arcam_fmj supporting 3.5

* Fix extra spaces

* Drop somewhat flaky unique_id

* Un-blackify ident to satisy pylint

* Un-blackify ident to satisy pylint

* Move default name calculation to config validation

* Add test folder

* Drop unused code

* Add tests for config flow import
This commit is contained in:
Joakim Plate authored and Martin Hjelmare committed 2019-07-08 17:14:19 +02:00
1 parent f90fe7e628
commit ab832cda71
12 files changed
+644

No files matched your search

+1
View File
@@ -0,0 +1 @@
"""Tests for the arcam_fmj component."""
@@ -0,0 +1,50 @@
"""Tests for the Arcam FMJ config flow module."""
import pytest
from homeassistant import data_entry_flow
from homeassistant.const import CONF_HOST, CONF_PORT
from tests.common import MockConfigEntry, MockDependency
with MockDependency('arcam'), \
MockDependency('arcam.fmj'), \
MockDependency('arcam.fmj.client'):
from homeassistant.components.arcam_fmj import DEVICE_SCHEMA
from homeassistant.components.arcam_fmj.config_flow import (
ArcamFmjFlowHandler)
from homeassistant.components.arcam_fmj.const import DOMAIN
MOCK_HOST = "127.0.0.1"
MOCK_PORT = 1234
MOCK_NAME = "Arcam FMJ"
MOCK_CONFIG = DEVICE_SCHEMA({
CONF_HOST: MOCK_HOST,
CONF_PORT: MOCK_PORT,
})
@pytest.fixture(name="config_entry")
def config_entry_fixture():
"""Create a mock HEOS config entry."""
return MockConfigEntry(
domain=DOMAIN,
data=MOCK_CONFIG,
title=MOCK_NAME,
)
async def test_single_import_only(hass, config_entry):
"""Test form is shown when host not provided."""
config_entry.add_to_hass(hass)
flow = ArcamFmjFlowHandler()
flow.hass = hass
result = await flow.async_step_import(MOCK_CONFIG)
assert result['type'] == data_entry_flow.RESULT_TYPE_ABORT
assert result['reason'] == 'already_setup'
async def test_import(hass):
"""Test form is shown when host not provided."""
flow = ArcamFmjFlowHandler()
flow.hass = hass
result = await flow.async_step_import(MOCK_CONFIG)
assert result['type'] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result['title'] == MOCK_NAME
assert result['data'] == MOCK_CONFIG