Following the unit testing at <https://www.pulumi....
# python
f
Following the unit testing at https://www.pulumi.com/docs/guides/testing/unit/ and I am failing to understand how to Mock simple API calls. My IaC has
region = aws.get_region()
as one of the first API calls.
Copy code
class PulumiMocks(pulumi.runtime.Mocks):
    def new_resource(self, args: pulumi.runtime.MockResourceArgs):
        print("new_resource")
        return [args.name + '_id', args.inputs]

    def call(self, args: pulumi.runtime.MockCallArgs):
        print(f"XXXXX call:")
        return {}
Narrowed down
aws.get_region()
invokes the Mocks
call(self, args: pulumi.runtime.MockCallArgs):
how do I extract that I am calling get_region() and return my Mock values? Maybe I’m missing something? I thought I would be able to add
get_region()
method to the PulumiMocks() class? Any help would be appreciated.
e
the args.token member will be set to "aws:get_region" (I think, something like that at any rate), then you can just return a dictionary with the return values filled in, something like
{"name": "us-west-2"}