Skip to content

Commit

Permalink
AssetSelection.assets (#8316)
Browse files Browse the repository at this point in the history
  • Loading branch information
sryza committed Jun 10, 2022
1 parent 2623403 commit e6fad5b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ class AssetSelection(ABC):
def all() -> "AllAssetSelection":
return AllAssetSelection()

@staticmethod
def assets(*assets_defs: AssetsDefinition) -> "KeysAssetSelection":
return KeysAssetSelection(
*(key for assets_def in assets_defs for key in assets_def.asset_keys)
)

@staticmethod
def keys(*asset_keys: CoerceableToAssetKey) -> "KeysAssetSelection":
_asset_keys = [AssetKey.from_coerceable(key) for key in asset_keys]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ def test_asset_selection_keys(all_assets):
assert sel.resolve(all_assets) == _asset_keys_of({alice, bob})


def test_asset_selection_assets(all_assets):
sel = AssetSelection.assets(alice, bob)
assert sel.resolve(all_assets) == _asset_keys_of({alice, bob})


def test_asset_selection_or(all_assets):
sel = AssetSelection.keys("alice", "bob") | AssetSelection.keys("bob", "candace")
assert sel.resolve(all_assets) == _asset_keys_of({alice, bob, candace})
Expand Down

0 comments on commit e6fad5b

Please sign in to comment.