@@ -706,6 +706,168 @@ def test_given_helper_cte_references_when_testing_then_helpers_read_the_tested_m
706706 expected_column = 39 ,
707707 expected_help_fragment = '__ref("<model>")' ,
708708 ),
709+ HelperReferenceErrorE2ETestCase (
710+ description = "a mock a check calls reading a referencing helper through a middle helper on the python engine" ,
711+ test_name = "mock_called_reads_referencing_helper" ,
712+ engine = "python" ,
713+ expected_code = "P013" ,
714+ expected_message = (
715+ "SQL test mock '__source__item_returns' reads helper CTE 'extras', which calls "
716+ '__ref("item_extras"); mocks and fixtures are defined before the models the '
717+ "test runs, so the helper cannot be resolved for them"
718+ ),
719+ expected_line = 4 ,
720+ expected_column = 40 ,
721+ expected_help_fragment = 'FROM __ref__item_extras rather than FROM __ref("item_extras")' ,
722+ ),
723+ HelperReferenceErrorE2ETestCase (
724+ description = "a mock a check calls reading a referencing helper directly on the python engine" ,
725+ test_name = "mock_called_reads_referencing_helper_directly" ,
726+ engine = "python" ,
727+ expected_code = "P013" ,
728+ expected_message = (
729+ "SQL test mock '__source__item_returns' reads helper CTE 'extras', which calls "
730+ '__ref("item_extras"); mocks and fixtures are defined before the models the '
731+ "test runs, so the helper cannot be resolved for them"
732+ ),
733+ expected_line = 4 ,
734+ expected_column = 40 ,
735+ expected_help_fragment = 'FROM __ref__item_extras rather than FROM __ref("item_extras")' ,
736+ ),
737+ HelperReferenceErrorE2ETestCase (
738+ description = "test reading a mocked source and a mocked model on the python engine" ,
739+ test_name = "assertion_reads_mocked_source_and_model" ,
740+ engine = "python" ,
741+ expected_code = "P013" ,
742+ expected_message = (
743+ "SQL test 'assertion_reads_mocked_source_and_model' mocks the model it tests "
744+ "(__ref__items), so the test has no model to run against"
745+ ),
746+ expected_line = 10 ,
747+ expected_column = 8 ,
748+ expected_help_fragment = 'and keep __ref("items") in the __assert__ or __expected__ CTE' ,
749+ ),
750+ HelperReferenceErrorE2ETestCase (
751+ description = "test reading a mocked model by CTE name on the python engine" ,
752+ test_name = "assertion_reads_mock_by_name" ,
753+ engine = "python" ,
754+ expected_code = "P013" ,
755+ expected_message = (
756+ "SQL test 'assertion_reads_mock_by_name' mocks the model it tests (__ref__items), "
757+ "so the test has no model to run against"
758+ ),
759+ expected_line = 8 ,
760+ expected_column = 23 ,
761+ expected_help_fragment = 'and call __ref("items") in the __assert__ or __expected__ CTE' ,
762+ ),
763+ HelperReferenceErrorE2ETestCase (
764+ description = "a mock a check calls reading a referencing helper through a middle helper on the native engine" ,
765+ test_name = "mock_called_reads_referencing_helper" ,
766+ engine = "native" ,
767+ expected_code = "P013" ,
768+ expected_message = (
769+ "SQL test mock '__source__item_returns' reads helper CTE 'extras', which calls "
770+ '__ref("item_extras"); mocks and fixtures are defined before the models the '
771+ "test runs, so the helper cannot be resolved for them"
772+ ),
773+ expected_line = 4 ,
774+ expected_column = 40 ,
775+ expected_help_fragment = 'FROM __ref__item_extras rather than FROM __ref("item_extras")' ,
776+ ),
777+ HelperReferenceErrorE2ETestCase (
778+ description = "a mock a check calls reading a referencing helper directly on the native engine" ,
779+ test_name = "mock_called_reads_referencing_helper_directly" ,
780+ engine = "native" ,
781+ expected_code = "P013" ,
782+ expected_message = (
783+ "SQL test mock '__source__item_returns' reads helper CTE 'extras', which calls "
784+ '__ref("item_extras"); mocks and fixtures are defined before the models the '
785+ "test runs, so the helper cannot be resolved for them"
786+ ),
787+ expected_line = 4 ,
788+ expected_column = 40 ,
789+ expected_help_fragment = 'FROM __ref__item_extras rather than FROM __ref("item_extras")' ,
790+ ),
791+ HelperReferenceErrorE2ETestCase (
792+ description = "test reading a mocked source and a mocked model on the native engine" ,
793+ test_name = "assertion_reads_mocked_source_and_model" ,
794+ engine = "native" ,
795+ expected_code = "P013" ,
796+ expected_message = (
797+ "SQL test 'assertion_reads_mocked_source_and_model' mocks the model it tests "
798+ "(__ref__items), so the test has no model to run against"
799+ ),
800+ expected_line = 10 ,
801+ expected_column = 8 ,
802+ expected_help_fragment = 'and keep __ref("items") in the __assert__ or __expected__ CTE' ,
803+ ),
804+ HelperReferenceErrorE2ETestCase (
805+ description = "test reading a mocked model by CTE name on the native engine" ,
806+ test_name = "assertion_reads_mock_by_name" ,
807+ engine = "native" ,
808+ expected_code = "P013" ,
809+ expected_message = (
810+ "SQL test 'assertion_reads_mock_by_name' mocks the model it tests (__ref__items), "
811+ "so the test has no model to run against"
812+ ),
813+ expected_line = 8 ,
814+ expected_column = 23 ,
815+ expected_help_fragment = 'and call __ref("items") in the __assert__ or __expected__ CTE' ,
816+ ),
817+ HelperReferenceErrorE2ETestCase (
818+ description = "a mock a check calls reading a referencing helper through a middle helper on the native-preview engine" ,
819+ test_name = "mock_called_reads_referencing_helper" ,
820+ engine = "native-preview" ,
821+ expected_code = "P013" ,
822+ expected_message = (
823+ "SQL test mock '__source__item_returns' reads helper CTE 'extras', which calls "
824+ '__ref("item_extras"); mocks and fixtures are defined before the models the '
825+ "test runs, so the helper cannot be resolved for them"
826+ ),
827+ expected_line = 4 ,
828+ expected_column = 40 ,
829+ expected_help_fragment = 'FROM __ref__item_extras rather than FROM __ref("item_extras")' ,
830+ ),
831+ HelperReferenceErrorE2ETestCase (
832+ description = "a mock a check calls reading a referencing helper directly on the native-preview engine" ,
833+ test_name = "mock_called_reads_referencing_helper_directly" ,
834+ engine = "native-preview" ,
835+ expected_code = "P013" ,
836+ expected_message = (
837+ "SQL test mock '__source__item_returns' reads helper CTE 'extras', which calls "
838+ '__ref("item_extras"); mocks and fixtures are defined before the models the '
839+ "test runs, so the helper cannot be resolved for them"
840+ ),
841+ expected_line = 4 ,
842+ expected_column = 40 ,
843+ expected_help_fragment = 'FROM __ref__item_extras rather than FROM __ref("item_extras")' ,
844+ ),
845+ HelperReferenceErrorE2ETestCase (
846+ description = "test reading a mocked source and a mocked model on the native-preview engine" ,
847+ test_name = "assertion_reads_mocked_source_and_model" ,
848+ engine = "native-preview" ,
849+ expected_code = "P013" ,
850+ expected_message = (
851+ "SQL test 'assertion_reads_mocked_source_and_model' mocks the model it tests "
852+ "(__ref__items), so the test has no model to run against"
853+ ),
854+ expected_line = 10 ,
855+ expected_column = 8 ,
856+ expected_help_fragment = 'and keep __ref("items") in the __assert__ or __expected__ CTE' ,
857+ ),
858+ HelperReferenceErrorE2ETestCase (
859+ description = "test reading a mocked model by CTE name on the native-preview engine" ,
860+ test_name = "assertion_reads_mock_by_name" ,
861+ engine = "native-preview" ,
862+ expected_code = "P013" ,
863+ expected_message = (
864+ "SQL test 'assertion_reads_mock_by_name' mocks the model it tests (__ref__items), "
865+ "so the test has no model to run against"
866+ ),
867+ expected_line = 8 ,
868+ expected_column = 23 ,
869+ expected_help_fragment = 'and call __ref("items") in the __assert__ or __expected__ CTE' ,
870+ ),
709871 ),
710872 ids = lambda case : case .description ,
711873)
0 commit comments