|
|
|
@ -157,8 +157,10 @@ async def test_setup_with_properties(hass):
|
|
|
|
|
with patchers.PATCH_ADB_DEVICE_TCP, patchers.patch_connect(True)[
|
|
|
|
|
patch_key
|
|
|
|
|
], patchers.patch_shell(response)[patch_key]:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
with patchers.PATCH_DEVICE_PROPERTIES:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
|
|
state = hass.states.get(entity_id)
|
|
|
|
|
assert state is not None
|
|
|
|
|
|
|
|
|
@ -188,8 +190,9 @@ async def test_reconnect(hass, caplog, config):
|
|
|
|
|
], patchers.patch_shell(SHELL_RESPONSE_OFF)[
|
|
|
|
|
patch_key
|
|
|
|
|
], patchers.PATCH_KEYGEN, patchers.PATCH_ANDROIDTV_OPEN, patchers.PATCH_SIGNER:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
with patchers.PATCH_DEVICE_PROPERTIES:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
|
|
await hass.helpers.entity_component.async_update_entity(entity_id)
|
|
|
|
|
state = hass.states.get(entity_id)
|
|
|
|
@ -256,8 +259,10 @@ async def test_adb_shell_returns_none(hass, config):
|
|
|
|
|
], patchers.patch_shell(SHELL_RESPONSE_OFF)[
|
|
|
|
|
patch_key
|
|
|
|
|
], patchers.PATCH_KEYGEN, patchers.PATCH_ANDROIDTV_OPEN, patchers.PATCH_SIGNER:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
with patchers.PATCH_DEVICE_PROPERTIES:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
|
|
await hass.helpers.entity_component.async_update_entity(entity_id)
|
|
|
|
|
state = hass.states.get(entity_id)
|
|
|
|
|
assert state is not None
|
|
|
|
@ -284,8 +289,10 @@ async def test_setup_with_adbkey(hass):
|
|
|
|
|
], patchers.patch_shell(SHELL_RESPONSE_OFF)[
|
|
|
|
|
patch_key
|
|
|
|
|
], patchers.PATCH_ANDROIDTV_OPEN, patchers.PATCH_SIGNER, PATCH_ISFILE, PATCH_ACCESS:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
with patchers.PATCH_DEVICE_PROPERTIES:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
|
|
await hass.helpers.entity_component.async_update_entity(entity_id)
|
|
|
|
|
state = hass.states.get(entity_id)
|
|
|
|
|
assert state is not None
|
|
|
|
@ -317,8 +324,10 @@ async def test_sources(hass, config0):
|
|
|
|
|
with patchers.PATCH_ADB_DEVICE_TCP, patchers.patch_connect(True)[
|
|
|
|
|
patch_key
|
|
|
|
|
], patchers.patch_shell(SHELL_RESPONSE_OFF)[patch_key]:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
with patchers.PATCH_DEVICE_PROPERTIES:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
|
|
await hass.helpers.entity_component.async_update_entity(entity_id)
|
|
|
|
|
state = hass.states.get(entity_id)
|
|
|
|
|
assert state is not None
|
|
|
|
@ -395,8 +404,10 @@ async def _test_exclude_sources(hass, config0, expected_sources):
|
|
|
|
|
with patchers.PATCH_ADB_DEVICE_TCP, patchers.patch_connect(True)[
|
|
|
|
|
patch_key
|
|
|
|
|
], patchers.patch_shell(SHELL_RESPONSE_OFF)[patch_key]:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
with patchers.PATCH_DEVICE_PROPERTIES:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
|
|
await hass.helpers.entity_component.async_update_entity(entity_id)
|
|
|
|
|
state = hass.states.get(entity_id)
|
|
|
|
|
assert state is not None
|
|
|
|
@ -475,8 +486,10 @@ async def _test_select_source(hass, config0, source, expected_arg, method_patch)
|
|
|
|
|
with patchers.PATCH_ADB_DEVICE_TCP, patchers.patch_connect(True)[
|
|
|
|
|
patch_key
|
|
|
|
|
], patchers.patch_shell(SHELL_RESPONSE_OFF)[patch_key]:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
with patchers.PATCH_DEVICE_PROPERTIES:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
|
|
await hass.helpers.entity_component.async_update_entity(entity_id)
|
|
|
|
|
state = hass.states.get(entity_id)
|
|
|
|
|
assert state is not None
|
|
|
|
@ -701,8 +714,10 @@ async def test_setup_fail(hass, config):
|
|
|
|
|
], patchers.patch_shell(SHELL_RESPONSE_OFF)[
|
|
|
|
|
patch_key
|
|
|
|
|
], patchers.PATCH_KEYGEN, patchers.PATCH_ANDROIDTV_OPEN, patchers.PATCH_SIGNER:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id) is False
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
with patchers.PATCH_DEVICE_PROPERTIES:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id) is False
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
|
|
await hass.helpers.entity_component.async_update_entity(entity_id)
|
|
|
|
|
state = hass.states.get(entity_id)
|
|
|
|
|
assert state is None
|
|
|
|
@ -718,8 +733,9 @@ async def test_adb_command(hass):
|
|
|
|
|
with patchers.PATCH_ADB_DEVICE_TCP, patchers.patch_connect(True)[
|
|
|
|
|
patch_key
|
|
|
|
|
], patchers.patch_shell(SHELL_RESPONSE_OFF)[patch_key]:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
with patchers.PATCH_DEVICE_PROPERTIES:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
|
|
with patch(
|
|
|
|
|
"androidtv.basetv.basetv_async.BaseTVAsync.adb_shell", return_value=response
|
|
|
|
@ -747,8 +763,9 @@ async def test_adb_command_unicode_decode_error(hass):
|
|
|
|
|
with patchers.PATCH_ADB_DEVICE_TCP, patchers.patch_connect(True)[
|
|
|
|
|
patch_key
|
|
|
|
|
], patchers.patch_shell(SHELL_RESPONSE_OFF)[patch_key]:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
with patchers.PATCH_DEVICE_PROPERTIES:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
|
|
with patch(
|
|
|
|
|
"androidtv.basetv.basetv_async.BaseTVAsync.adb_shell",
|
|
|
|
@ -776,8 +793,9 @@ async def test_adb_command_key(hass):
|
|
|
|
|
with patchers.PATCH_ADB_DEVICE_TCP, patchers.patch_connect(True)[
|
|
|
|
|
patch_key
|
|
|
|
|
], patchers.patch_shell(SHELL_RESPONSE_OFF)[patch_key]:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
with patchers.PATCH_DEVICE_PROPERTIES:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
|
|
with patch(
|
|
|
|
|
"androidtv.basetv.basetv_async.BaseTVAsync.adb_shell", return_value=response
|
|
|
|
@ -805,8 +823,9 @@ async def test_adb_command_get_properties(hass):
|
|
|
|
|
with patchers.PATCH_ADB_DEVICE_TCP, patchers.patch_connect(True)[
|
|
|
|
|
patch_key
|
|
|
|
|
], patchers.patch_shell(SHELL_RESPONSE_OFF)[patch_key]:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
with patchers.PATCH_DEVICE_PROPERTIES:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
|
|
with patch(
|
|
|
|
|
"androidtv.androidtv.androidtv_async.AndroidTVAsync.get_properties_dict",
|
|
|
|
@ -834,8 +853,9 @@ async def test_learn_sendevent(hass):
|
|
|
|
|
with patchers.PATCH_ADB_DEVICE_TCP, patchers.patch_connect(True)[
|
|
|
|
|
patch_key
|
|
|
|
|
], patchers.patch_shell(SHELL_RESPONSE_OFF)[patch_key]:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
with patchers.PATCH_DEVICE_PROPERTIES:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
|
|
with patch(
|
|
|
|
|
"androidtv.basetv.basetv_async.BaseTVAsync.learn_sendevent",
|
|
|
|
@ -862,8 +882,9 @@ async def test_update_lock_not_acquired(hass):
|
|
|
|
|
with patchers.PATCH_ADB_DEVICE_TCP, patchers.patch_connect(True)[
|
|
|
|
|
patch_key
|
|
|
|
|
], patchers.patch_shell(SHELL_RESPONSE_OFF)[patch_key]:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
with patchers.PATCH_DEVICE_PROPERTIES:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
|
|
with patchers.patch_shell(SHELL_RESPONSE_OFF)[patch_key]:
|
|
|
|
|
await hass.helpers.entity_component.async_update_entity(entity_id)
|
|
|
|
@ -897,8 +918,9 @@ async def test_download(hass):
|
|
|
|
|
with patchers.PATCH_ADB_DEVICE_TCP, patchers.patch_connect(True)[
|
|
|
|
|
patch_key
|
|
|
|
|
], patchers.patch_shell(SHELL_RESPONSE_OFF)[patch_key]:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
with patchers.PATCH_DEVICE_PROPERTIES:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
|
|
# Failed download because path is not whitelisted
|
|
|
|
|
with patch("androidtv.basetv.basetv_async.BaseTVAsync.adb_pull") as patch_pull:
|
|
|
|
@ -943,8 +965,9 @@ async def test_upload(hass):
|
|
|
|
|
with patchers.PATCH_ADB_DEVICE_TCP, patchers.patch_connect(True)[
|
|
|
|
|
patch_key
|
|
|
|
|
], patchers.patch_shell(SHELL_RESPONSE_OFF)[patch_key]:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
with patchers.PATCH_DEVICE_PROPERTIES:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
|
|
# Failed upload because path is not whitelisted
|
|
|
|
|
with patch("androidtv.basetv.basetv_async.BaseTVAsync.adb_push") as patch_push:
|
|
|
|
@ -987,8 +1010,9 @@ async def test_androidtv_volume_set(hass):
|
|
|
|
|
with patchers.PATCH_ADB_DEVICE_TCP, patchers.patch_connect(True)[
|
|
|
|
|
patch_key
|
|
|
|
|
], patchers.patch_shell(SHELL_RESPONSE_OFF)[patch_key]:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
with patchers.PATCH_DEVICE_PROPERTIES:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
|
|
with patch(
|
|
|
|
|
"androidtv.basetv.basetv_async.BaseTVAsync.set_volume_level", return_value=0.5
|
|
|
|
@ -1014,8 +1038,9 @@ async def test_get_image(hass, hass_ws_client):
|
|
|
|
|
with patchers.PATCH_ADB_DEVICE_TCP, patchers.patch_connect(True)[
|
|
|
|
|
patch_key
|
|
|
|
|
], patchers.patch_shell(SHELL_RESPONSE_OFF)[patch_key]:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
with patchers.PATCH_DEVICE_PROPERTIES:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
|
|
with patchers.patch_shell("11")[patch_key]:
|
|
|
|
|
await hass.helpers.entity_component.async_update_entity(entity_id)
|
|
|
|
@ -1090,8 +1115,9 @@ async def test_services_androidtv(hass):
|
|
|
|
|
|
|
|
|
|
with patchers.PATCH_ADB_DEVICE_TCP, patchers.patch_connect(True)[patch_key]:
|
|
|
|
|
with patchers.patch_shell(SHELL_RESPONSE_OFF)[patch_key]:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
with patchers.PATCH_DEVICE_PROPERTIES:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
|
|
with patchers.patch_shell(SHELL_RESPONSE_STANDBY)[patch_key]:
|
|
|
|
|
await _test_service(
|
|
|
|
@ -1136,8 +1162,9 @@ async def test_services_firetv(hass):
|
|
|
|
|
|
|
|
|
|
with patchers.PATCH_ADB_DEVICE_TCP, patchers.patch_connect(True)[patch_key]:
|
|
|
|
|
with patchers.patch_shell(SHELL_RESPONSE_OFF)[patch_key]:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
with patchers.PATCH_DEVICE_PROPERTIES:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
|
|
with patchers.patch_shell(SHELL_RESPONSE_STANDBY)[patch_key]:
|
|
|
|
|
await _test_service(hass, entity_id, SERVICE_MEDIA_STOP, "back")
|
|
|
|
@ -1152,8 +1179,9 @@ async def test_volume_mute(hass):
|
|
|
|
|
|
|
|
|
|
with patchers.PATCH_ADB_DEVICE_TCP, patchers.patch_connect(True)[patch_key]:
|
|
|
|
|
with patchers.patch_shell(SHELL_RESPONSE_OFF)[patch_key]:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
with patchers.PATCH_DEVICE_PROPERTIES:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
|
|
with patchers.patch_shell(SHELL_RESPONSE_STANDBY)[patch_key]:
|
|
|
|
|
service_data = {ATTR_ENTITY_ID: entity_id, ATTR_MEDIA_VOLUME_MUTED: True}
|
|
|
|
@ -1196,8 +1224,9 @@ async def test_connection_closed_on_ha_stop(hass):
|
|
|
|
|
with patchers.PATCH_ADB_DEVICE_TCP, patchers.patch_connect(True)[
|
|
|
|
|
patch_key
|
|
|
|
|
], patchers.patch_shell(SHELL_RESPONSE_OFF)[patch_key]:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
with patchers.PATCH_DEVICE_PROPERTIES:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
|
|
with patch(
|
|
|
|
|
"androidtv.androidtv.androidtv_async.AndroidTVAsync.adb_close"
|
|
|
|
@ -1220,8 +1249,9 @@ async def test_exception(hass):
|
|
|
|
|
], patchers.patch_shell(SHELL_RESPONSE_OFF)[
|
|
|
|
|
patch_key
|
|
|
|
|
], patchers.PATCH_KEYGEN, patchers.PATCH_ANDROIDTV_OPEN, patchers.PATCH_SIGNER:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
with patchers.PATCH_DEVICE_PROPERTIES:
|
|
|
|
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
|
|
await hass.helpers.entity_component.async_update_entity(entity_id)
|
|
|
|
|
state = hass.states.get(entity_id)
|
|
|
|
|