@@ -64,14 +64,6 @@ def test_is_empty_config(selector_config, paths, tags, config, other, expected):
64
64
config = {"materialized" : "view" , "tags" : ["has_child" , "is_child" ]},
65
65
)
66
66
67
- parent_sibling_node = DbtNode (
68
- unique_id = f"{ DbtResourceType .MODEL .value } .{ SAMPLE_PROJ_PATH .stem } .parent_sibling" ,
69
- resource_type = DbtResourceType .MODEL ,
70
- depends_on = [grandparent_node .unique_id , another_grandparent_node .unique_id ],
71
- file_path = SAMPLE_PROJ_PATH / "gen2/models/parent_sibling.sql" ,
72
- tags = ["is_adopted" ],
73
- config = {"materialized" : "view" , "tags" : ["is_adopted" ]},
74
- )
75
67
76
68
child_node = DbtNode (
77
69
unique_id = f"{ DbtResourceType .MODEL .value } .{ SAMPLE_PROJ_PATH .stem } .child" ,
@@ -208,11 +200,45 @@ def test_select_nodes_by_select_intersection_config_graph_selector_none():
208
200
assert selected == expected
209
201
210
202
203
+ def test_select_nodes_by_intersection_and_tag_ancestry ():
204
+ parent_sibling_node = DbtNode (
205
+ unique_id = f"{ DbtResourceType .MODEL .value } .{ SAMPLE_PROJ_PATH .stem } .parent_sibling" ,
206
+ resource_type = DbtResourceType .MODEL ,
207
+ depends_on = [grandparent_node .unique_id , another_grandparent_node .unique_id ],
208
+ file_path = SAMPLE_PROJ_PATH / "gen2/models/parent_sibling.sql" ,
209
+ tags = ["is_adopted" ],
210
+ config = {"materialized" : "view" , "tags" : ["is_adopted" ]},
211
+ )
212
+ sample_nodes_with_parent_sibling = dict (sample_nodes )
213
+ sample_nodes_with_parent_sibling [parent_sibling_node .unique_id ] = parent_sibling_node
214
+ selected = select_nodes (
215
+ project_dir = SAMPLE_PROJ_PATH , nodes = sample_nodes_with_parent_sibling , select = ["+tag:is_child,+tag:is_adopted" ]
216
+ )
217
+ expected = {
218
+ grandparent_node .unique_id : grandparent_node ,
219
+ another_grandparent_node .unique_id : another_grandparent_node ,
220
+ }
221
+ assert selected == expected
222
+
223
+
211
224
def test_select_nodes_by_tag_ancestry ():
212
- selected = select_nodes (project_dir = SAMPLE_PROJ_PATH , nodes = sample_nodes , select = ["+tag:is_child,+tag:is_adopted" ])
225
+ parent_sibling_node = DbtNode (
226
+ unique_id = f"{ DbtResourceType .MODEL .value } .{ SAMPLE_PROJ_PATH .stem } .parent_sibling" ,
227
+ resource_type = DbtResourceType .MODEL ,
228
+ depends_on = [grandparent_node .unique_id , another_grandparent_node .unique_id ],
229
+ file_path = SAMPLE_PROJ_PATH / "gen2/models/parent_sibling.sql" ,
230
+ tags = ["is_adopted" ],
231
+ config = {"materialized" : "view" , "tags" : ["is_adopted" ]},
232
+ )
233
+ sample_nodes_with_parent_sibling = dict (sample_nodes )
234
+ sample_nodes_with_parent_sibling [parent_sibling_node .unique_id ] = parent_sibling_node
235
+ selected = select_nodes (
236
+ project_dir = SAMPLE_PROJ_PATH , nodes = sample_nodes_with_parent_sibling , select = ["+tag:is_adopted" ]
237
+ )
213
238
expected = {
214
239
grandparent_node .unique_id : grandparent_node ,
215
240
another_grandparent_node .unique_id : another_grandparent_node ,
241
+ parent_sibling_node .unique_id : parent_sibling_node ,
216
242
}
217
243
assert selected == expected
218
244
0 commit comments