mirror of
https://github.com/home-assistant/core.git
synced 2025-11-13 04:50:17 +00:00
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:
@@ -674,6 +674,41 @@ async def test_message_is_truncated(
|
||||
assert len(event_data["text"]) == 3
|
||||
|
||||
|
||||
@pytest.mark.parametrize("imap_search", [TEST_SEARCH_RESPONSE])
|
||||
@pytest.mark.parametrize(
|
||||
"imap_fetch", [(TEST_FETCH_RESPONSE_TEXT_PLAIN)], ids=["plain"]
|
||||
)
|
||||
@pytest.mark.parametrize("imap_has_capability", [True, False], ids=["push", "poll"])
|
||||
@pytest.mark.parametrize("event_message_data", [[], ["text"], ["text", "headers"]])
|
||||
async def test_message_data(
|
||||
hass: HomeAssistant,
|
||||
mock_imap_protocol: MagicMock,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
event_message_data: list,
|
||||
) -> None:
|
||||
"""Test with different message data."""
|
||||
event_called = async_capture_events(hass, "imap_content")
|
||||
|
||||
config = MOCK_CONFIG.copy()
|
||||
# Mock different message data
|
||||
config["event_message_data"] = event_message_data
|
||||
config_entry = MockConfigEntry(domain=DOMAIN, data=config)
|
||||
config_entry.add_to_hass(hass)
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
# Make sure we have had one update (when polling)
|
||||
async_fire_time_changed(hass, utcnow() + timedelta(seconds=5))
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("sensor.imap_email_email_com")
|
||||
# We should have received one message
|
||||
assert state is not None
|
||||
assert state.state == "1"
|
||||
assert len(event_called) == 1
|
||||
|
||||
event_data = event_called[0].data
|
||||
assert set(event_message_data).issubset(set(event_data))
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("imap_search", "imap_fetch"),
|
||||
[(TEST_SEARCH_RESPONSE, TEST_FETCH_RESPONSE_TEXT_PLAIN)],
|
||||
|
||||
Reference in New Issue
Block a user