Skip to content

Commit

Permalink
update error messages for ExternalAssetDependency/ExternalAssetDepend…
Browse files Browse the repository at this point in the history
…edBy (#6748)
  • Loading branch information
OwenKephart committed Feb 23, 2022
1 parent 0c55d96 commit e83b11c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,9 @@ class ExternalAssetDependency(
def __new__(cls, upstream_asset_key: AssetKey, input_name: str = None, output_name: str = None):
check.invariant(
(input_name is None) ^ (output_name is None),
"Exactly one of `input_name` and `output_name` should be supplied",
"When constructing ExternalAssetDependency, exactly one of `input_name` and "
f"`output_name` should be supplied. AssetKey `{upstream_asset_key}` is associated with "
f"input `{input_name}` and output `{output_name}`.",
)
return super(ExternalAssetDependency, cls).__new__(
cls,
Expand All @@ -529,7 +531,9 @@ def __new__(
):
check.invariant(
(input_name is None) ^ (output_name is None),
"Exactly one of `input_name` and `output_name` should be supplied",
"When constructing ExternalAssetDependedBy, exactly one of `input_name` and "
f"`output_name` should be supplied. AssetKey `{downstream_asset_key}` is associated with "
f"input `{input_name}` and output `{output_name}`.",
)
return super(ExternalAssetDependedBy, cls).__new__(
cls,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,22 +530,22 @@ def bar():


def test_input_name_or_output_name_dep_by():
with pytest.raises(CheckError, match="Exactly one"):
with pytest.raises(CheckError, match="input `foo` and output `bar`"):
ExternalAssetDependedBy(
downstream_asset_key=AssetKey("bar"), input_name="foo", output_name="foo"
downstream_asset_key=AssetKey("bar"), input_name="foo", output_name="bar"
)
with pytest.raises(CheckError, match="Exactly one"):
with pytest.raises(CheckError, match="input `None` and output `None`"):
ExternalAssetDependedBy(
downstream_asset_key=AssetKey("bar"), input_name=None, output_name=None
)


def test_input_name_or_output_name_dependency():
with pytest.raises(CheckError, match="Exactly one"):
with pytest.raises(CheckError, match="input `foo` and output `bar`"):
ExternalAssetDependency(
upstream_asset_key=AssetKey("bar"), input_name="foo", output_name="foo"
upstream_asset_key=AssetKey("bar"), input_name="foo", output_name="bar"
)
with pytest.raises(CheckError, match="Exactly one"):
with pytest.raises(CheckError, match="input `None` and output `None`"):
ExternalAssetDependency(
upstream_asset_key=AssetKey("bar"), input_name=None, output_name=None
)
Expand Down

0 comments on commit e83b11c

Please sign in to comment.