Hi team, may be a basic question. How can I unit t...
# ask-community
a
Hi team, may be a basic question. How can I unit test an Op that logs an asset event using
context.log_event
? Previously I used to yield the materialization and used the return values.
Looks like I need to use graph as shown here ?https://docs.dagster.io/concepts/testing#testing-event-stream
z
You could pass in a MagicMock as your context and use the methods on the mock object to assert that log_event was called with the parameters you expected
o
cc @chris if there are other options here
c
Hey! No need to explicitly mock context -
OpContext
has a
get_events
method that returns the logged asset materializations as a list.
z
oh sweet! TIL