# Buggy code
def parse_models_entry(self, model_dict, path, package_name, root_dir):
    model_name = model_dict["name"]
    refs = ParserRef()
    for column in model_dict.get("columns", []):
        column_tests = self._parse_column(
            model_dict, column, package_name, root_dir, path, refs
        )
        for node in column_tests:
            yield "test", node

    for test in model_dict.get("tests", []):
        try:
            node = self.build_test_node(model_dict, package_name, test, root_dir, path)
        except dbt.exceptions.CompilationException as exc:
            dbt.exceptions.warn_or_error("in {}: {}".format(path, exc.msg), test)
            continue
        yield "test", node

    context = {"doc": dbt.context.parser.docs(model_dict, refs.docrefs)}
    description = model_dict.get("description", "")
    get_rendered(description, context)

    patch = ParsedNodePatch(
        name=model_name,
        original_file_path=path,
        description=description,
        columns=refs.column_info,
        docrefs=refs.docrefs,
    )
    yield "patch", patch


# Traceback (TypeError)
2019-02-27 12:11:45,010 (MainThread): Parsing test.dbt_utils.at_least_one_eng_active_subs_next_fy_earliest_subscription_engagement_date
2019-02-27 12:11:45,014 (MainThread): Flushing usage events
2019-02-27 12:11:45,014 (MainThread): Encountered an error:
2019-02-27 12:11:45,014 (MainThread): list indices must be integers or slices, not dict
2019-02-27 12:11:45,019 (MainThread): Traceback (most recent call last):
File "/usr/local/Cellar/dbt/0.12.2/libexec/lib/python3.7/site-packages/dbt/main.py", line 77, in main
results, succeeded = handle_and_check(args)
File "/usr/local/Cellar/dbt/0.12.2/libexec/lib/python3.7/site-packages/dbt/main.py", line 151, in handle_and_check
task, res = run_from_args(parsed)
File "/usr/local/Cellar/dbt/0.12.2/libexec/lib/python3.7/site-packages/dbt/main.py", line 207, in run_from_args
results = run_from_task(task, cfg, parsed)
File "/usr/local/Cellar/dbt/0.12.2/libexec/lib/python3.7/site-packages/dbt/main.py", line 215, in run_from_task
result = task.run()
File "/usr/local/Cellar/dbt/0.12.2/libexec/lib/python3.7/site-packages/dbt/task/test.py", line 43, in run
results = RunManager(self.config, query, TestRunner).run()
File "/usr/local/Cellar/dbt/0.12.2/libexec/lib/python3.7/site-packages/dbt/runner.py", line 37, in __init__
manifest, linker = self.compile(self.config)
File "/usr/local/Cellar/dbt/0.12.2/libexec/lib/python3.7/site-packages/dbt/runner.py", line 216, in compile
return compiler.compile()
File "/usr/local/Cellar/dbt/0.12.2/libexec/lib/python3.7/site-packages/dbt/compilation.py", line 246, in compile
manifest = dbt.loader.GraphLoader.load_all(self.config, all_projects)
File "/usr/local/Cellar/dbt/0.12.2/libexec/lib/python3.7/site-packages/dbt/loader.py", line 140, in load_all
return cls(project_config, all_projects).load()
File "/usr/local/Cellar/dbt/0.12.2/libexec/lib/python3.7/site-packages/dbt/loader.py", line 122, in load
self._load_schema_tests()
File "/usr/local/Cellar/dbt/0.12.2/libexec/lib/python3.7/site-packages/dbt/loader.py", line 101, in _load_schema_tests
relative_dirs=project.source_paths
File "/usr/local/Cellar/dbt/0.12.2/libexec/lib/python3.7/site-packages/dbt/parser/schemas.py", line 459, in load_and_parse
for result_type, node in v2_results:
File "/usr/local/Cellar/dbt/0.12.2/libexec/lib/python3.7/site-packages/dbt/parser/schemas.py", line 381, in parse_v2_yml
for node_type, node in iterator:
File "/usr/local/Cellar/dbt/0.12.2/libexec/lib/python3.7/site-packages/dbt/parser/schemas.py", line 421, in parse_model
test_args, root_dir, path)
File "/usr/local/Cellar/dbt/0.12.2/libexec/lib/python3.7/site-packages/dbt/parser/schemas.py", line 226, in build_node
original_file_path)
File "/usr/local/Cellar/dbt/0.12.2/libexec/lib/python3.7/site-packages/dbt/parser/schemas.py", line 159, in build_unparsed_node
test_args)
File "/usr/local/Cellar/dbt/0.12.2/libexec/lib/python3.7/site-packages/dbt/parser/schemas.py", line 75, in build_test_raw_sql
kwargs = [as_kwarg(key, test_args[key]) for key in sorted(test_args)]
File "/usr/local/Cellar/dbt/0.12.2/libexec/lib/python3.7/site-packages/dbt/parser/schemas.py", line 75, in <listcomp>
kwargs = [as_kwarg(key, test_args[key]) for key in sorted(test_args)]
TypeError: list indices must be integers or slices, not dict

# Fixed code
def parse_models_entry(self, model_dict, path, package_name, root_dir):
    model_name = model_dict["name"]
    refs = ParserRef()
    for column in model_dict.get("columns", []):
        column_tests = self._parse_column(
            model_dict, column, package_name, root_dir, path, refs
        )
        for node in column_tests:
            yield "test", node

    for test in model_dict.get("tests", []):
        try:
            node = self.build_test_node(model_dict, package_name, test, root_dir, path)
        except dbt.exceptions.CompilationException as exc:
            dbt.exceptions.warn_or_error(
                "Compilation warning: Invalid test config given in {}:\n\t{}".format(
                    path, exc.msg
                ),
                None,
            )
            continue
        yield "test", node

    context = {"doc": dbt.context.parser.docs(model_dict, refs.docrefs)}
    description = model_dict.get("description", "")
    get_rendered(description, context)

    patch = ParsedNodePatch(
        name=model_name,
        original_file_path=path,
        description=description,
        columns=refs.column_info,
        docrefs=refs.docrefs,
    )
    yield "patch", patch