Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joshua-stauffer committed Sep 11, 2024
1 parent 8778208 commit 774cea1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
5 changes: 4 additions & 1 deletion tests/checkpoint/test_checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
18 changes: 18 additions & 0 deletions tests/checkpoint/test_checkpoint_id_pk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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?
Expand Down Expand Up @@ -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?
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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?
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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?
Expand Down Expand Up @@ -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?
Expand Down Expand Up @@ -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?
Expand Down Expand Up @@ -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?
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion tests/integration/cloud/rest_contracts/test_checkpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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)

0 comments on commit 774cea1

Please sign in to comment.