pulumi/sdk/python/lib/test
Julien d403b24f85
Avoid calling invokes with dependencies on unknown resources (#18141)
Python implementation of https://github.com/pulumi/pulumi/pull/18133

DependsOn for resources is an ordering constraint for register resource
calls. If a resource R1 depends on a resource R2, the register resource
call for R2 will happen after R1. This is ensured by awaiting the URN
for each resource dependency before calling register resource.

For invokes, this causes a problem when running under preview. During
preview, register resource immediately returns with the URN, however
this does not tell us if the resource "exists".

Instead of waiting for the dependency's URN, we wait for the ID. This
tells us that whether a physical resource exists (if the state is in
sync), and we can avoid calling the invoke when it is unknown.

The following example fails without this change:
```python
import pulumi
from pulumi_gcp import organizations, compute

config = pulumi.Config()
billing_account = config.require("billing-account")

project = organizations.Project(
    "project",
    name="project-1234-banana",
    billing_account=billing_account,
    auto_create_network=False,
    deletion_policy="DELETE",
)

zones = compute.get_zones_output(
    region="us-central1",
    project=project.project_id,
    status="UP",
    opts=pulumi.InvokeOutputOptions(depends_on=[project]),
)
pulumi.export("zones", zones)
```
2025-01-06 13:39:35 +00:00
..
automation make python auto api tests work with DIY backend (#18127) 2024-12-30 16:42:07 +00:00
data/lazy_import_test [sdk/python] Workaround lazy module regression (#16038) 2024-04-24 06:53:59 +00:00
dynamic Allow accessing configuration in Python dynamic providers (#17673) 2024-11-07 10:12:24 +00:00
langhost Switch to ruff for linting and formatting (#17882) 2024-12-02 12:41:19 +00:00
provider Switch to ruff for linting and formatting (#17882) 2024-12-02 12:41:19 +00:00
runtime Switch to ruff for linting and formatting (#17882) 2024-12-02 12:41:19 +00:00
__init__.py Fix a couple of issues when projecting Protobuf and UNKNOWN in Python (#1468) 2018-06-06 16:09:07 -07:00
conftest.py Use black to format lib/test (#16028) 2024-04-23 08:29:58 +00:00
helpers.py Switch to ruff for linting and formatting (#17882) 2024-12-02 12:41:19 +00:00
test_broken_dynamic_provider.py Switch to ruff for linting and formatting (#17882) 2024-12-02 12:41:19 +00:00
test_config.py Use black to format lib/test (#16028) 2024-04-23 08:29:58 +00:00
test_deprecated.py Fixing a few pylint errors in the python test folder (#16962) 2024-08-14 08:26:34 +00:00
test_invoke.py Avoid calling invokes with dependencies on unknown resources (#18141) 2025-01-06 13:39:35 +00:00
test_monitor_termination.py Fixing a few pylint errors in the python test folder (#16962) 2024-08-14 08:26:34 +00:00
test_next_serialize.py Switch to ruff for linting and formatting (#17882) 2024-12-02 12:41:19 +00:00
test_output.py Switch to ruff for linting and formatting (#17882) 2024-12-02 12:41:19 +00:00
test_resource.py Switch to ruff for linting and formatting (#17882) 2024-12-02 12:41:19 +00:00
test_runtime_to_json.py Use black to format lib/test (#16028) 2024-04-23 08:29:58 +00:00
test_stack_reference.py Switch to ruff for linting and formatting (#17882) 2024-12-02 12:41:19 +00:00
test_stack_registers_outputs.py Switch to ruff for linting and formatting (#17882) 2024-12-02 12:41:19 +00:00
test_translate_output_properties.py Start mypy linting lib/test (#16040) 2024-04-30 12:54:13 +00:00
test_types_input_type.py Fixing a few pylint errors in the python test folder (#16962) 2024-08-14 08:26:34 +00:00
test_types_input_type_types.py Start mypy linting lib/test (#16040) 2024-04-30 12:54:13 +00:00
test_types_output_type.py Fixing a few pylint errors in the python test folder (#16962) 2024-08-14 08:26:34 +00:00
test_types_resource_types.py Start mypy linting lib/test (#16040) 2024-04-30 12:54:13 +00:00
test_urn.py Use black to format lib/test (#16028) 2024-04-23 08:29:58 +00:00
test_utils.py Start mypy linting lib/test (#16040) 2024-04-30 12:54:13 +00:00