Add config message items selector to imap option flow (#115108)

* Update const.py

* Update config_flow.py

* Update coordinator.py

* Update coordinator.py

* Update strings.json

* Update config_flow.py

* Update const.py

* Update coordinator.py

* Update config_flow.py

* Update config_flow.py

* Update test_diagnostics.py

* Update const.py

* Update test_init.py

* Update test_diagnostics.py

* Update test_diagnostics.py

* Update test_diagnostics.py

* Update test_init.py

* Update test_diagnostics.py

* Update test_init.py

* Update test_diagnostics.py

* Update test_diagnostics.py

* Update test_diagnostics.py

* Update test_config_flow.py

* Update config_flow.py

* Update test_config_flow.py

* Update test_init.py

* Update const.py

* Only make text and headers optional

* Add message data tests

* Add message data test

* Update test_config_flow.py

* Update test message data

* Fix ruff

* Fix ruff

* Update test_init.py

* Update strings.json

---------

Co-authored-by: jbouwh <jan@jbsoft.nl>
Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
This commit is contained in:
Luca Angemi 2024-04-08 19:34:50 +02:00 committed by GitHub
parent f23e48f373
commit fc1ebdaaa3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 112 additions and 10 deletions

View file

@ -29,11 +29,13 @@ MOCK_CONFIG = {
"charset": "utf-8",
"folder": "INBOX",
"search": "UnSeen UnDeleted",
"event_message_data": ["text", "headers"],
}
MOCK_OPTIONS = {
"folder": "INBOX",
"search": "UnSeen UnDeleted",
"event_message_data": ["text", "headers"],
}
pytestmark = pytest.mark.usefixtures("mock_setup_entry")
@ -504,6 +506,38 @@ async def test_config_flow_with_cipherlist_and_ssl_verify(
assert len(mock_setup_entry.mock_calls) == 1
@pytest.mark.parametrize("event_message_data", [[], ["headers"], ["text", "headers"]])
async def test_config_flow_with_event_message_data(
hass: HomeAssistant, mock_setup_entry: AsyncMock, event_message_data: list
) -> None:
"""Test with different message data."""
config = MOCK_CONFIG.copy()
config["event_message_data"] = event_message_data
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_USER, "show_advanced_options": False},
)
assert result["type"] is FlowResultType.FORM
assert result["errors"] is None
with patch(
"homeassistant.components.imap.config_flow.connect_to_server"
) as mock_client:
mock_client.return_value.search.return_value = (
"OK",
[b""],
)
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], config
)
await hass.async_block_till_done()
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "email@email.com"
assert result2["data"] == config
assert len(mock_setup_entry.mock_calls) == 1
async def test_config_flow_from_with_advanced_settings(
hass: HomeAssistant, mock_setup_entry: AsyncMock
) -> None: