-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[MAINTENANCE] create Checkpoint endpoint contract test #8882
Closed
josectobar
wants to merge
9
commits into
develop
from
PP-779-api-context-add-checkpoint-contract-test
Closed
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d969b5a
Add checkpoint put contract test
josectobar c59c376
Fix test
josectobar e922195
Merge branch 'develop' of github.com:great-expectations/great_expecta…
josectobar 22d293b
Get Checkpoint after it's been created
josectobar 9a98a4a
lint
josectobar 40a1e34
make request body a real checkpoint config
josectobar d6cfe84
lint
josectobar c635143
changed code and method
josectobar 128796b
Merge branch 'develop' into PP-779-api-context-add-checkpoint-contrac…
NathanFarmer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
tests/integration/cloud/rest_contracts/test_add_checkpoint.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
from __future__ import annotations | ||
|
||
import pathlib | ||
from collections import OrderedDict | ||
from typing import TYPE_CHECKING, Callable, Final | ||
|
||
import pact | ||
import pytest | ||
|
||
from tests.integration.cloud.rest_contracts.conftest import ( | ||
EXISTING_ORGANIZATION_ID, | ||
ContractInteraction, | ||
) | ||
|
||
if TYPE_CHECKING: | ||
from tests.integration.cloud.rest_contracts.conftest import PactBody | ||
|
||
NON_EXISTING_CHECKPOINT_ID: Final[str] = "68058949-f9c2-47b1-922a-a89c23ffad99" | ||
EXISTING_CHECKPOINT_ID: Final[str] = "68058949-f9c2-47b1-922a-a89c23ffad99" | ||
PUT_CHECKPOINT_MIN_RESPONSE_BODY: Final[PactBody] = pact.Like("204 string") | ||
PUT_CHECKPOINTS_MIN_REQUEST_BODY = { | ||
"data": { | ||
"attributes": { | ||
"checkpoint_config": OrderedDict( | ||
[ | ||
("name", "my_checkpoint"), | ||
("config_version", 1.0), | ||
("template_name", None), | ||
("module_name", "great_expectations.checkpoint"), | ||
("class_name", "Checkpoint"), | ||
("run_name_template", None), | ||
("expectation_suite_name", None), | ||
( | ||
"action_list", | ||
[ | ||
{ | ||
"name": "store_validation_result", | ||
"action": {"class_name": "StoreValidationResultAction"}, | ||
}, | ||
{ | ||
"name": "store_evaluation_params", | ||
"action": { | ||
"class_name": "StoreEvaluationParametersAction" | ||
}, | ||
}, | ||
], | ||
), | ||
("evaluation_parameters", {}), | ||
("runtime_configuration", {}), | ||
( | ||
"validations", | ||
[ | ||
{ | ||
"batch_request": { | ||
"datasource_name": "My_Datasource", | ||
"data_connector_name": "default_runtime_data_connector", | ||
"data_asset_name": "My_data_asset", | ||
"data_connector_query": {"index": 0}, | ||
}, | ||
"expectation_suite_name": "My_Expectation_Suite", | ||
"id": "1d8bc783-6444-437c-b008-ccfb7c8ce964", | ||
}, | ||
], | ||
), | ||
("profilers", []), | ||
("ge_cloud_id", "68058949-f9c2-47b1-922a-a89c23ffad99"), | ||
( | ||
"expectation_suite_ge_cloud_id", | ||
"3705d38a-0eec-4bd8-9956-fdb34df924b6", | ||
), | ||
] | ||
) | ||
}, | ||
"type": "checkpoint", | ||
} | ||
} | ||
|
||
GET_CHECKPOINTS_MIN_RESPONSE_BODY: Final[dict] = { | ||
"data": { | ||
"id": pact.Format().uuid, | ||
"type": "checkpoint", | ||
"attributes": { | ||
"checkpoint_config": { | ||
"validations": [ | ||
{ | ||
"id": pact.Format().uuid, | ||
} | ||
] | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
|
||
@pytest.mark.cloud | ||
@pytest.mark.parametrize( | ||
"contract_interaction", | ||
[ | ||
ContractInteraction( | ||
method="POST", | ||
request_path=pathlib.Path( | ||
"/", | ||
"organizations", | ||
EXISTING_ORGANIZATION_ID, | ||
"checkpoints", | ||
), | ||
request_body=PUT_CHECKPOINTS_MIN_REQUEST_BODY, | ||
upon_receiving="a request to create a Checkpoint", | ||
given="the Checkpoint is created", | ||
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 think the |
||
response_status=201, | ||
response_body="", | ||
), | ||
ContractInteraction( | ||
method="GET", | ||
request_path=pathlib.Path( | ||
"/", | ||
"organizations", | ||
EXISTING_ORGANIZATION_ID, | ||
"checkpoints", | ||
EXISTING_CHECKPOINT_ID, | ||
), | ||
upon_receiving="a request to get a Checkpoint", | ||
given="the Checkpoint exists", | ||
response_status=200, | ||
response_body=GET_CHECKPOINTS_MIN_RESPONSE_BODY, | ||
), | ||
], | ||
) | ||
def test_put_checkpoint( | ||
contract_interaction: ContractInteraction, | ||
run_pact_test: Callable[[ContractInteraction], None], | ||
) -> None: | ||
run_pact_test(contract_interaction) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Are you testing the
PUT
or thePOST
? Thisrequest_path
makes sense with thePOST
, but therequest_body
referencesPUT
. Maybe you tried both.