fix(init,config_flow): F4 — seed blocks and the import prefill honor the block's shape: ADB only when the block carries an adb host, protocol-only blocks keep adb_enabled off; TestSeedBlockShapeF4 pins all three paths (t32)

This commit is contained in:
James Mackay committed 2026-10-09 08:04:41 +01:00
1 parent 6087566336
commit c20146b08b
3 files changed
+56 -3

No files matched your search

+48
View File
@@ -885,6 +885,54 @@ class TestMacLessDiscoveryF2:
assert len(sys.modules[__name__]._zc_holder.entries) == 1
class TestSeedBlockShapeF4:
"""t32 F4 (rider): protocol-only seed blocks don't force ADB on."""
def test_protocol_only_block_keeps_adb_off(self):
import conftest
import entity_stublib
entity_stublib.install()
if "nsh.init" not in sys.modules:
conftest._load_module("nsh.init", conftest._SHIELD_DIR / "__init__.py")
init_module = sys.modules["nsh.init"]
blocks = init_module._yaml_seed_blocks(
{"name": "Proto", "protocol_host": "shield.local"}
)
assert blocks[0]["adb_enabled"] is False
assert blocks[0]["adb_host"] == ""
def test_adb_block_keeps_adb_on(self):
import conftest
import entity_stublib
entity_stublib.install()
if "nsh.init" not in sys.modules:
conftest._load_module("nsh.init", conftest._SHIELD_DIR / "__init__.py")
init_module = sys.modules["nsh.init"]
blocks = init_module._yaml_seed_blocks(
{"name": "Adb", "adb_host": "10.0.0.31"}
)
assert blocks[0]["adb_enabled"] is True
async def test_protocol_only_import_prefills_adb_off(self):
module = _form_module()
flow = module.NvidiaShieldConfigFlow()
flow.hass = FakeHass("/tmp/nsh-f4")
flow._async_current_entries = lambda: []
result = await flow.async_step_import(
{"name": "Proto", "protocol_host": "shield.local"}
)
assert result["type"] == "form"
assert flow._user_data["adb_enabled"] is False
class TestZeroconfDiscovery:
"""P4-1a: _androidtvremote2._tcp discovery → pre-filled user step."""