Skip to content

Commit

Permalink
remove test name
Browse files Browse the repository at this point in the history
  • Loading branch information
johannkm committed Nov 27, 2023
1 parent 855ec6a commit 610e9fa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def resolve_inner(self, asset_graph: AssetGraph) -> AbstractSet[AssetKey]:

return keys

def resolve_checks_inner(self, asset_graph: AssetGraph) -> AbstractSet[AssetKey]:
def resolve_checks_inner(self, asset_graph: AssetGraph) -> AbstractSet[AssetCheckKey]:
if not self.dagster_dbt_translator.settings.enable_asset_checks:
return set()

Expand All @@ -88,14 +88,17 @@ def resolve_checks_inner(self, asset_graph: AssetGraph) -> AbstractSet[AssetKey]
manifest_json=self.manifest,
):
dbt_resource_props = dbt_nodes[unique_id]
if dbt_resource_props["resource_type"] == "test":
attached_node_unique_id = dbt_resource_props.get("attached_node")
is_generic_test = bool(attached_node_unique_id)
if dbt_resource_props["resource_type"] != "test":
continue
attached_node_unique_id = dbt_resource_props.get("attached_node")
is_generic_test = bool(attached_node_unique_id)

if is_generic_test:
asset_resource_props = dbt_nodes[attached_node_unique_id]
asset_key = self.dagster_dbt_translator.get_asset_key(asset_resource_props)
if not is_generic_test:
continue

keys.add(AssetCheckKey(asset_key, dbt_resource_props["name"]))
asset_resource_props = dbt_nodes[attached_node_unique_id]
asset_key = self.dagster_dbt_translator.get_asset_key(asset_resource_props)

keys.add(AssetCheckKey(asset_key, dbt_resource_props["name"]))

return keys
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
.resolve()
)

with open(manifest_path, "r") as f:
manifest = json.load(f)
manifest = json.loads(manifest_path.read_bytes())


@dbt_assets(manifest=manifest, dagster_dbt_translator=dagster_dbt_translator_with_checks)
Expand Down Expand Up @@ -116,20 +115,6 @@ def test_selection_customers():
}


def test_test_name():
asset_selection = build_dbt_asset_selection([my_dbt_assets], dbt_select="test_name:not_null")
assert asset_selection.resolve(asset_graph) == set()
assert asset_selection.resolve_checks(asset_graph) == {
key for key in ALL_CHECK_KEYS if "not_null" in key.name
}

asset_selection = build_dbt_asset_selection([my_dbt_assets], dbt_exclude="test_name:not_null")
assert asset_selection.resolve(asset_graph) == ALL_ASSET_KEYS
assert asset_selection.resolve_checks(asset_graph) == {
key for key in ALL_CHECK_KEYS if "not_null" not in key.name
}


def test_excluding_tests():
asset_selection = build_dbt_asset_selection(
[my_dbt_assets],
Expand Down

0 comments on commit 610e9fa

Please sign in to comment.