@@ -80,53 +80,6 @@ def test_run_seed_test(self, project):
8080 check_relations_equal (project .adapter , ["seed" , "materialization" ])
8181
8282
83- class TestOnTableExistsSkip (BaseOnTableExists ):
84- """
85- Testing on_table_exists = `skip` configuration for table materialization,
86- using dbt seed, run and tests commands and validate data load correctness.
87- """
88-
89- @pytest .fixture (scope = "class" )
90- def project_config_update (self ):
91- return {
92- "name" : "table_rename" ,
93- "models" : {"+materialized" : "table" , "+on_table_exists" : "skip" },
94- "seeds" : {
95- "+column_types" : {"some_date" : "timestamp(6)" },
96- },
97- }
98-
99- # The actual sequence of dbt commands and assertions
100- # pytest will take care of all "setup" + "teardown"
101- def test_run_seed_test (self , project ):
102- # seed seeds
103- results = run_dbt (["seed" ], expect_pass = True )
104- assert len (results ) == 1
105- # run models two times to check on_table_exists = 'skip'
106- results , logs = run_dbt_and_capture (["--debug" , "run" ], expect_pass = True )
107- assert len (results ) == 1
108- assert (
109- f'create table if not exists "{ project .database } "."{ project .test_schema } "."materialization"' in logs
110- )
111- assert "alter table" not in logs
112- assert "drop table" not in logs
113- assert "or replace" not in logs
114- results , logs = run_dbt_and_capture (["--debug" , "run" ], expect_pass = True )
115- assert len (results ) == 1
116- assert (
117- f'create table if not exists "{ project .database } "."{ project .test_schema } "."materialization"' in logs
118- )
119- assert "alter table" not in logs
120- assert "drop table" not in logs
121- assert "or replace" not in logs
122- # test tests
123- results = run_dbt (["test" ], expect_pass = True )
124- assert len (results ) == 3
125-
126- # check if the data was loaded correctly
127- check_relations_equal (project .adapter , ["seed" , "materialization" ])
128-
129-
13083class TestOnTableExistsRenameIncrementalFullRefresh (BaseOnTableExists ):
13184 """
13285 Testing on_table_exists = `rename` configuration for incremental materialization and full refresh flag,
@@ -356,3 +309,50 @@ class TestOnTableExistsReplaceDeltaIncrementalFullRefresh(
356309 BaseOnTableExistsReplaceIncrementalFullRefresh
357310):
358311 pass
312+
313+
314+ class TestOnTableExistsSkip (BaseOnTableExists ):
315+ """
316+ Testing on_table_exists = `skip` configuration for table materialization,
317+ using dbt seed, run and tests commands and validate data load correctness.
318+ """
319+
320+ @pytest .fixture (scope = "class" )
321+ def project_config_update (self ):
322+ return {
323+ "name" : "table_rename" ,
324+ "models" : {"+materialized" : "table" , "+on_table_exists" : "skip" },
325+ "seeds" : {
326+ "+column_types" : {"some_date" : "timestamp(6)" },
327+ },
328+ }
329+
330+ # The actual sequence of dbt commands and assertions
331+ # pytest will take care of all "setup" + "teardown"
332+ def test_run_seed_test (self , project ):
333+ # seed seeds
334+ results = run_dbt (["seed" ], expect_pass = True )
335+ assert len (results ) == 1
336+ # run models two times to check on_table_exists = 'skip'
337+ results , logs = run_dbt_and_capture (["--debug" , "run" ], expect_pass = True )
338+ assert len (results ) == 1
339+ assert (
340+ f'create table if not exists "{ project .database } "."{ project .test_schema } "."materialization"' in logs
341+ )
342+ assert "alter table" not in logs
343+ assert "drop table" not in logs
344+ assert "or replace" not in logs
345+ results , logs = run_dbt_and_capture (["--debug" , "run" ], expect_pass = True )
346+ assert len (results ) == 1
347+ assert (
348+ f'create table if not exists "{ project .database } "."{ project .test_schema } "."materialization"' in logs
349+ )
350+ assert "alter table" not in logs
351+ assert "drop table" not in logs
352+ assert "or replace" not in logs
353+ # test tests
354+ results = run_dbt (["test" ], expect_pass = True )
355+ assert len (results ) == 3
356+
357+ # check if the data was loaded correctly
358+ check_relations_equal (project .adapter , ["seed" , "materialization" ])
0 commit comments