diff --git a/tests/checkpoint/test_checkpoint.py b/tests/checkpoint/test_checkpoint.py index 949d373e59ff..8be2199b3345 100644 --- a/tests/checkpoint/test_checkpoint.py +++ b/tests/checkpoint/test_checkpoint.py @@ -708,7 +708,10 @@ def test_checkpoint_run_sends_analytics( ) # Act - checkpoint.run() + with mock.patch.object( + Checkpoint, "is_fresh", return_value=CheckpointFreshnessDiagnostics(errors=[]) + ): + checkpoint.run() # Assert submit_analytics_event.assert_called_once_with( diff --git a/tests/checkpoint/test_checkpoint_id_pk.py b/tests/checkpoint/test_checkpoint_id_pk.py index dadbb3f7c224..5632b2d00d8a 100644 --- a/tests/checkpoint/test_checkpoint_id_pk.py +++ b/tests/checkpoint/test_checkpoint_id_pk.py @@ -14,6 +14,8 @@ from great_expectations.datasource.fluent.interfaces import Datasource if TYPE_CHECKING: + from pytest_mock import MockerFixture + from great_expectations.checkpoint.checkpoint import CheckpointResult from great_expectations.data_context import AbstractDataContext, FileDataContext @@ -101,6 +103,11 @@ def expect_multicolumn_sum_to_equal() -> gxe.ExpectMulticolumnSumToEqual: return gxe.ExpectMulticolumnSumToEqual(column_list=["a", "b", "c"], sum_total=30) +@pytest.fixture +def patch_checkpoint_run_analytics(mocker: MockerFixture) -> None: + mocker.patch("great_expectations.checkpoint.checkpoint.submit_analytics_event") + + def _build_checkpoint_and_run( context: AbstractDataContext, expectations: list[gxe.Expectation], @@ -135,6 +142,7 @@ def test_sql_result_format_in_checkpoint_pk_defined_one_expectation_complete_out expect_column_values_to_be_in_set: gxe.ExpectColumnValuesToBeInSet, expected_unexpected_indices_output: list[dict], expected_sql_query_output: str, + patch_checkpoint_run_analytics: None, ): """ What does this test? @@ -170,6 +178,7 @@ def test_sql_result_format_in_checkpoint_pk_defined_one_expectation_complete_out expect_column_values_to_be_in_set: gxe.ExpectColumnValuesToBeInSet, expected_unexpected_indices_output: list[dict[str, str | int]], expected_sql_query_output: str, + patch_checkpoint_run_analytics: None, ): """ What does this test? @@ -208,6 +217,7 @@ def test_sql_result_format_in_checkpoint_pk_defined_one_expectation_complete_out def test_sql_result_format_in_checkpoint_pk_defined_column_pair_expectation_complete_output_with_query( # noqa: E501 data_context_with_connection_to_metrics_db: FileDataContext, expect_column_pair_values_to_be_equal: gxe.ExpectColumnPairValuesToBeEqual, + patch_checkpoint_run_analytics: None, ): result = _build_checkpoint_and_run( context=data_context_with_connection_to_metrics_db, @@ -248,6 +258,7 @@ def test_sql_result_format_in_checkpoint_pk_defined_column_pair_expectation_comp def test_sql_result_format_in_checkpoint_pk_defined_column_pair_expectation_summary_output( data_context_with_connection_to_metrics_db: FileDataContext, expect_column_pair_values_to_be_equal: gxe.ExpectColumnPairValuesToBeEqual, + patch_checkpoint_run_analytics: None, ): result = _build_checkpoint_and_run( context=data_context_with_connection_to_metrics_db, @@ -280,6 +291,7 @@ def test_sql_result_format_in_checkpoint_pk_defined_column_pair_expectation_summ def test_sql_result_format_in_checkpoint_pk_defined_multi_column_sum_expectation_complete_output_with_query( # noqa: E501 data_context_with_connection_to_metrics_db: FileDataContext, expect_multicolumn_sum_to_equal: gxe.ExpectMulticolumnSumToEqual, + patch_checkpoint_run_analytics: None, ): """ What does this test? @@ -333,6 +345,7 @@ def test_sql_result_format_in_checkpoint_pk_defined_multi_column_sum_expectation def test_sql_result_format_in_checkpoint_pk_defined_multi_column_sum_expectation_summary_output( data_context_with_connection_to_metrics_db: FileDataContext, expect_multicolumn_sum_to_equal: gxe.ExpectMulticolumnSumToEqual, + patch_checkpoint_run_analytics: None, ): result = _build_checkpoint_and_run( context=data_context_with_connection_to_metrics_db, @@ -368,6 +381,7 @@ def test_sql_result_format_in_checkpoint_pk_defined_one_expectation_complete_out data_context_with_connection_to_metrics_db: FileDataContext, expect_column_values_to_be_in_set: gxe.ExpectColumnValuesToBeInSet, expected_unexpected_indices_output: list[dict[str, str | int]], + patch_checkpoint_run_analytics: None, ): """ What does this test? @@ -408,6 +422,7 @@ def test_sql_result_format_in_checkpoint_pk_defined_two_expectation_complete_out expect_column_values_to_not_be_in_set: gxe.ExpectColumnValuesToNotBeInSet, expected_unexpected_indices_output: list[dict[str, str | int]], expected_sql_query_output: str, + patch_checkpoint_run_analytics: None, ): """ What does this test? @@ -457,6 +472,7 @@ def test_sql_result_format_in_checkpoint_pk_defined_one_expectation_summary_outp data_context_with_connection_to_metrics_db: FileDataContext, expect_column_values_to_be_in_set: gxe.ExpectColumnValuesToBeInSet, expected_unexpected_indices_output: list[dict[str, str | int]], + patch_checkpoint_run_analytics: None, ): """ What does this test? @@ -491,6 +507,7 @@ def test_sql_result_format_in_checkpoint_pk_defined_one_expectation_summary_outp def test_sql_result_format_in_checkpoint_pk_defined_one_expectation_basic_output( data_context_with_connection_to_metrics_db: FileDataContext, expect_column_values_to_be_in_set: gxe.ExpectColumnValuesToBeInSet, + patch_checkpoint_run_analytics: None, ): """ What does this test? @@ -527,6 +544,7 @@ def test_sql_result_format_in_checkpoint_pk_defined_one_expectation_basic_output def test_sql_complete_output_no_id_pk_fallback( data_context_with_connection_to_metrics_db: FileDataContext, expect_column_values_to_be_in_set: gxe.ExpectColumnValuesToBeInSet, + patch_checkpoint_run_analytics: None, ): result = _build_checkpoint_and_run( context=data_context_with_connection_to_metrics_db, diff --git a/tests/integration/cloud/rest_contracts/test_checkpoints.py b/tests/integration/cloud/rest_contracts/test_checkpoints.py index 062bc22e2a8d..3ee26ec8d0bf 100644 --- a/tests/integration/cloud/rest_contracts/test_checkpoints.py +++ b/tests/integration/cloud/rest_contracts/test_checkpoints.py @@ -12,8 +12,9 @@ ) if TYPE_CHECKING: - from tests.integration.cloud.rest_contracts.conftest import PactBody + from pytest_mock import MockerFixture + from tests.integration.cloud.rest_contracts.conftest import PactBody NON_EXISTENT_CHECKPOINT_ID: Final[str] = "6ed9a340-8469-4ee2-a300-ffbe5d09b49d" @@ -95,5 +96,7 @@ def test_checkpoint( contract_interaction: ContractInteraction, run_rest_api_pact_test: Callable[[ContractInteraction], None], + mocker: MockerFixture, ) -> None: + mocker.patch("great_expectations.checkpoint.checkpoint.submit_analytics_event") run_rest_api_pact_test(contract_interaction)