# ask-community

Adam Ward

06/28/2023, 11:11 PM
Hi - I have a job which runs every hour to collect and report on any/all runs which have failed in the last hour. I am attempting to gather the assets from any job which materializes assets that were affected by the failure and did not successfully materialize. (Yes, I know there's a run failure sensor but it would send an email for each failure during that period while I need a single email containing all failures during that period) To that end, I need to write a unit test which can test fetching context and failure event data from (hopefully mocked) failed assets. Anyone have any suggestions on how I could accomplish this?
🤖 1


06/28/2023, 11:29 PM
Hi Adam, There’s a function called
that’s part of our public API. We use this extensively internally as well. You use it like this:
Copy code
from dagster import instance_for_test

with instance_for_test() as instance:
You can use this approach to populate the test instance with various failed runs. This should allow you to set it up appropriately to test your job.

Adam Ward

06/29/2023, 8:50 PM
That is fantastic! Thank you!
Are the event logs all in memory or are they stored in the same default Sqlite DB?