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

Ben Wilson

07/10/2023, 9:49 PM
Hi there...can someone help me understand how I'm supposed to mock a redshift resource for the purposes of testing? I'm using
Copy code
context = build_op_context(
            resources={
                "database": db,
                "s3": s3_resource.mock_resource("mock gather s3"),
            }
        )
to build the context for my test and need to add a mock redshift resource, but can't quite seem to get the setup right. Thanks!
p

Philip Strnad

07/10/2023, 9:55 PM
Have you tried
ResourceDefinition.mock_resource()
? I've also had success doing it like this:
Copy code
s3_mock = MagicMock()
and then setting
s3_mock
in the resources dict
👍 1
c

chris

07/11/2023, 1:31 AM
The
s3_resource.mock_resource
call that you’re doing is just calling the class method
mock_resource
that Philip mentions above ^. It should be working to provide a mock in place of the resource, an alternative would be to just directly provide a mock. What issues are you running into with it?
4 Views