might have found a bug in pulumis python test setu...
# general
d
might have found a bug in pulumis python test setup - seems to be related to helm template rendering - who is available to discuss this
e
Feel free to open a github issue to discuss it. We've got the community summit currently running so probably don't have anyone synchronously available.
d
ill be happy to report it to github, - but could also be a simple error on my behalf tho. running a simple unittest script:
Copy code
import unittest
import pulumi

class MyMocks(pulumi.runtime.Mocks):
    def new_resource(self, args: pulumi.runtime.MockResourceArgs):
        return [args.name + '_id', args.inputs]
    def call(self, args: pulumi.runtime.MockCallArgs):
        return {}

pulumi.runtime.set_mocks(MyMocks())

import infrastructure.infrastructure as infrastructure

class TestingWithMocks(unittest.TestCase):

    @pulumi.runtime.test
    def test_kms_key(self):        
        def check_deletionwindow(args):
            deletionwindow = args[0]
            shouldbe = 10
            self.assertEqual(deletionwindow, shouldbe, "deletion windows must be = '10'")

        return pulumi.Output.all(infrastructure.kmskey.deletion_window_in_days).apply(check_deletionwindow)
where my infrastructure does aws resources and kubernetes helm resource rendering the error reported by pytest is (seems to be failing at rendering a helm chart):
Copy code
...
------
x = '{"namespace": "vault_id", "include_test_hook_resources": null, "skip_crd_rendering": null, "skip_await": null, "value... "1.15.8", "fetch_opts": {"repo": "<https://kubernetes-charts.banzaicloud.com>"}, "release_name": "banzaivaultinjector"}'

>   objects = json_opts.apply(lambda x: pulumi.runtime.invoke('kubernetes:helm:template',
                                                              {'jsonOpts': x}, invoke_opts).value['result'])
E   TypeError: 'NoneType' object is not subscriptable

../../../.local/lib/python3.8/site-packages/pulumi_kubernetes/helm/v3/helm.py:598: TypeError
============ short test summary info ==========================
FAILED test_unittest.py::TestingWithMocks::test_kms_key - TypeError: 'NoneType' object is not subscriptable
============ 1 failed, 58 warnings in 7.21s =======================
the helm render it seems to be failing at is here (snippet from my infrastructure.py)
Copy code
banzaivaultinjectorchart = Chart(
    "banzaivaultinjector", 
    ChartOpts(
        chart="vault-secrets-webhook",
        version="1.15.8",
        namespace=namespace.id,
        fetch_opts= FetchOpts(
            repo="<https://kubernetes-charts.banzaicloud.com>",
        ),
        values={"debug": False}
    ),
    ResourceOptions(provider=k8s_provider, depends_on=[vaultchart], custom_timeouts=CustomTimeouts(create='1m'))
)
theres a dependency on a previous chart (hashicorp vault), and using a simple kubeconfig context provider
if you want this info copy pasted to github ill be happy to do so
v
I’ve faced the same issue but for yaml.ConfigFile resource. in the line:
Copy code
__ret__ = pulumi.runtime.invoke('kubernetes:yaml:decode', {'text': text}, invoke_opts).value['result']
Seems that the issue might be related to the fact that those resources based of
pulumi.ComponentResource
.
e
Yeh can you raise this on github, I don't know the unit testing library well enough for say for sure if this is a bug or user error, but it looks like its probably a bug with handling component vs custom calls.