From 24472a63970671372e01f096a1911b6ce1375302 Mon Sep 17 00:00:00 2001 From: matt-winkler Date: Mon, 21 Oct 2024 10:20:17 -0600 Subject: [PATCH] maybe this is runnable? --- .../functional/python_model_tests/fixtures.py | 30 ------------- .../test_override_dataproc_project.py | 44 +++++++------------ 2 files changed, 16 insertions(+), 58 deletions(-) delete mode 100644 tests/functional/python_model_tests/fixtures.py diff --git a/tests/functional/python_model_tests/fixtures.py b/tests/functional/python_model_tests/fixtures.py deleted file mode 100644 index 24cfcfdbc..000000000 --- a/tests/functional/python_model_tests/fixtures.py +++ /dev/null @@ -1,30 +0,0 @@ -import os -import pytest -from dbt.tests.fixtures.project import write_project_files - -ALT_DATABASE = os.getenv("BIGQUERY_TEST_ALT_DATABASE") - -models__view_1_sql = """ -select 1 as id -""" - -models__python_model_py = """ -def model(dbt, session): - return dbt.ref("view_1") -""" - - -@pytest.fixture(scope="class") -def models(): - return { - "view_1.sql": models__view_1_sql, - "python_model.py": models__python_model_py, - } - - -@pytest.fixture(scope="class") -def project_files( - project_root, - models, -): - write_project_files(project_root, "models", models) diff --git a/tests/functional/python_model_tests/test_override_dataproc_project.py b/tests/functional/python_model_tests/test_override_dataproc_project.py index 21cf7d58e..43cd0deb5 100644 --- a/tests/functional/python_model_tests/test_override_dataproc_project.py +++ b/tests/functional/python_model_tests/test_override_dataproc_project.py @@ -1,25 +1,9 @@ -import os -from unittest.mock import patch +import pytest -from dbt.tests.util import run_dbt, check_relations_equal_with_relations +from dbt.tests.util import run_dbt from tests.unit.test_bigquery_adapter import BaseTestBigQueryAdapter - from tests.functional.python_model_tests.files import SINGLE_RECORD # noqa: F401 - -ALT_DATABASE = os.getenv("BIGQUERY_TEST_ALT_DATABASE") - -""" -dataset: dbt_mwinkler_core_dev -keyfile: /Users/matt-winkler/Downloads/sales-demo-project-314714-2e886a5c2612.json -method: service-account -project: sales-demo-project-314714 -threads: 4 -type: bigquery -gcs_bucket: matt-w-python-demo -dataproc_cluster_name: matt-w-python-demo -dataproc_region: us-west1 -dataproc_project: test-some-other-project -""" +from unittest.mock import patch # Test application of dataproc_batch configuration to a @@ -27,17 +11,21 @@ # This reuses the machinery from BaseTestBigQueryAdapter to get hold of the # parsed credentials class TestOverrideDataprocProject(BaseTestBigQueryAdapter): - @patch( - "dbt.adapters.bigquery.connections.get_bigquery_defaults", - return_value=("credentials", "project_id"), - ) + @pytest.fixture(scope="class") + def model_path(self): + return "models" + def test_update_dataproc_cluster(self): + # update the raw profile to set dataproc_project config + self.raw_profile["outputs"]["dataproc-serverless-configured"]["dataproc_batch"][ + "dataproc_project" + ] = "test" adapter = self.get_adapter("dataproc-serverless-configured") - raw_profile = self.raw_profile["outputs"]["dataproc-serverless-configured"][ - "dataproc_batch" - ] - print("showing raw_profile") - print(raw_profile) + run_dbt(["models"]) + + # raw_profile = self.raw_profile["outputs"]["dataproc-serverless-configured"][ + # "dataproc_batch" + # ] # class BaseOverrideDatabase: