-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUGFIX] Ensure that Checkpoint
deserializes proper action subclass
#9701
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,9 +14,14 @@ | |
from great_expectations.checkpoint.actions import ( | ||
MicrosoftTeamsNotificationAction, | ||
SlackNotificationAction, | ||
UpdateDataDocsAction, | ||
ValidationAction, | ||
) | ||
from great_expectations.checkpoint.v1_checkpoint import Checkpoint, CheckpointResult | ||
from great_expectations.checkpoint.v1_checkpoint import ( | ||
Checkpoint, | ||
CheckpointAction, | ||
CheckpointResult, | ||
) | ||
from great_expectations.compatibility.pydantic import ValidationError | ||
from great_expectations.core.batch_definition import BatchDefinition | ||
from great_expectations.core.expectation_suite import ExpectationSuite | ||
|
@@ -209,7 +214,9 @@ def test_checkpoint_serialization( | |
|
||
@pytest.mark.filesystem | ||
def test_checkpoint_filesystem_round_trip_adds_ids( | ||
self, tmp_path: pathlib.Path, actions: list[ValidationAction] | ||
self, | ||
tmp_path: pathlib.Path, | ||
actions: list[CheckpointAction], | ||
): | ||
with working_directory(tmp_path): | ||
context = gx.get_context(mode="file") | ||
|
@@ -367,6 +374,37 @@ def test_checkpoint_deserialization_failure( | |
|
||
assert expected_error in str(e.value) | ||
|
||
@pytest.mark.unit | ||
def test_checkpoint_deserialization_with_actions(self, mocker: MockerFixture): | ||
# Arrange | ||
context = mocker.Mock(spec=AbstractDataContext) | ||
context.validation_definition_store.get.return_value = mocker.Mock( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. deserializing a checkpoint hits the validation definition store? |
||
spec=ValidationDefinition | ||
) | ||
set_context(context) | ||
|
||
# Act | ||
serialized_checkpoint = { | ||
"actions": [ | ||
{"site_names": [], "type": "update_data_docs"}, | ||
{"slack_webhook": "test", "type": "slack"}, | ||
{"teams_webhook": "test", "type": "microsoft"}, | ||
], | ||
"id": "e7d1f462-821b-429c-8086-cca80eeea5e9", | ||
"name": "my_checkpoint", | ||
"result_format": "SUMMARY", | ||
"validation_definitions": [ | ||
{"id": "3fb9ce09-a8fb-44d6-8abd-7d699443f6a1", "name": "my_validation_def"} | ||
], | ||
} | ||
checkpoint = Checkpoint.parse_obj(serialized_checkpoint) | ||
|
||
# Assert | ||
assert len(checkpoint.actions) == 3 | ||
assert isinstance(checkpoint.actions[0], UpdateDataDocsAction) | ||
assert isinstance(checkpoint.actions[1], SlackNotificationAction) | ||
assert isinstance(checkpoint.actions[2], MicrosoftTeamsNotificationAction) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd probably add another test here to verify that (pseudocode) serialized_checkpoint == serialize(deserialize(checkpoint)) |
||
|
||
|
||
class TestCheckpointResult: | ||
suite_name: str = "my_suite" | ||
|
@@ -455,7 +493,9 @@ def test_checkpoint_run_no_actions(self, validation_definition: ValidationDefini | |
|
||
@pytest.mark.unit | ||
def test_checkpoint_run_actions( | ||
self, validation_definition: ValidationDefinition, actions: list[ValidationAction] | ||
self, | ||
validation_definition: ValidationDefinition, | ||
actions: list[CheckpointAction], | ||
): | ||
validation_definitions = [validation_definition] | ||
checkpoint = Checkpoint( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we can test this with Checkpoint, I'd like to remove this test