Repository: dbt-labs/dbt-core

Issue:
[CT-3146] [Implementation] updating the unit-tests block (to start with test name instead of model)
### Housekeeping

- [X] I am a maintainer of dbt-core

### Short description

From https://github.com/dbt-labs/dbt-core/issues/8606

Current the unit test spec is as follows:

```
unit:
  - model: my_model # name of the model I'm unit testing
    tests:
     - name: test_is_valid_email_address # this is the unique name of the test
       given: # optional: list of inputs to provide as fixtures
        - input: ref('users')
          rows:
           - {user_id: 1, email: cool@example.com,     email_top_level_domain: example.com}
           - {user_id: 2, email: cool@unknown.com,     email_top_level_domain: unknown.com}
           - {user_id: 3, email: badgmail.com,         email_top_level_domain: gmail.com}
           - {user_id: 4, email: missingdot@gmailcom,  email_top_level_domain: gmail.com}
         - input: ref('top_level_domains')
           rows:
            - {tld: example.com}
            - {tld: gmail.com}
       expect: # required: the expected output given the inputs above
        - {user_id: 1, is_valid_email_address: true}
        - {user_id: 2, is_valid_email_address: false}
        - {user_id: 3, is_valid_email_address: false}
        - {user_id: 4, is_valid_email_address: false}
    - name: test_another_column
      ...
```

we should adjust it so that the block is
1. named `unit-tests:` instead of `unit:`
2. starts with the test name instead of the model name

the final spec should look like this:

```
unit-tests:
  - name: test_is_valid_email_address # this is the unique name of the test
    model: my_model # name of the model I'm unit testing
    given: # optional: list of inputs to provide as fixtures
      - input: ref('users')
        rows:
         - {user_id: 1, email: cool@example.com,     email_top_level_domain: example.com}
         - {user_id: 2, email: cool@unknown.com,     email_top_level_domain: unknown.com}
         - {user_id: 3, email: badgmail.com,         email_top_level_domain: gmail.com}
         - {user_id: 4, email: missingdot@gmailcom,  email_top_level_domain: gmail.com}
      - input: ref('top_level_domains')
        rows:
         - {tld: example.com}
         - {tld: gmail.com}
    expect: # required: the expected output given the inputs above
      - {user_id: 1, is_valid_email_address: true}
      - {user_id: 2, is_valid_email_address: false}
      - {user_id: 3, is_valid_email_address: false}
      - {user_id: 4, is_valid_email_address: false}
  - name: test_another_column
    ...
```

### Acceptance criteria

- unit test block is called `unit-tests:`
- unit test block starts with test name (instead of model name)

### Impact to Other Teams

None

### Will backports be required?

No

### Context

_No response_


Discussion:
- changes the hierarchy, which will affect parsing
- already storing by the unit test in the manifest → so no expected manifest structure changes

Resolving patch:
diff --git a/core/dbt/contracts/graph/unparsed.py b/core/dbt/contracts/graph/unparsed.py
--- a/core/dbt/contracts/graph/unparsed.py
+++ b/core/dbt/contracts/graph/unparsed.py
@@ -830,16 +830,11 @@ class UnitTestOverrides(dbtClassMixin):
 
 
 @dataclass
-class UnparsedUnitTestDefinition(dbtClassMixin):
+class UnparsedUnitTest(dbtClassMixin):
     name: str
+    model: str  # name of the model being unit tested
     given: Sequence[UnitTestInputFixture]
     expect: UnitTestOutputFixture
     description: str = ""
     overrides: Optional[UnitTestOverrides] = None
     config: Dict[str, Any] = field(default_factory=dict)
-
-
-@dataclass
-class UnparsedUnitTestSuite(dbtClassMixin):
-    model: str  # name of the model being unit tested
-    tests: Sequence[UnparsedUnitTestDefinition]
diff --git a/core/dbt/parser/partial.py b/core/dbt/parser/partial.py
--- a/core/dbt/parser/partial.py
+++ b/core/dbt/parser/partial.py
@@ -608,7 +608,7 @@ def delete_schema_file(self, file_id):
         self.saved_manifest.files.pop(file_id)
 
     # For each key in a schema file dictionary, process the changed, deleted, and added
-    # elemnts for the key lists
+    # elements for the key lists
     def handle_schema_file_changes(self, schema_file, saved_yaml_dict, new_yaml_dict):
         # loop through comparing previous dict_from_yaml with current dict_from_yaml
         # Need to do the deleted/added/changed thing, just like the files lists
@@ -711,7 +711,6 @@ def _handle_element_change(
     # Take a "section" of the schema file yaml dictionary from saved and new schema files
     # and determine which parts have changed
     def get_diff_for(self, key, saved_yaml_dict, new_yaml_dict):
-        dict_name = "model" if key == "unit_tests" else "name"
         if key in saved_yaml_dict or key in new_yaml_dict:
             saved_elements = saved_yaml_dict[key] if key in saved_yaml_dict else []
             new_elements = new_yaml_dict[key] if key in new_yaml_dict else []
@@ -722,9 +721,9 @@ def get_diff_for(self, key, saved_yaml_dict, new_yaml_dict):
         new_elements_by_name = {}
         # sources have two part names?
         for element in saved_elements:
-            saved_elements_by_name[element[dict_name]] = element
+            saved_elements_by_name[element["name"]] = element
         for element in new_elements:
-            new_elements_by_name[element[dict_name]] = element
+            new_elements_by_name[element["name"]] = element
 
         # now determine which elements, by name, are added, deleted or changed
         saved_element_names = set(saved_elements_by_name.keys())
@@ -754,7 +753,6 @@ def get_diff_for(self, key, saved_yaml_dict, new_yaml_dict):
     # flag indicates that we're processing a schema file, so if a matching
     # patch has already been scheduled, replace it.
     def merge_patch(self, schema_file, key, patch, new_patch=False):
-        elem_name = "model" if key == "unit_tests" else "name"
         if schema_file.pp_dict is None:
             schema_file.pp_dict = {}
         pp_dict = schema_file.pp_dict
@@ -764,7 +762,7 @@ def merge_patch(self, schema_file, key, patch, new_patch=False):
             # check that this patch hasn't already been saved
             found_elem = None
             for elem in pp_dict[key]:
-                if elem["name"] == patch[elem_name]:
+                if elem["name"] == patch["name"]:
                     found_elem = elem
             if not found_elem:
                 pp_dict[key].append(patch)
@@ -773,7 +771,7 @@ def merge_patch(self, schema_file, key, patch, new_patch=False):
                 pp_dict[key].remove(found_elem)
                 pp_dict[key].append(patch)
 
-        schema_file.delete_from_env_vars(key, patch[elem_name])
+        schema_file.delete_from_env_vars(key, patch["name"])
         self.add_to_pp_files(schema_file)
 
     # For model, seed, snapshot, analysis schema dictionary keys,
@@ -942,12 +940,12 @@ def delete_schema_semantic_model(self, schema_file, semantic_model_dict):
                 self.delete_disabled(unique_id, schema_file.file_id)
 
     def delete_schema_unit_test(self, schema_file, unit_test_dict):
-        unit_test_model_name = unit_test_dict["model"]
+        unit_test_name = unit_test_dict["name"]
         unit_tests = schema_file.unit_tests.copy()
         for unique_id in unit_tests:
             if unique_id in self.saved_manifest.unit_tests:
                 unit_test = self.saved_manifest.unit_tests[unique_id]
-                if unit_test.model == unit_test_model_name:
+                if unit_test.name == unit_test_name:
                     self.saved_manifest.unit_tests.pop(unique_id)
                     schema_file.unit_tests.remove(unique_id)
             # No disabled unit tests yet


Test patch:
diff --git a/core/dbt/parser/unit_tests.py b/core/dbt/parser/unit_tests.py
--- a/core/dbt/parser/unit_tests.py
+++ b/core/dbt/parser/unit_tests.py
@@ -13,7 +13,7 @@
     DependsOn,
     UnitTestConfig,
 )
-from dbt.contracts.graph.unparsed import UnparsedUnitTestSuite
+from dbt.contracts.graph.unparsed import UnparsedUnitTest
 from dbt.exceptions import ParsingError, InvalidUnitTestGivenInput
 from dbt.graph import UniqueId
 from dbt.node_types import NodeType
@@ -199,50 +199,50 @@ def __init__(self, schema_parser: SchemaParser, yaml: YamlBlock) -> None:
 
     def parse(self) -> ParseResult:
         for data in self.get_key_dicts():
-            unit_test_suite = self._get_unit_test_suite(data)
-            model_name_split = unit_test_suite.model.split()
-            tested_model_node = self._find_tested_model_node(unit_test_suite)
-
-            for test in unit_test_suite.tests:
-                unit_test_case_unique_id = f"{NodeType.Unit}.{self.project.project_name}.{unit_test_suite.model}.{test.name}"
-                unit_test_fqn = [self.project.project_name] + model_name_split + [test.name]
-                unit_test_config = self._build_unit_test_config(unit_test_fqn, test.config)
-
-                # Check that format and type of rows matches for each given input
-                for input in test.given:
-                    input.validate_fixture("input", test.name)
-                test.expect.validate_fixture("expected", test.name)
-
-                unit_test_definition = UnitTestDefinition(
-                    name=test.name,
-                    model=unit_test_suite.model,
-                    resource_type=NodeType.Unit,
-                    package_name=self.project.project_name,
-                    path=self.yaml.path.relative_path,
-                    original_file_path=self.yaml.path.original_file_path,
-                    unique_id=unit_test_case_unique_id,
-                    given=test.given,
-                    expect=test.expect,
-                    description=test.description,
-                    overrides=test.overrides,
-                    depends_on=DependsOn(nodes=[tested_model_node.unique_id]),
-                    fqn=unit_test_fqn,
-                    config=unit_test_config,
-                )
-                self.manifest.add_unit_test(self.yaml.file, unit_test_definition)
+            unit_test = self._get_unit_test(data)
+            model_name_split = unit_test.model.split()
+            tested_model_node = self._find_tested_model_node(unit_test)
+            unit_test_case_unique_id = (
+                f"{NodeType.Unit}.{self.project.project_name}.{unit_test.model}.{unit_test.name}"
+            )
+            unit_test_fqn = [self.project.project_name] + model_name_split + [unit_test.name]
+            unit_test_config = self._build_unit_test_config(unit_test_fqn, unit_test.config)
+
+            # Check that format and type of rows matches for each given input
+            for input in unit_test.given:
+                input.validate_fixture("input", unit_test.name)
+            unit_test.expect.validate_fixture("expected", unit_test.name)
+
+            unit_test_definition = UnitTestDefinition(
+                name=unit_test.name,
+                model=unit_test.model,
+                resource_type=NodeType.Unit,
+                package_name=self.project.project_name,
+                path=self.yaml.path.relative_path,
+                original_file_path=self.yaml.path.original_file_path,
+                unique_id=unit_test_case_unique_id,
+                given=unit_test.given,
+                expect=unit_test.expect,
+                description=unit_test.description,
+                overrides=unit_test.overrides,
+                depends_on=DependsOn(nodes=[tested_model_node.unique_id]),
+                fqn=unit_test_fqn,
+                config=unit_test_config,
+            )
+            self.manifest.add_unit_test(self.yaml.file, unit_test_definition)
 
         return ParseResult()
 
-    def _get_unit_test_suite(self, data: Dict[str, Any]) -> UnparsedUnitTestSuite:
+    def _get_unit_test(self, data: Dict[str, Any]) -> UnparsedUnitTest:
         try:
-            UnparsedUnitTestSuite.validate(data)
-            return UnparsedUnitTestSuite.from_dict(data)
+            UnparsedUnitTest.validate(data)
+            return UnparsedUnitTest.from_dict(data)
         except (ValidationError, JSONValidationError) as exc:
             raise YamlParseDictError(self.yaml.path, self.key, data, exc)
 
-    def _find_tested_model_node(self, unit_test_suite: UnparsedUnitTestSuite) -> ModelNode:
+    def _find_tested_model_node(self, unit_test: UnparsedUnitTest) -> ModelNode:
         package_name = self.project.project_name
-        model_name_split = unit_test_suite.model.split()
+        model_name_split = unit_test.model.split()
         model_name = model_name_split[0]
         model_version = model_name_split[1] if len(model_name_split) == 2 else None
 
@@ -251,7 +251,7 @@ def _find_tested_model_node(self, unit_test_suite: UnparsedUnitTestSuite) -> Mod
         )
         if not tested_node:
             raise ParsingError(
-                f"Unable to find model '{package_name}.{unit_test_suite.model}' for unit tests in {self.yaml.path.original_file_path}"
+                f"Unable to find model '{package_name}.{unit_test.model}' for unit tests in {self.yaml.path.original_file_path}"
             )
 
         return tested_node
diff --git a/core/dbt/task/unit_test.py b/core/dbt/task/unit_test.py
--- a/core/dbt/task/unit_test.py
+++ b/core/dbt/task/unit_test.py
@@ -67,7 +67,8 @@ def before_execute(self):
         self.print_start_line()
 
     def execute_unit_test(self, node: UnitTestNode, manifest: Manifest) -> UnitTestResultData:
-        # generate_runtime_unit_test_context not strictly needed - this is to run the 'unit' materialization, not compile the node.compield_code
+        # generate_runtime_unit_test_context not strictly needed - this is to run the 'unit'
+        # materialization, not compile the node.compiled_code
         context = generate_runtime_model_context(node, self.config, manifest)
 
         materialization_macro = manifest.find_materialization_macro_by_name(
diff --git a/tests/functional/unit_testing/test_unit_testing.py b/tests/functional/unit_testing/test_unit_testing.py
--- a/tests/functional/unit_testing/test_unit_testing.py
+++ b/tests/functional/unit_testing/test_unit_testing.py
@@ -1,6 +1,6 @@
 import pytest
 from dbt.tests.util import run_dbt, write_file, get_manifest, get_artifact
-from dbt.exceptions import DuplicateResourceNameError, YamlParseDictError, ParsingError
+from dbt.exceptions import DuplicateResourceNameError, ParsingError, YamlParseDictError
 
 my_model_sql = """
 SELECT
@@ -35,78 +35,83 @@
 
 test_my_model_yml = """
 unit_tests:
-  - model: my_model
-    tests:
-      - name: test_my_model
-        given:
-          - input: ref('my_model_a')
-            rows:
-              - {id: 1, a: 1}
-          - input: ref('my_model_b')
-            rows:
-              - {id: 1, b: 2}
-              - {id: 2, b: 2}
-        expect:
-          rows:
-            - {c: 2}
-
-      - name: test_my_model_empty
-        given:
-          - input: ref('my_model_a')
-            rows: []
-          - input: ref('my_model_b')
-            rows:
-              - {id: 1, b: 2}
-              - {id: 2, b: 2}
-        expect:
-          rows: []
-      - name: test_my_model_overrides
-        given:
-          - input: ref('my_model_a')
-            rows:
-              - {id: 1, a: 1}
-          - input: ref('my_model_b')
-            rows:
-              - {id: 1, b: 2}
-              - {id: 2, b: 2}
-        overrides:
-          macros:
-            type_numeric: override
-            invocation_id: 123
-          vars:
-            my_test: var_override
-          env_vars:
-            MY_TEST: env_var_override
-        expect:
-          rows:
-            - {macro_call: override, var_call: var_override, env_var_call: env_var_override, invocation_id: 123}
-      - name: test_my_model_string_concat
-        given:
-          - input: ref('my_model_a')
-            rows:
-              - {id: 1, string_a: a}
-          - input: ref('my_model_b')
-            rows:
-              - {id: 1, string_b: b}
-        expect:
-          rows:
-            - {string_c: ab}
-        config:
-           tags: test_this
+  - name: test_my_model
+    model: my_model
+    given:
+      - input: ref('my_model_a')
+        rows:
+          - {id: 1, a: 1}
+      - input: ref('my_model_b')
+        rows:
+          - {id: 1, b: 2}
+          - {id: 2, b: 2}
+    expect:
+      rows:
+        - {c: 2}
+
+  - name: test_my_model_empty
+    model: my_model
+    given:
+      - input: ref('my_model_a')
+        rows: []
+      - input: ref('my_model_b')
+        rows:
+          - {id: 1, b: 2}
+          - {id: 2, b: 2}
+    expect:
+      rows: []
+
+  - name: test_my_model_overrides
+    model: my_model
+    given:
+      - input: ref('my_model_a')
+        rows:
+          - {id: 1, a: 1}
+      - input: ref('my_model_b')
+        rows:
+          - {id: 1, b: 2}
+          - {id: 2, b: 2}
+    overrides:
+      macros:
+        type_numeric: override
+        invocation_id: 123
+      vars:
+        my_test: var_override
+      env_vars:
+        MY_TEST: env_var_override
+    expect:
+      rows:
+        - {macro_call: override, var_call: var_override, env_var_call: env_var_override, invocation_id: 123}
+
+  - name: test_my_model_string_concat
+    model: my_model
+    given:
+      - input: ref('my_model_a')
+        rows:
+          - {id: 1, string_a: a}
+      - input: ref('my_model_b')
+        rows:
+          - {id: 1, string_b: b}
+    expect:
+      rows:
+        - {string_c: ab}
+    config:
+        tags: test_this
 """
 
 datetime_test = """
-      - name: test_my_model_datetime
-        given:
-          - input: ref('my_model_a')
-            rows:
-              - {id: 1, date_a: "2020-01-01"}
-          - input: ref('my_model_b')
-            rows:
-              - {id: 1}
-        expect:
-          rows:
-            - {date_a: "2020-01-01"}
+  - name: test_my_model_datetime
+    model: my_model
+    given:
+      - input: ref('my_model_a')
+        rows:
+          - {id: 1, date_a: "2020-01-01"}
+      - input: ref('my_model_b')
+        rows:
+          - {id: 1}
+    expect:
+      rows:
+        - {date_a: "2020-01-01"}
 """
 
 
@@ -169,6 +174,8 @@ def test_basic(self, project):
         assert len(unit_test_manifest["nodes"]) == 15
 
         # Check for duplicate unit test name
+        # this doesn't currently pass with partial parsing because of the root problem
+        # described in https://github.com/dbt-labs/dbt-core/issues/8982
         write_file(
             test_my_model_yml + datetime_test + datetime_test,
             project.project_root,
@@ -176,117 +183,121 @@ def test_basic(self, project):
             "test_my_model.yml",
         )
         with pytest.raises(DuplicateResourceNameError):
-            run_dbt(["unit-test", "--select", "my_model"])
+            run_dbt(["run", "--no-partial-parse", "--select", "my_model"])
 
 
 test_my_model_csv_yml = """
 unit_tests:
-  - model: my_model
-    tests:
-      - name: test_my_model
-        given:
-          - input: ref('my_model_a')
-            format: csv
-            rows: |
-              id,a
-              1,1
-          - input: ref('my_model_b')
-            format: csv
-            rows: |
-              id,b
-              1,2
-              2,2
-        expect:
-          format: csv
-          rows: |
-            c
-            2
-
-      - name: test_my_model_empty
-        given:
-          - input: ref('my_model_a')
-            rows: []
-          - input: ref('my_model_b')
-            format: csv
-            rows: |
-              id,b
-              1,2
-              2,2
-        expect:
-          rows: []
-      - name: test_my_model_overrides
-        given:
-          - input: ref('my_model_a')
-            format: csv
-            rows: |
-              id,a
-              1,1
-          - input: ref('my_model_b')
-            format: csv
-            rows: |
-              id,b
-              1,2
-              2,2
-        overrides:
-          macros:
-            type_numeric: override
-            invocation_id: 123
-          vars:
-            my_test: var_override
-          env_vars:
-            MY_TEST: env_var_override
-        expect:
-          rows:
-            - {macro_call: override, var_call: var_override, env_var_call: env_var_override, invocation_id: 123}
-      - name: test_my_model_string_concat
-        given:
-          - input: ref('my_model_a')
-            format: csv
-            rows: |
-              id,string_a
-              1,a
-          - input: ref('my_model_b')
-            format: csv
-            rows: |
-              id,string_b
-              1,b
-        expect:
-          format: csv
-          rows: |
-            string_c
-            ab
-        config:
-           tags: test_this
+  - name: test_my_model
+    model: my_model
+    given:
+      - input: ref('my_model_a')
+        format: csv
+        rows: |
+          id,a
+          1,1
+      - input: ref('my_model_b')
+        format: csv
+        rows: |
+          id,b
+          1,2
+          2,2
+    expect:
+      format: csv
+      rows: |
+        c
+        2
+
+  - name: test_my_model_empty
+    model: my_model
+    given:
+      - input: ref('my_model_a')
+        rows: []
+      - input: ref('my_model_b')
+        format: csv
+        rows: |
+          id,b
+          1,2
+          2,2
+    expect:
+      rows: []
+  - name: test_my_model_overrides
+    model: my_model
+    given:
+      - input: ref('my_model_a')
+        format: csv
+        rows: |
+          id,a
+          1,1
+      - input: ref('my_model_b')
+        format: csv
+        rows: |
+          id,b
+          1,2
+          2,2
+    overrides:
+      macros:
+        type_numeric: override
+        invocation_id: 123
+      vars:
+        my_test: var_override
+      env_vars:
+        MY_TEST: env_var_override
+    expect:
+      rows:
+        - {macro_call: override, var_call: var_override, env_var_call: env_var_override, invocation_id: 123}
+  - name: test_my_model_string_concat
+    model: my_model
+    given:
+      - input: ref('my_model_a')
+        format: csv
+        rows: |
+          id,string_a
+          1,a
+      - input: ref('my_model_b')
+        format: csv
+        rows: |
+          id,string_b
+          1,b
+    expect:
+      format: csv
+      rows: |
+        string_c
+        ab
+    config:
+        tags: test_this
 """
 
 datetime_test_invalid_format = """
-      - name: test_my_model_datetime
-        given:
-          - input: ref('my_model_a')
-            format: xxxx
-            rows:
-              - {id: 1, date_a: "2020-01-01"}
-          - input: ref('my_model_b')
-            rows:
-              - {id: 1}
-        expect:
-          rows:
-            - {date_a: "2020-01-01"}
+  - name: test_my_model_datetime
+    model: my_model
+    given:
+      - input: ref('my_model_a')
+        format: xxxx
+        rows:
+          - {id: 1, date_a: "2020-01-01"}
+      - input: ref('my_model_b')
+        rows:
+          - {id: 1}
+    expect:
+      rows:
+        - {date_a: "2020-01-01"}
 """
 
 datetime_test_invalid_format2 = """
-      - name: test_my_model_datetime
-        given:
-          - input: ref('my_model_a')
-            format: csv
-            rows:
-              - {id: 1, date_a: "2020-01-01"}
-          - input: ref('my_model_b')
-            rows:
-              - {id: 1}
-        expect:
-          rows:
-            - {date_a: "2020-01-01"}
+  - name: test_my_model_datetime
+    model: my_model
+    given:
+      - input: ref('my_model_a')
+        format: csv
+        rows:
+          - {id: 1, date_a: "2020-01-01"}
+      - input: ref('my_model_b')
+        rows:
+          - {id: 1}
+    expect:
+      rows:
+        - {date_a: "2020-01-01"}
 """
 
 
@@ -356,36 +367,36 @@ def test_basic(self, project):
 
 test_my_model_incremental_yml = """
 unit_tests:
-  - model: my_incremental_model
-    tests:
-      - name: incremental_false
-        overrides:
-          macros:
-            is_incremental: false
-        given:
-          - input: ref('events')
-            rows:
-              - {event_time: "2020-01-01", event: 1}
-        expect:
-          rows:
-            - {event_time: "2020-01-01", event: 1}
-      - name: incremental_true
-        overrides:
-          macros:
-            is_incremental: true
-        given:
-          - input: ref('events')
-            rows:
-              - {event_time: "2020-01-01", event: 1}
-              - {event_time: "2020-01-02", event: 2}
-              - {event_time: "2020-01-03", event: 3}
-          - input: this
-            rows:
-              - {event_time: "2020-01-01", event: 1}
-        expect:
-          rows:
-            - {event_time: "2020-01-02", event: 2}
-            - {event_time: "2020-01-03", event: 3}
+  - name: incremental_false
+    model: my_incremental_model
+    overrides:
+      macros:
+        is_incremental: false
+    given:
+      - input: ref('events')
+        rows:
+          - {event_time: "2020-01-01", event: 1}
+    expect:
+      rows:
+        - {event_time: "2020-01-01", event: 1}
+  - name: incremental_true
+    model: my_incremental_model
+    overrides:
+      macros:
+        is_incremental: true
+    given:
+      - input: ref('events')
+        rows:
+          - {event_time: "2020-01-01", event: 1}
+          - {event_time: "2020-01-02", event: 2}
+          - {event_time: "2020-01-03", event: 3}
+      - input: this
+        rows:
+          - {event_time: "2020-01-01", event: 1}
+    expect:
+      rows:
+        - {event_time: "2020-01-02", event: 2}
+        - {event_time: "2020-01-03", event: 3}
 """
 
 
diff --git a/tests/unit/test_unit_test_parser.py b/tests/unit/test_unit_test_parser.py
--- a/tests/unit/test_unit_test_parser.py
+++ b/tests/unit/test_unit_test_parser.py
@@ -12,77 +12,73 @@
 
 UNIT_TEST_MODEL_NOT_FOUND_SOURCE = """
 unit_tests:
-    - model: my_model_doesnt_exist
-      tests:
-        - name: test_my_model_doesnt_exist
-          description: "unit test description"
-          given: []
-          expect:
-            rows:
-              - {a: 1}
+    - name: test_my_model_doesnt_exist
+      model: my_model_doesnt_exist
+      description: "unit test description"
+      given: []
+      expect:
+        rows:
+          - {a: 1}
 """
 
 
 UNIT_TEST_SOURCE = """
 unit_tests:
-    - model: my_model
-      tests:
-        - name: test_my_model
-          description: "unit test description"
-          given: []
-          expect:
-            rows:
-              - {a: 1}
+    - name: test_my_model
+      model: my_model
+      description: "unit test description"
+      given: []
+      expect:
+        rows:
+          - {a: 1}
 """
 
 
 UNIT_TEST_VERSIONED_MODEL_SOURCE = """
 unit_tests:
-    - model: my_model_versioned.v1
-      tests:
-        - name: test_my_model_versioned
-          description: "unit test description"
-          given: []
-          expect:
-            rows:
-              - {a: 1}
+    - name: test_my_model_versioned
+      model: my_model_versioned.v1
+      description: "unit test description"
+      given: []
+      expect:
+        rows:
+          - {a: 1}
 """
 
 
 UNIT_TEST_CONFIG_SOURCE = """
 unit_tests:
-    - model: my_model
-      tests:
-        - name: test_my_model
-          config:
-            tags: "schema_tag"
-            meta:
-              meta_key: meta_value
-              meta_jinja_key: '{{ 1 + 1 }}'
-          description: "unit test description"
-          given: []
-          expect:
-            rows:
-              - {a: 1}
+    - name: test_my_model
+      model: my_model
+      config:
+        tags: "schema_tag"
+        meta:
+          meta_key: meta_value
+          meta_jinja_key: '{{ 1 + 1 }}'
+      description: "unit test description"
+      given: []
+      expect:
+        rows:
+          - {a: 1}
 """
 
 
 UNIT_TEST_MULTIPLE_SOURCE = """
 unit_tests:
-    - model: my_model
-      tests:
-        - name: test_my_model
-          description: "unit test description"
-          given: []
-          expect:
-            rows:
-              - {a: 1}
-        - name: test_my_model2
-          description: "unit test description"
-          given: []
-          expect:
-            rows:
-              - {a: 1}
+    - name: test_my_model
+      model: my_model
+      description: "unit test description"
+      given: []
+      expect:
+        rows:
+          - {a: 1}
+    - name: test_my_model2
+      model: my_model
+      description: "unit test description"
+      given: []
+      expect:
+        rows:
+          - {a: 1}
 """