|
3 | 3 | import pytest |
4 | 4 |
|
5 | 5 | from dbt.tests.util import run_dbt |
6 | | - |
| 6 | +import re |
7 | 7 |
|
8 | 8 | def select_1(dataset: str, materialized: str): |
9 | 9 | config = f"""config( |
@@ -87,51 +87,17 @@ def test_grant_access_succeeds(self, project, setup_grant_schema, teardown_grant |
87 | 87 |
|
88 | 88 |
|
89 | 89 |
|
90 | | -class TestAccessGrantSucceedsWithFullRefresh: |
91 | | - @pytest.fixture(scope="class") |
92 | | - def setup_grant_schema( |
93 | | - self, |
94 | | - project, |
95 | | - unique_schema, |
96 | | - ): |
97 | | - with project.adapter.connection_named("__test_grants"): |
98 | | - relation = project.adapter.Relation.create( |
99 | | - database=project.database, |
100 | | - schema=get_schema_name(unique_schema), |
101 | | - identifier="grant_access", |
102 | | - ) |
103 | | - project.adapter.create_schema(relation) |
104 | | - yield relation |
105 | | - |
106 | | - @pytest.fixture(scope="class") |
107 | | - def teardown_grant_schema( |
108 | | - self, |
109 | | - project, |
110 | | - unique_schema, |
111 | | - ): |
112 | | - yield |
113 | | - with project.adapter.connection_named("__test_grants"): |
114 | | - relation = project.adapter.Relation.create( |
115 | | - database=project.database, schema=get_schema_name(unique_schema) |
116 | | - ) |
117 | | - project.adapter.drop_schema(relation) |
118 | | - |
119 | | - @pytest.fixture(scope="class") |
120 | | - def models(self, unique_schema): |
121 | | - dataset = get_schema_name(unique_schema) |
122 | | - return { |
123 | | - "select_1.sql": select_1(dataset=dataset, materialized="view"), |
124 | | - "select_1_table.sql": select_1(dataset=dataset, materialized="table"), |
125 | | - } |
126 | | - |
127 | | - def test_grant_access_succeeds(self, project, setup_grant_schema, teardown_grant_schema): |
| 90 | +class TestAccessGrantSucceedsWithFullRefresh(TestAccessGrantSucceeds): |
| 91 | + def test_grant_access_succeeds(self, project, setup_grant_schema, teardown_grant_schema,capsys): |
128 | 92 | # Need to run twice to validate idempotency |
129 | 93 | results = run_dbt(["run"]) |
130 | 94 | assert len(results) == 2 |
131 | 95 | time.sleep(10) |
132 | 96 | results = run_dbt(["run","--full-refresh"]) |
133 | 97 | assert len(results) == 2 |
134 | | - |
| 98 | + captured = capsys.readouterr() |
| 99 | + assert not re.search(r"BigQuery adapter: Access entry <AccessEntry: .* already exists in dataset",captured[0]) |
| 100 | + |
135 | 101 |
|
136 | 102 |
|
137 | 103 |
|
|
0 commit comments