Dear Dagsterians, I am currently struggling in tes...
# ask-community
a
Dear Dagsterians, I am currently struggling in testing my application. I have several assets that have a key_prefix defined. When I want to materialize multiple (upstream and downstream) assets, I would use "materialize_to_memory". However, due to the key_prefix, Dagster does not find the mock ressources provided. How do I need to define the "ressources" attribute so that it knows that "raw" is the key_prefix and "foo_input" the ressource to mock? Example code with only one asset (but in my tests there would be multiple assets to be called including their mock ressources):
@asset(key_prefix=["raw"])
def foo(foo_input):
return "foo" + foo_input
def test_assets_require_service():
result = materialize_to_memory(
[foo],
resources={
"raw.foo_input": mock.MagicMock(),  # this does not work to mock the input of the asset
},
)
assert result.success