https://pulumi.com logo
Title
s

steep-alligator-79173

07/02/2020, 8:10 AM
Im trying to write some python unittest for the infra. I have this snippet that read config from stack yaml :
Get instance stack config
config_instance = pulumi.Config("instance")
config_instance = pulumi.Config("instance")
When I try to run tests I get:
ERROR: test_core_stack (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_core_stack
Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/loader.py", line 436, in _find_test_path
    module = self._get_module_from_name(name)
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "/Users/pawelmadon/git/a4b/poc/qx-pulumi/core-stack/test_core_stack.py", line 13, in <module>
    import core_stack
  File "/Users/pawelmadon/git/a4b/poc/qx-pulumi/core-stack/core_stack.py", line 54, in <module>
    instance_type=config_instance.require('bastion_size'),
  File "/Users/pawelmadon/git/a4b/poc/qx-pulumi/core-stack/venv/lib/python3.7/site-packages/pulumi/config.py", line 214, in require
    raise ConfigMissingError(self.full_key(key))
pulumi.config.ConfigMissingError: Missing required configuration variable 'instance:bastion_size'
    please set a value using the command `pulumi config set instance:bastion_size <value>`


----------------------------------------------------------------------
Ran 1 test in 0.000s

FAILED (errors=1)
(venv)
How I can import configuration to tests ?
g

gentle-diamond-70147

07/02/2020, 3:15 PM
We don't currently have a way to mock configuration, but Mikhail has provided a workaround for this at https://github.com/pulumi/pulumi/issues/4472#issuecomment-618053293.
📝 1
😛: 1
s

steep-alligator-79173

07/02/2020, 5:29 PM
And how to mock stack reference and outputs from another stack ?