-
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] Add Expectation Suite Pact tests #8885
Conversation
✅ Deploy Preview for niobium-lead-7998 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
2e4aa76
to
62068b3
Compare
039038b
to
b569be2
Compare
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.
My idea with the parametrized tests was to test various states/codes for a given http verb, but I'm not going to block on that.
"id": pact.Format().uuid, | ||
"type": "expectation_suite", | ||
}, | ||
minimum=1, |
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.
This is what I was looking for!
@pytest.mark.cloud | ||
@pytest.mark.parametrize( | ||
"contract_interaction", | ||
[ | ||
ContractInteraction( | ||
method="GET", | ||
request_path=pathlib.Path( | ||
"/", | ||
"organizations", | ||
EXISTING_ORGANIZATION_ID, | ||
"expectation-suites", | ||
EXISTING_EXPECTATION_SUITE_ID, | ||
), | ||
upon_receiving="a request to get an Expectation Suite", | ||
given="the Expectation Suite does exist", | ||
response_status=200, | ||
response_body=GET_EXPECTATION_SUITE_MIN_RESPONSE_BODY, | ||
), | ||
], | ||
) | ||
def test_get_expectation_suite( | ||
contract_interaction: ContractInteraction, | ||
run_pact_test: Callable[[ContractInteraction], None], | ||
) -> None: | ||
run_pact_test(contract_interaction) | ||
|
||
|
||
@pytest.mark.cloud | ||
@pytest.mark.parametrize( | ||
"contract_interaction", | ||
[ | ||
ContractInteraction( | ||
method="GET", | ||
request_path=pathlib.Path( | ||
"/", | ||
"organizations", | ||
EXISTING_ORGANIZATION_ID, | ||
"expectation-suites", | ||
NON_EXISTENT_EXPECTATION_SUITE_ID, | ||
), | ||
upon_receiving="a request to get an Expectation Suite", | ||
given="the Expectation Suite does not exist", | ||
response_status=404, | ||
response_body=None, | ||
), | ||
], | ||
) | ||
def test_get_non_existent_expectation_suite( | ||
contract_interaction: ContractInteraction, | ||
run_pact_test: Callable[[ContractInteraction], None], | ||
) -> None: | ||
run_pact_test(contract_interaction) |
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.
I would have combined these two into the same parametrized test.
@pytest.mark.cloud | ||
@pytest.mark.parametrize( | ||
"contract_interaction", | ||
[ | ||
ContractInteraction( | ||
method="POST", | ||
request_path=pathlib.Path( | ||
"/", | ||
"organizations", | ||
EXISTING_ORGANIZATION_ID, | ||
"expectation-suites", | ||
), | ||
upon_receiving="a request to post an Expectation Suite", | ||
given="the Expectation Suite does not exist", | ||
request_body={ | ||
"data": { | ||
"type": "expectation_suite", | ||
"attributes": { | ||
"suite": { | ||
"meta": {"great_expectations_version": "0.13.23"}, | ||
"expectations": [ | ||
{ | ||
"kwargs": {"max_value": 3, "min_value": 1}, | ||
"meta": {}, | ||
"expectation_type": "expect_table_row_count_to_be_between", | ||
}, | ||
], | ||
"expectation_suite_name": "brand new suite", | ||
} | ||
}, | ||
}, | ||
}, | ||
response_status=201, | ||
response_body=POST_EXPECTATION_SUITE_MIN_RESPONSE_BODY, | ||
), | ||
], | ||
) | ||
def test_post_expectation_suite( | ||
contract_interaction: ContractInteraction, | ||
run_pact_test: Callable[[ContractInteraction], None], | ||
) -> None: | ||
run_pact_test(contract_interaction) | ||
|
||
|
||
@pytest.mark.cloud | ||
@pytest.mark.parametrize( | ||
"contract_interaction", | ||
[ | ||
ContractInteraction( | ||
method="POST", | ||
request_path=pathlib.Path( | ||
"/", | ||
"organizations", | ||
EXISTING_ORGANIZATION_ID, | ||
"expectation-suites", | ||
), | ||
upon_receiving="a request to post an Expectation Suite", | ||
given="an Expectation Suite with same name exists", | ||
request_body={ | ||
"data": { | ||
"type": "expectation_suite", | ||
"attributes": { | ||
"suite": { | ||
"meta": {"great_expectations_version": "0.13.23"}, | ||
"expectations": [ | ||
{ | ||
"kwargs": {"max_value": 3, "min_value": 1}, | ||
"meta": {}, | ||
"expectation_type": "expect_table_row_count_to_be_between", | ||
}, | ||
], | ||
"expectation_suite_name": "brand new suite", | ||
} | ||
}, | ||
}, | ||
}, | ||
response_status=400, | ||
response_body={ | ||
"errors": [ | ||
{ | ||
"detail": pact.Like( | ||
"Expectation Suite with name brand new suite already exists." | ||
) | ||
} | ||
] | ||
}, | ||
), | ||
], | ||
) | ||
def test_post_expectation_suite_with_existing_name( | ||
contract_interaction: ContractInteraction, | ||
run_pact_test: Callable[[ContractInteraction], None], | ||
) -> None: | ||
run_pact_test(contract_interaction) |
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.
I also would have combined the POST
s, PUT
s, and DELETE
s.
* develop: [MAINTENANCE] remove deprecated usage of pydantic Extra (#8896) [MAINTENANCE] Better error msg for refrence environments (#8913) [FEATURE] Expect column specified percentile value to be above a given value. (#8907) [DOCS] add 'user' access token clarification to GX Cloud quickstart (#8912) [MAINTENANCE] Typing render/view (#8903) [MAINTENANCE] Adjust timeouts for cloud-tests services (#8910) [DOCS] Update Section Title (#8905) [MAINTENANCE] List checkpoints endpoint contract test (#8886) [MAINTENANCE] Do not skip spark tests in cloud stage (#8901) [MAINTENANCE] Add Expectation Suite Pact tests (#8885) [MAINTENANCE] Get checkpoint endpoint contract test (#8881) [DOCS] Update Cloud Quickstart save expectation suite example (#8893) [RELEASE] 0.18.0 (#8895)
invoke lint
(usesblack
+ruff
)For more information about contributing, see Contribute.
After you submit your PR, keep the page open and monitor the statuses of the various checks made by our continuous integration process at the bottom of the page. Please fix any issues that come up and reach out on Slack if you need help. Thanks for contributing!