context
Test context builder that validates against the asset definition.
Prevents tests from silently injecting partition_key for non-partitioned assets (or omitting it for partitioned ones), which would mask wiring bugs that only surface at runtime.
build_asset_context_for(asset_fn, *, partition_key=None)
¶
Build an AssetExecutionContext that is consistent with asset_fn's definition.
Raises ValueError when:
* partition_key is supplied but the asset has no partitions_def
* partition_key is omitted but the asset declares a partitions_def
Usage::
with build_asset_context_for(building_surfaces, partition_key="10/434/716") as ctx:
result = building_surfaces(ctx, ...)
Source code in packages/common/src/bag3d/common/testing/context.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |