Adjust logging for OptionsFlow deprecation (#130360)
This commit is contained in:
parent
e388e9f396
commit
f1ce7ee8ce
3 changed files with 14 additions and 10 deletions
|
@ -318,7 +318,6 @@ class OptionsFlowHandler(OptionsFlow, ABC):
|
|||
self.start_task: asyncio.Task | None = None
|
||||
self.stop_task: asyncio.Task | None = None
|
||||
self._zha_migration_mgr: ZhaMultiPANMigrationHelper | None = None
|
||||
self.config_entry = config_entry
|
||||
self.original_addon_config: dict[str, Any] | None = None
|
||||
self.revert_reason: str | None = None
|
||||
|
||||
|
|
|
@ -3158,11 +3158,12 @@ class OptionsFlow(ConfigEntryBaseFlow):
|
|||
@config_entry.setter
|
||||
def config_entry(self, value: ConfigEntry) -> None:
|
||||
"""Set the config entry value."""
|
||||
report(
|
||||
report_usage(
|
||||
"sets option flow config_entry explicitly, which is deprecated "
|
||||
"and will stop working in 2025.12",
|
||||
error_if_integration=False,
|
||||
error_if_core=True,
|
||||
core_behavior=ReportBehavior.ERROR,
|
||||
core_integration_behavior=ReportBehavior.ERROR,
|
||||
custom_integration_behavior=ReportBehavior.LOG,
|
||||
)
|
||||
self._config_entry = value
|
||||
|
||||
|
|
|
@ -7501,6 +7501,7 @@ async def test_options_flow_config_entry(
|
|||
assert result["reason"] == "abort"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("integration_frame_path", ["custom_components/my_integration"])
|
||||
@pytest.mark.usefixtures("mock_integration_frame")
|
||||
@patch.object(frame, "_REPORTED_INTEGRATIONS", set())
|
||||
async def test_options_flow_deprecated_config_entry_setter(
|
||||
|
@ -7509,13 +7510,15 @@ async def test_options_flow_deprecated_config_entry_setter(
|
|||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test that setting config_entry explicitly still works."""
|
||||
original_entry = MockConfigEntry(domain="hue", data={})
|
||||
original_entry = MockConfigEntry(domain="my_integration", data={})
|
||||
original_entry.add_to_hass(hass)
|
||||
|
||||
mock_setup_entry = AsyncMock(return_value=True)
|
||||
|
||||
mock_integration(hass, MockModule("hue", async_setup_entry=mock_setup_entry))
|
||||
mock_platform(hass, "hue.config_flow", None)
|
||||
mock_integration(
|
||||
hass, MockModule("my_integration", async_setup_entry=mock_setup_entry)
|
||||
)
|
||||
mock_platform(hass, "my_integration.config_flow", None)
|
||||
|
||||
class TestFlow(config_entries.ConfigFlow):
|
||||
"""Test flow."""
|
||||
|
@ -7549,15 +7552,16 @@ async def test_options_flow_deprecated_config_entry_setter(
|
|||
|
||||
return _OptionsFlow(config_entry)
|
||||
|
||||
with mock_config_flow("hue", TestFlow):
|
||||
with mock_config_flow("my_integration", TestFlow):
|
||||
result = await hass.config_entries.options.async_init(original_entry.entry_id)
|
||||
|
||||
options_flow = hass.config_entries.options._progress.get(result["flow_id"])
|
||||
assert options_flow.config_entry is original_entry
|
||||
|
||||
assert (
|
||||
"Detected that integration 'hue' sets option flow config_entry explicitly, "
|
||||
"which is deprecated and will stop working in 2025.12" in caplog.text
|
||||
"Detected that custom integration 'my_integration' sets option flow "
|
||||
"config_entry explicitly, which is deprecated and will stop working "
|
||||
"in 2025.12" in caplog.text
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue