From db5100b8c76487b3117e5d33b28317a6749b269c Mon Sep 17 00:00:00 2001 From: Mila Page <67295367+VersusFacit@users.noreply.github.com> Date: Wed, 17 Jul 2024 10:22:47 -0700 Subject: [PATCH] Revert "Adap 821/unit test infer wrong datatype (#852)" This reverts commit b510298d752711455997c9050d03d8667fb29539. --- .../unreleased/Fixes-20240625-170324.yaml | 7 -- .../adapter/unit_testing/fixtures.py | 73 ------------------- .../adapter/unit_testing/test_unit_testing.py | 53 -------------- 3 files changed, 133 deletions(-) delete mode 100644 .changes/unreleased/Fixes-20240625-170324.yaml delete mode 100644 tests/functional/adapter/unit_testing/fixtures.py diff --git a/.changes/unreleased/Fixes-20240625-170324.yaml b/.changes/unreleased/Fixes-20240625-170324.yaml deleted file mode 100644 index 316a92b95..000000000 --- a/.changes/unreleased/Fixes-20240625-170324.yaml +++ /dev/null @@ -1,7 +0,0 @@ -kind: Fixes -body: 'Handle unit test fixtures where typing goes wrong from first value in column - being Null. ' -time: 2024-06-25T17:03:24.73937-07:00 -custom: - Author: versusfacit - Issue: "821" diff --git a/tests/functional/adapter/unit_testing/fixtures.py b/tests/functional/adapter/unit_testing/fixtures.py deleted file mode 100644 index 36212dff3..000000000 --- a/tests/functional/adapter/unit_testing/fixtures.py +++ /dev/null @@ -1,73 +0,0 @@ -model_none_value_base = """ -{{ config(materialized="table") }} - -select 1 as id, 'a' as col1 -""" - -model_none_value_model = """ -{{config(materialized="table")}} - -select * from {{ ref('none_value_base') }} -""" - - -test_none_column_value_doesnt_throw_error_csv = """ -unit_tests: - - name: test_simple - - model: none_value_model - given: - - input: ref('none_value_base') - format: csv - rows: | - id,col1 - ,d - ,e - 6,f - - expect: - format: csv - rows: | - id,col1 - ,d - ,e - 6,f -""" - -test_none_column_value_doesnt_throw_error_dct = """ -unit_tests: - - name: test_simple - - model: none_value_model - given: - - input: ref('none_value_base') - rows: - - { "id": , "col1": "d"} - - { "id": , "col1": "e"} - - { "id": 6, "col1": "f"} - - expect: - rows: - - {id: , "col1": "d"} - - {id: , "col1": "e"} - - {id: 6, "col1": "f"} -""" - -test_none_column_value_will_throw_error = """ -unit_tests: - - name: test_simple - - model: none_value_model - given: - - input: ref('none_value_base') - rows: - - { "id": , "col1": "d"} - - { "id": , "col1": "e"} - - { "id": 6, "col1": } - - expect: - rows: - - {id: , "col1": "d"} - - {id: , "col1": "e"} - - {id: 6, "col1": } -""" diff --git a/tests/functional/adapter/unit_testing/test_unit_testing.py b/tests/functional/adapter/unit_testing/test_unit_testing.py index f54a22a88..4d89c4b08 100644 --- a/tests/functional/adapter/unit_testing/test_unit_testing.py +++ b/tests/functional/adapter/unit_testing/test_unit_testing.py @@ -1,19 +1,7 @@ import pytest - -from dbt.exceptions import ParsingError -from dbt.tests.fixtures.project import write_project_files -from dbt.tests.util import run_dbt - from dbt.tests.adapter.unit_testing.test_types import BaseUnitTestingTypes from dbt.tests.adapter.unit_testing.test_case_insensitivity import BaseUnitTestCaseInsensivity from dbt.tests.adapter.unit_testing.test_invalid_input import BaseUnitTestInvalidInput -from tests.functional.adapter.unit_testing.fixtures import ( - model_none_value_base, - model_none_value_model, - test_none_column_value_doesnt_throw_error_csv, - test_none_column_value_doesnt_throw_error_dct, - test_none_column_value_will_throw_error, -) class TestRedshiftUnitTestingTypes(BaseUnitTestingTypes): @@ -46,47 +34,6 @@ def data_types(self): ] -class RedshiftUnitTestingNone: - def test_nones_handled_dict(self, project): - run_dbt(["build"]) - - -class TestRedshiftUnitTestCsvNone(RedshiftUnitTestingNone): - @pytest.fixture(scope="class") - def models(self): - return { - "none_value_base.sql": model_none_value_base, - "none_value_model.sql": model_none_value_model, - "__properties.yml": test_none_column_value_doesnt_throw_error_csv, - } - - -class TestRedshiftUnitTestDictNone(RedshiftUnitTestingNone): - @pytest.fixture(scope="class") - def models(self): - return { - "none_value_base.sql": model_none_value_base, - "none_value_model.sql": model_none_value_model, - "__properties.yml": test_none_column_value_doesnt_throw_error_dct, - } - - -class TestRedshiftUnitTestingTooManyNonesFails: - @pytest.fixture(scope="class") - def models(self): - return { - "__properties.yml": test_none_column_value_will_throw_error, - "none_value_base.sql": model_none_value_base, - "none_value_model.sql": model_none_value_model, - } - - def test_invalid_input(self, project): - with pytest.raises(ParsingError) as e: - run_dbt(["build"]) - - assert "Unit Test fixtures require at least one row free of None" in str(e) - - class TestRedshiftUnitTestCaseInsensitivity(BaseUnitTestCaseInsensivity): pass