From 1744e65044098ecbf69cc5251ef1b97a0e583515 Mon Sep 17 00:00:00 2001 From: salim_moulouel Date: Mon, 6 May 2024 14:53:32 +0200 Subject: [PATCH] check no warning of already existing grant when full_refresh --- .../adapter/test_grant_access_to.py | 50 +++---------------- 1 file changed, 8 insertions(+), 42 deletions(-) diff --git a/tests/functional/adapter/test_grant_access_to.py b/tests/functional/adapter/test_grant_access_to.py index f628461782..bd89ef53ce 100644 --- a/tests/functional/adapter/test_grant_access_to.py +++ b/tests/functional/adapter/test_grant_access_to.py @@ -3,13 +3,13 @@ import pytest from dbt.tests.util import run_dbt - +import re def select_1(dataset: str, materialized: str): config = f"""config( materialized='{materialized}', grant_access_to=[ - {{'project': 'dbt-test-env', 'dataset': '{dataset}'}}, + {{'project': 'vg1np-apps-bdi-dev-70', 'dataset': '{dataset}'}}, ] )""" return ( @@ -26,7 +26,7 @@ def select_1(dataset: str, materialized: str): {{ config( materialized='view', grant_access_to=[ - {'project': 'dbt-test-env', 'dataset': 'NonExistentDataset'}, + {'project': 'vg1np-apps-bdi-dev-70', 'dataset': 'NonExistentDataset'}, ] ) }} @@ -87,51 +87,17 @@ def test_grant_access_succeeds(self, project, setup_grant_schema, teardown_grant -class TestAccessGrantSucceedsWithFullRefresh: - @pytest.fixture(scope="class") - def setup_grant_schema( - self, - project, - unique_schema, - ): - with project.adapter.connection_named("__test_grants"): - relation = project.adapter.Relation.create( - database=project.database, - schema=get_schema_name(unique_schema), - identifier="grant_access", - ) - project.adapter.create_schema(relation) - yield relation - - @pytest.fixture(scope="class") - def teardown_grant_schema( - self, - project, - unique_schema, - ): - yield - with project.adapter.connection_named("__test_grants"): - relation = project.adapter.Relation.create( - database=project.database, schema=get_schema_name(unique_schema) - ) - project.adapter.drop_schema(relation) - - @pytest.fixture(scope="class") - def models(self, unique_schema): - dataset = get_schema_name(unique_schema) - return { - "select_1.sql": select_1(dataset=dataset, materialized="view"), - "select_1_table.sql": select_1(dataset=dataset, materialized="table"), - } - - def test_grant_access_succeeds(self, project, setup_grant_schema, teardown_grant_schema): +class TestAccessGrantSucceedsWithFullRefresh(TestAccessGrantSucceeds): + def test_grant_access_succeeds(self, project, setup_grant_schema, teardown_grant_schema,capsys): # Need to run twice to validate idempotency results = run_dbt(["run"]) assert len(results) == 2 time.sleep(10) results = run_dbt(["run","--full-refresh"]) assert len(results) == 2 - + captured = capsys.readouterr() + assert not re.search(r"BigQuery adapter: Access entry