Avoid running final writes in executor in test (#84679)

This commit is contained in:
Joakim Plate
2022-12-28 23:40:11 +01:00
committed by GitHub
parent 345081ba15
commit 5c43f0861f
4 changed files with 10 additions and 7 deletions

View File

@@ -1165,13 +1165,13 @@ def mock_storage(data=None):
# Route through original load so that we trigger migration
loaded = await orig_load(store)
_LOGGER.info("Loading data for %s: %s", store.key, loaded)
_LOGGER.debug("Loading data for %s: %s", store.key, loaded)
return loaded
def mock_write_data(store, path, data_to_write):
async def mock_write_data(store, path, data_to_write):
"""Mock version of write data."""
# To ensure that the data can be serialized
_LOGGER.info("Writing data to %s: %s", store.key, data_to_write)
_LOGGER.debug("Writing data to %s: %s", store.key, data_to_write)
raise_contains_mocks(data_to_write)
data[store.key] = json.loads(json.dumps(data_to_write, cls=store._encoder))
@@ -1184,7 +1184,7 @@ def mock_storage(data=None):
side_effect=mock_async_load,
autospec=True,
), patch(
"homeassistant.helpers.storage.Store._write_data",
"homeassistant.helpers.storage.Store._async_write_data",
side_effect=mock_write_data,
autospec=True,
), patch(