Avoid running final writes in executor in test (#84679)
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user