From df2f066796fbaf49ca528fae31504af32b8d205d Mon Sep 17 00:00:00 2001 From: Peter Allen Webb Date: Wed, 19 Oct 2022 15:48:58 -0400 Subject: [PATCH] CT-1099: Migrate test 071_commented_yaml_regression_3568_tests --- .../models/schema.yml | 3 --- .../test_all_comment_yml_files.py | 20 ------------------- tests/functional/schema_tests/fixtures.py | 4 ++++ .../schema_tests/test_schema_v2_tests.py | 19 ++++++++++++++++++ 4 files changed, 23 insertions(+), 23 deletions(-) delete mode 100644 test/integration/071_commented_yaml_regression_3568_tests/models/schema.yml delete mode 100644 test/integration/071_commented_yaml_regression_3568_tests/test_all_comment_yml_files.py diff --git a/test/integration/071_commented_yaml_regression_3568_tests/models/schema.yml b/test/integration/071_commented_yaml_regression_3568_tests/models/schema.yml deleted file mode 100644 index 35ab0fade65..00000000000 --- a/test/integration/071_commented_yaml_regression_3568_tests/models/schema.yml +++ /dev/null @@ -1,3 +0,0 @@ -# models/schema.yml -# only comments here -# https://github.com/dbt-labs/dbt-core/issues/3568 \ No newline at end of file diff --git a/test/integration/071_commented_yaml_regression_3568_tests/test_all_comment_yml_files.py b/test/integration/071_commented_yaml_regression_3568_tests/test_all_comment_yml_files.py deleted file mode 100644 index c9f6b2d99f1..00000000000 --- a/test/integration/071_commented_yaml_regression_3568_tests/test_all_comment_yml_files.py +++ /dev/null @@ -1,20 +0,0 @@ -from test.integration.base import DBTIntegrationTest, use_profile - - -class TestAllCommentYMLIsOk(DBTIntegrationTest): - @property - def schema(self): - return "071_commented_yaml" - - @property - def models(self): - return "models" - - @use_profile('postgres') - def test_postgres_parses_with_all_comment_yml(self): - try: - self.run_dbt(['parse']) - except TypeError: - assert False, '`dbt parse` failed with a yaml file that is all comments with the same exception as 3568' - except: - assert False, '`dbt parse` failed with a yaml file that is all comments' diff --git a/tests/functional/schema_tests/fixtures.py b/tests/functional/schema_tests/fixtures.py index 40fe9f5a086..7e0dfbaca58 100644 --- a/tests/functional/schema_tests/fixtures.py +++ b/tests/functional/schema_tests/fixtures.py @@ -536,6 +536,10 @@ """ +all_quotes_schema__schema_yml = """# models/schema.yml +# only comments here, which should be okay! +# https://github.com/dbt-labs/dbt-core/issues/3568""" + models_v2__render_test_cli_arg_models__schema_yml = """ version: 2 diff --git a/tests/functional/schema_tests/test_schema_v2_tests.py b/tests/functional/schema_tests/test_schema_v2_tests.py index 07c3b87e63e..00c14cd711b 100644 --- a/tests/functional/schema_tests/test_schema_v2_tests.py +++ b/tests/functional/schema_tests/test_schema_v2_tests.py @@ -93,6 +93,7 @@ macro_resolution_order_models__config_yml, macro_resolution_order_models__my_model_sql, alt_local_utils__macros__type_timestamp_sql, + all_quotes_schema__schema_yml, ) from dbt.exceptions import ParsingException, CompilationException from dbt.contracts.results import TestStatus @@ -991,6 +992,24 @@ def test_invalid_schema_file( assert re.search(r"'models' is not a list", str(exc)) +class TestCommentedSchema: + @pytest.fixture(scope="class") + def models(self): + return { + "schema.yml": all_quotes_schema__schema_yml, + "model.sql": invalid_schema_models__model_sql, + } + + def test_quoted_schema_file(self, project): + try: + # A schema file consisting entirely of quotes should not be a problem + run_dbt(['parse']) + except TypeError: + assert False, '`dbt parse` failed with a yaml file that is all comments with the same exception as 3568' + except Exception: + assert False, '`dbt parse` failed with a yaml file that is all comments' + + class TestWrongSpecificationBlock: @pytest.fixture(scope="class") def models(self):