https://pulumi.com logo
#python
Title
# python
g

gorgeous-minister-41131

01/25/2024, 7:34 PM
Does anyone know how to mock the
Awaitable*whatever*Result
's that happen, in python unit tests?
Copy code
class MyMocks(pulumi.runtime.Mocks):
    def new_resource(self, args: pulumi.runtime.MockResourceArgs):
        outputs = args.inputs
        # if args.typ == "aws:route53/getZone:getZone":
        #     outputs = {
        #         **args.inputs,
        #         "zone_id": "TEST",
        #     }
        return [args.name + "_id", outputs]

    def call(self, args: pulumi.runtime.MockCallArgs):
        if args.token == "aws:iam/getPolicyDocument:getPolicyDocument":
            return {"json": json.dumps({})}
        if args.token == "aws:route53/getZone:getZone":
            return {"zone_id": "TEST"}
        return {}
I've even defined this as part of the mocks...
The documentation provides like, one example how to do this with the get_ami ... but I'm using get_zone... and I don't know if there's nuance, or if the fact that that get_zone is using a different provider causes a problem?
does
zone_id
need to be
zoneId
??
OK it does look like that did it. I guess when examining the mocking sample I overlooked the fact that these properties were mixedCase and not snake_case.