https://dagster.io/ logo
#ask-community
Title
# ask-community
a

Arun Kumar

06/02/2022, 12:14 AM
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

Zach

06/02/2022, 3:29 PM
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

owen

06/02/2022, 3:53 PM
cc @chris if there are other options here
c

chris

06/02/2022, 7:51 PM
Hey! No need to explicitly mock context -
OpContext
has a
get_events
method that returns the logged asset materializations as a list.
z

Zach

06/02/2022, 7:52 PM
oh sweet! TIL
4 Views