Skip to content
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

Merged
merged 4 commits into from
Oct 31, 2023

Conversation

wookasz
Copy link
Contributor

@wookasz wookasz commented Oct 27, 2023

  • Description of PR changes above includes a link to an existing GitHub issue
  • PR title is prefixed with one of: [BUGFIX], [FEATURE], [DOCS], [MAINTENANCE], [CONTRIB]
  • Code is linted - run invoke lint (uses black + ruff)
  • Appropriate tests and docs have been updated

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!

@netlify
Copy link

netlify bot commented Oct 27, 2023

Deploy Preview for niobium-lead-7998 ready!

Name Link
🔨 Latest commit b569be2
🔍 Latest deploy log https://app.netlify.com/sites/niobium-lead-7998/deploys/6541361a5fe8c200086102ec
😎 Deploy Preview https://deploy-preview-8885.docs.greatexpectations.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions github-actions bot added the core label Oct 27, 2023
@ghost
Copy link

ghost commented Oct 27, 2023

👇 Click on the image for a new way to code review

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

@wookasz wookasz force-pushed the m/pp-661/expectation-suites-pact branch from 2e4aa76 to 62068b3 Compare October 27, 2023 20:11
@wookasz wookasz marked this pull request as ready for review October 27, 2023 20:12
@wookasz wookasz changed the title Add GET Expectation Suite Pact test [MAINTENANCE] Add GET Expectation Suite Pact test Oct 27, 2023
@wookasz wookasz force-pushed the m/pp-661/expectation-suites-pact branch from 039038b to b569be2 Compare October 31, 2023 17:15
@wookasz wookasz requested a review from NathanFarmer October 31, 2023 17:45
Copy link
Contributor

@NathanFarmer NathanFarmer left a 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,
Copy link
Contributor

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!

Comment on lines +98 to +149
@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)
Copy link
Contributor

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.

Comment on lines +178 to +271
@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)
Copy link
Contributor

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 POSTs, PUTs, and DELETEs.

@NathanFarmer NathanFarmer changed the title [MAINTENANCE] Add GET Expectation Suite Pact test [MAINTENANCE] Add Expectation Suite Pact tests Oct 31, 2023
@NathanFarmer NathanFarmer added this pull request to the merge queue Oct 31, 2023
Merged via the queue into develop with commit b95c9ec Oct 31, 2023
56 checks passed
@NathanFarmer NathanFarmer deleted the m/pp-661/expectation-suites-pact branch October 31, 2023 18:51
Shinnnyshinshin added a commit that referenced this pull request Nov 1, 2023
* 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants