I want to write a test for @asset_sensor which has...
# ask-community
s
I want to write a test for @asset_sensor which has context, logEntryEvent as the signature. Are there any examples or utilities for generating EventLogRecords? For testsetup
s
cc @prha
p
For our internal tests, we typically just execute a job that contains the events we want to emit (e.g. asset materialization) against a test instance. For example, you could do something like this (untested snippet):
Copy code
@op
def my_test_op(context):
    # sole purpose is to generate these materializations
    context.log_event(AssetMaterialization(asset_key="foo"))

@job
def my_test_job():
    my_test_op()

with DagsterInstance.ephemeral() as test_instance:
    my_test_job.execute_in_process(instance=test_instance)
    context = build_sensor_context(instance=test_instance)
    result = my_asset_sensor(context)