Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import unittest
- import pulumi
- class PulumiMocks(pulumi.runtime.Mocks):
- def new_resource(self, type_, name, inputs, provider, id_):
- return [name + "_id", inputs]
- def call(self, token, args, provider):
- if token == "azure:core/getSubscription:getSubscription":
- return {
- "id": "00000000-0000-0000-0000-000000000000",
- "display_name": "subscription",
- }
- elif token == "azure:compute/getSharedImageVersion:getSharedImageVersion":
- return {
- "exclude_from_latest": False,
- }
- else:
- return {}
- pulumi.runtime.set_mocks(PulumiMocks())
- # Now actually import the code that creates resources, and then test it.
- import vm
- MODULES = [vm]
- class TestingMocks(unittest.TestCase):
- def __init__(self, *args, **kwargs):
- super(TestingMocks, self).__init__(*args, **kwargs)
- self.resources = dict()
- def save(args):
- return {args[i]: args[i + 1] for i in range(0, len(args), 2)}
- for module in MODULES:
- for resource in module.__dict__.values():
- if hasattr(resource, "urn"):
- flatten = [s for sublst in resource.__dict__.items() for s in sublst]
- self.resources[resource.urn] = pulumi.Output.all(*flatten).apply(save)
- @pulumi.runtime.test
- def test_show(self):
- print("==================================================================")
- print(self.resources)
- print("==================================================================")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement