From b76bbca47684a6f738fae1b5cb310347f607d98e Mon Sep 17 00:00:00 2001 From: Jeremy Cohen Date: Thu, 30 Sep 2021 06:56:58 -0700 Subject: [PATCH] Rename tests: singular + generic (#3880) * Fix #3347 * Rename data->singular, schema->generic * Rm schema, data flag + tag behavior * Update test FQNs, compiled paths * Add changelog entry automatic commit by git-black, original commits: ca7c1fc4ad3d4b475e8b31da8aceefc22830407a --- core/dbt/clients/jinja.py | 2 +- core/dbt/graph/selector_methods.py | 7 +++---- core/dbt/parser/generic_test_builders.py | 2 +- core/dbt/parser/manifest.py | 2 +- core/dbt/parser/read_files.py | 2 +- core/dbt/parser/schemas.py | 6 ++++-- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/core/dbt/clients/jinja.py b/core/dbt/clients/jinja.py index 315ec21a7e0..9693b8dbfbe 100644 --- a/core/dbt/clients/jinja.py +++ b/core/dbt/clients/jinja.py @@ -599,7 +599,7 @@ def extract_toplevel_blocks( ) -GENERIC_TEST_KWARGS_NAME = '_dbt_generic_test_kwargs' +GENERIC_TEST_KWARGS_NAME = "_dbt_generic_test_kwargs" def add_rendered_test_kwargs( diff --git a/core/dbt/graph/selector_methods.py b/core/dbt/graph/selector_methods.py index 89b3befcb57..634f6f66af5 100644 --- a/core/dbt/graph/selector_methods.py +++ b/core/dbt/graph/selector_methods.py @@ -405,14 +405,13 @@ def search( ) -> Iterator[UniqueId]: search_types: Tuple[Type, ...] # continue supporting 'schema' + 'data' for backwards compatibility - if selector in ('generic', 'schema'): + if selector in ("generic", "schema"): search_types = (ParsedGenericTestNode, CompiledGenericTestNode) - elif selector in ('singular', 'data'): + elif selector in ("singular", "data"): search_types = (ParsedSingularTestNode, CompiledSingularTestNode) else: raise RuntimeException( - f'Invalid test type selector {selector}: expected "generic" or ' - '"singular"' + f'Invalid test type selector {selector}: expected "generic" or ' '"singular"' ) for node, real_node in self.parsed_nodes(included_nodes): diff --git a/core/dbt/parser/generic_test_builders.py b/core/dbt/parser/generic_test_builders.py index 121464d9339..282701a0dd3 100644 --- a/core/dbt/parser/generic_test_builders.py +++ b/core/dbt/parser/generic_test_builders.py @@ -165,7 +165,7 @@ def from_test_block( test: Dict[str, Any], column_name: Optional[str], tags: List[str], - ) -> 'GenericTestBlock': + ) -> "GenericTestBlock": return cls( file=src.file, data=src.data, diff --git a/core/dbt/parser/manifest.py b/core/dbt/parser/manifest.py index 039b3ed2fac..0da9181bdad 100644 --- a/core/dbt/parser/manifest.py +++ b/core/dbt/parser/manifest.py @@ -318,7 +318,7 @@ def load(self): # Load the rest of the files except for schema yaml files parser_types: List[Type[Parser]] = [ - ModelParser, SnapshotParser, AnalysisParser, SingularTestParser, + ModelParser, SeedParser, DocumentationParser, HookParser] for project in self.all_projects.values(): if project.project_name not in project_parser_files: diff --git a/core/dbt/parser/read_files.py b/core/dbt/parser/read_files.py index 56cddd8fdf5..24348ca4f9e 100644 --- a/core/dbt/parser/read_files.py +++ b/core/dbt/parser/read_files.py @@ -143,7 +143,7 @@ def read_files(project, files, parser_files, saved_files): project, files, project.analysis_paths, '.sql', ParseFileType.Analysis, saved_files ) - project_files['SingularTestParser'] = read_files_for_parser( + project_files["SingularTestParser"] = read_files_for_parser( project, files, project.test_paths, '.sql', ParseFileType.SingularTest, saved_files ) diff --git a/core/dbt/parser/schemas.py b/core/dbt/parser/schemas.py index 9519b5bec6c..2d89cdbe55b 100644 --- a/core/dbt/parser/schemas.py +++ b/core/dbt/parser/schemas.py @@ -56,7 +56,7 @@ from dbt.parser.base import SimpleParser from dbt.parser.search import FileBlock from dbt.parser.generic_test_builders import ( - TestBuilder, GenericTestBlock, TargetBlock, YamlBlock, + TestBuilder, TestBlock, Testable ) from dbt.ui import warning_tag @@ -439,7 +439,9 @@ def add_test_node(self, block: GenericTestBlock, node: ParsedGenericTestNode): self.manifest.add_disabled(block.file, node, test_from) def render_with_context( - self, node: ParsedGenericTestNode, config: ContextConfig, + self, + node: ParsedGenericTestNode, + config: ContextConfig, ) -> None: """Given the parsed node and a ContextConfig to use during parsing, collect all the refs that might be squirreled away in the test