diff --git a/pytest_dbt_adapter/sequences/data_test.yml b/pytest_dbt_adapter/sequences/data_test.yml index 7174fd8..579cd69 100644 --- a/pytest_dbt_adapter/sequences/data_test.yml +++ b/pytest_dbt_adapter/sequences/data_test.yml @@ -8,5 +8,5 @@ sequence: length: fact.test.length names: fact.test.names attributes: - passing.fail: false - failing.fail: true + passing.status: pass + failing.status: fail diff --git a/pytest_dbt_adapter/sequences/data_test_ephemeral_models.yml b/pytest_dbt_adapter/sequences/data_test_ephemeral_models.yml index 060d9f3..510c5da 100644 --- a/pytest_dbt_adapter/sequences/data_test_ephemeral_models.yml +++ b/pytest_dbt_adapter/sequences/data_test_ephemeral_models.yml @@ -12,8 +12,8 @@ sequence: length: fact.test.length names: fact.test.names attributes: - passing.fail: false - failing.fail: true + passing.status: pass + failing.status: fail - type: dbt cmd: run - type: run_results diff --git a/pytest_dbt_adapter/spec_file.py b/pytest_dbt_adapter/spec_file.py index d8975dd..0574d82 100644 --- a/pytest_dbt_adapter/spec_file.py +++ b/pytest_dbt_adapter/spec_file.py @@ -271,6 +271,17 @@ def _build_expected_attributes_dict( attributes[name][keypath] = value return attributes + @staticmethod + def _get_name( + unique_id: str + ) -> str: + """ turn a unique_id into just a node name. """ + # The last part of the unique_id is the name + # Example: + # Consider unique_id "test.dbt_test_project.failing" + # Then the name is "failing" + return unique_id.split(".")[-1] + def step_run_results(self, sequence_item, tmpdir): path = os.path.join(tmpdir, 'project', 'target', 'run_results.json') @@ -302,7 +313,8 @@ def step_run_results(self, sequence_item, tmpdir): for result in results: try: - name = result['node']['name'] + unique_id = result['unique_id'] + name = self._get_name(unique_id) except KeyError as exc: raise DBTException( f'Invalid result, missing required key {exc}' @@ -323,8 +335,8 @@ def step_run_results(self, sequence_item, tmpdir): for result in results: try: - node = result['node'] - name = node['name'] + unique_id = result['unique_id'] + name = self._get_name(unique_id) except KeyError as exc: raise DBTException( f'Invalid result, missing required key {exc}'