55
55
gsm_override_sql ,
56
56
gsm_override2_sql ,
57
57
orders_sql ,
58
+ orders_downstream_sql ,
58
59
snapshot_sql ,
59
60
snapshot2_sql ,
60
61
generic_schema_yml ,
65
66
groups_schema_yml_two_groups ,
66
67
groups_schema_yml_two_groups_edited ,
67
68
groups_schema_yml_one_group_model_in_group2 ,
69
+ groups_schema_yml_two_groups_private_orders_valid_access ,
70
+ groups_schema_yml_two_groups_private_orders_invalid_access ,
68
71
)
69
72
70
73
from dbt .exceptions import CompilationError , ParsingError
@@ -699,56 +702,57 @@ class TestGroups:
699
702
def models (self ):
700
703
return {
701
704
"orders.sql" : orders_sql ,
705
+ "orders_downstream.sql" : orders_downstream_sql ,
702
706
"schema.yml" : groups_schema_yml_one_group ,
703
707
}
704
708
705
709
def test_pp_groups (self , project ):
706
710
707
711
# initial run
708
712
results = run_dbt ()
709
- assert len (results ) == 1
713
+ assert len (results ) == 2
710
714
manifest = get_manifest (project .project_root )
711
- expected_nodes = ["model.test.orders" ]
715
+ expected_nodes = ["model.test.orders" , "model.test.orders_downstream" ]
712
716
expected_groups = ["group.test.test_group" ]
713
- assert expected_nodes == list (manifest .nodes .keys ())
714
- assert expected_groups == list (manifest .groups .keys ())
717
+ assert expected_nodes == sorted ( list (manifest .nodes .keys () ))
718
+ assert expected_groups == sorted ( list (manifest .groups .keys () ))
715
719
716
720
# add group to schema
717
721
write_file (groups_schema_yml_two_groups , project .project_root , "models" , "schema.yml" )
718
722
results = run_dbt (["--partial-parse" , "run" ])
719
- assert len (results ) == 1
723
+ assert len (results ) == 2
720
724
manifest = get_manifest (project .project_root )
721
- expected_nodes = ["model.test.orders" ]
725
+ expected_nodes = ["model.test.orders" , "model.test.orders_downstream" ]
722
726
expected_groups = ["group.test.test_group" , "group.test.test_group2" ]
723
- assert expected_nodes == list (manifest .nodes .keys ())
724
- assert expected_groups == list (manifest .groups .keys ())
727
+ assert expected_nodes == sorted ( list (manifest .nodes .keys () ))
728
+ assert expected_groups == sorted ( list (manifest .groups .keys () ))
725
729
726
730
# edit group in schema
727
731
write_file (
728
732
groups_schema_yml_two_groups_edited , project .project_root , "models" , "schema.yml"
729
733
)
730
734
results = run_dbt (["--partial-parse" , "run" ])
731
- assert len (results ) == 1
735
+ assert len (results ) == 2
732
736
manifest = get_manifest (project .project_root )
733
- expected_nodes = ["model.test.orders" ]
737
+ expected_nodes = ["model.test.orders" , "model.test.orders_downstream" ]
734
738
expected_groups = ["group.test.test_group" , "group.test.test_group2_edited" ]
735
- assert expected_nodes == list (manifest .nodes .keys ())
736
- assert expected_groups == list (manifest .groups .keys ())
739
+ assert expected_nodes == sorted ( list (manifest .nodes .keys () ))
740
+ assert expected_groups == sorted ( list (manifest .groups .keys () ))
737
741
738
742
# delete group in schema
739
743
write_file (groups_schema_yml_one_group , project .project_root , "models" , "schema.yml" )
740
744
results = run_dbt (["--partial-parse" , "run" ])
741
- assert len (results ) == 1
745
+ assert len (results ) == 2
742
746
manifest = get_manifest (project .project_root )
743
- expected_nodes = ["model.test.orders" ]
747
+ expected_nodes = ["model.test.orders" , "model.test.orders_downstream" ]
744
748
expected_groups = ["group.test.test_group" ]
745
- assert expected_nodes == list (manifest .nodes .keys ())
746
- assert expected_groups == list (manifest .groups .keys ())
749
+ assert expected_nodes == sorted ( list (manifest .nodes .keys () ))
750
+ assert expected_groups == sorted ( list (manifest .groups .keys () ))
747
751
748
752
# add back second group
749
753
write_file (groups_schema_yml_two_groups , project .project_root , "models" , "schema.yml" )
750
754
results = run_dbt (["--partial-parse" , "run" ])
751
- assert len (results ) == 1
755
+ assert len (results ) == 2
752
756
753
757
# remove second group with model still configured to second group
754
758
write_file (
@@ -759,3 +763,22 @@ def test_pp_groups(self, project):
759
763
)
760
764
with pytest .raises (ParsingError ):
761
765
results = run_dbt (["--partial-parse" , "run" ])
766
+
767
+ # add back second group, make orders private with valid ref
768
+ write_file (
769
+ groups_schema_yml_two_groups_private_orders_valid_access ,
770
+ project .project_root ,
771
+ "models" ,
772
+ "schema.yml" ,
773
+ )
774
+ results = run_dbt (["--partial-parse" , "run" ])
775
+ assert len (results ) == 2
776
+
777
+ write_file (
778
+ groups_schema_yml_two_groups_private_orders_invalid_access ,
779
+ project .project_root ,
780
+ "models" ,
781
+ "schema.yml" ,
782
+ )
783
+ with pytest .raises (ParsingError ):
784
+ results = run_dbt (["--partial-parse" , "run" ])
0 commit comments