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

lemon-planet-35664

11/13/2019, 5:31 AM
Hello, newbie here trying to write some unit test similar to this one in python https://www.pulumi.com/blog/testing-your-infrastructure-as-code-with-pulumi/. So i got the test running in pytest and when i tried to assert the output from the s3 bucket that i created, i got a pulumi output object. After some reading it looks like i need to obtain the property using apply but it still doesnt work for me. All i want is to get the id of the s3 bucket that is created :/. Anyone can point me to the right direction?
w

white-balloon-205

11/13/2019, 5:02 PM
The style of unit tests shown in that article run without ever deploying anything - so output properties like
id
will never be populated - and the callbacks to
apply
will never run. This does generally significantly limit the value of this kind of testing - it can be used to verify inputs - but not outputs or behavior. There was a follow up article that shows a technique that can allow running unit tests during updates - which can allow verifying things like this: https://www.pulumi.com/blog/unit-testing-infrastructure-in-nodejs-and-mocha/ But frankly in my experience by far the highest value testing you can have is tests that spin up real infrastructure and validate it before tearing down. These can still be “unit tests” in the sense that they test one component at a time - but they can test the actual correctness of your infrastructure. There’s a great project - Pitfall - for doing this kind of testing with Pulumi in Python - see https://pulumi-community.slack.com/archives/CB36DSVSA/p1573146387034300.
👍 1
l

lemon-planet-35664

11/13/2019, 10:29 PM
Cool thanks for the info
m

mysterious-egg-7415

11/15/2019, 12:08 AM
@lemon-planet-35664 Let me know if you have any questions