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

chore(tests): Adding any tests #2053

Merged
merged 6 commits into from
Jun 10, 2021
Merged

chore(tests): Adding any tests #2053

merged 6 commits into from
Jun 10, 2021

Conversation

jfuss
Copy link
Contributor

@jfuss jfuss commented Jun 8, 2021

Is a work in progress PR for adding tests related to the "any" method in API Gateway.

Issue #, if available:

Description of changes:

Description of how you validated changes:

Checklist:

  • Write/update tests
  • make pr passes
  • Update documentation
  • Verify transformed template deploys and application functions as expected

Examples?

Please reach out in the comments, if you want to add an example. Examples will be
added to sam init through https://github.com/awslabs/aws-sam-cli-app-templates/

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@jfuss jfuss force-pushed the any-method-tests branch from b2bafbc to f360335 Compare June 8, 2021 15:09
@codecov-commenter
Copy link

codecov-commenter commented Jun 8, 2021

Codecov Report

Merging #2053 (ee3da9a) into develop (e7a1496) will increase coverage by 0.21%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2053      +/-   ##
===========================================
+ Coverage    93.58%   93.80%   +0.21%     
===========================================
  Files           90       91       +1     
  Lines         6124     6097      -27     
  Branches      1260     1261       +1     
===========================================
- Hits          5731     5719      -12     
+ Misses         183      174       -9     
+ Partials       210      204       -6     
Impacted Files Coverage Δ
samtranslator/plugins/exceptions.py 83.33% <0.00%> (-2.39%) ⬇️
samtranslator/model/iam.py 94.59% <0.00%> (-1.16%) ⬇️
samtranslator/model/sqs.py 94.44% <0.00%> (-0.56%) ⬇️
samtranslator/validator/validator.py 95.23% <0.00%> (-0.42%) ⬇️
samtranslator/sdk/resource.py 89.74% <0.00%> (-0.26%) ⬇️
samtranslator/open_api/open_api.py 91.72% <0.00%> (-0.25%) ⬇️
samtranslator/translator/arn_generator.py 94.28% <0.00%> (-0.16%) ⬇️
samtranslator/model/__init__.py 97.57% <0.00%> (-0.08%) ⬇️
samtranslator/plugins/globals/globals.py 99.02% <0.00%> (-0.03%) ⬇️
samtranslator/model/sam_resources.py 91.21% <0.00%> (-0.02%) ⬇️
... and 13 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e7a1496...ee3da9a. Read the comment docs.

@jfuss jfuss marked this pull request as ready for review June 9, 2021 18:50
@jfuss jfuss changed the title chore(tests): Adding api_request_model any tests chore(tests): Adding any tests Jun 9, 2021
Copy link
Contributor

@mndeveci mndeveci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow thanks for working on all these tests, LGTM! Only one minor comment.

"Properties": {
"DeploymentId": {
"Ref": "HtmlApiDeploymentdd6198efe6"
},
"Ref": "HtmlApiDeploymentcb065c609e"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hash change is not because of difference between py2 and py3, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's because of py2 vs py3. Rather, since there's a new path added in the input template, I believe the hash change is due to swagger change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mndeveci @hawflau is correct. All changes here are due to adding new paths to an API Gateway and therefore changing the hashes. I thought about maybe splitting everything into new tests but figured this was easier on me and that there are no code changes, so the hashes and things changing were predictable and expected.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation @jfuss & @hawflau !

@hawflau
Copy link
Contributor

hawflau commented Jun 10, 2021

LGTM in general!
I notice there's "api_with_swagger_authorizer_none.yaml" in the input dir, but there's not corresponding json files in the output dirs. It's weird that we actually don't have this included in "test_translator.py". Did we miss it for some reason? Or intentionally omit it?

@jfuss
Copy link
Contributor Author

jfuss commented Jun 10, 2021

LGTM in general!
I notice there's "api_with_swagger_authorizer_none.yaml" in the input dir, but there's not corresponding json files in the output dirs. It's weird that we actually don't have this included in "test_translator.py". Did we miss it for some reason? Or intentionally omit it?

Hmm... Honestly I have no idea if it is a miss or omitted on purpose. Let me do some digging into the git history and see if I can't understand that.

@jfuss
Copy link
Contributor Author

jfuss commented Jun 10, 2021

@hawflau I talked with @qingchm. It was just a miss from an earlier PR (he noticed we didn't have the input class but didn't add it to the list of tests to run). So I added it back in.

@jfuss jfuss merged commit e59951f into aws:develop Jun 10, 2021
c2tarun pushed a commit to c2tarun/serverless-application-model that referenced this pull request Jul 7, 2021
* Adding api_request_model any tests

* Add any to api_request_model_openapi_3 cases

* Add rest of relevant any test cases

* Fix hashing to match python2

* add api_with_swagger_authorizer_none to be run

* fix py2 hashes in api_with_swagger_authorizer_none tests

Co-authored-by: Jacob Fuss <[email protected]>
c2tarun added a commit that referenced this pull request Jul 8, 2021
* test: New test group to test for side effects (#2046)

* test: New test group to test for side effects

* refactor: Updated to use _compare_transform and test CN and GOV partitions

* docs: fix dead link (#2045)

* Percentage-based Enablement for Feature Toggle (#1952)

* Percentage-based Enablement for Feature Toggle

* Update Feature Toggle to accept stage, account_id and region during instanciation

* remove unnecessary uses of dict.get method

* Refactor feature toggle methods

* Update test names

* black reformat

* Update FeatureToggle to require stage, region and account_id to instanciate

* Update log message

* Implement calculating account percentile based on hash of account_id and feature_name

* Refactor _is_feature_enabled_for_region_config

* Refactor dialup logic into its own classes

* Add comments for dialup classes

* Rename NeverEnabledDialup to DisabledDialup

* chore(tests): Adding any tests (#2053)

* Adding api_request_model any tests

* Add any to api_request_model_openapi_3 cases

* Add rest of relevant any test cases

* Fix hashing to match python2

* add api_with_swagger_authorizer_none to be run

* fix py2 hashes in api_with_swagger_authorizer_none tests

Co-authored-by: Jacob Fuss <[email protected]>

* Add modes support for RestApi (#2055)

* Adding Mode passthrough property to RestApi with unit tests.

* Adding integration test for Mode

* Fixing sam-translate for manual translation.

* running black formatting

* Running black formatting, again.

* Clearing pip-wheel-metadata.

* Clearing tmp folder created by integ test.

Co-authored-by: Tarun Mall <[email protected]>

* chore: bump version to 1.38.0 (#2081)

Co-authored-by: Mathieu Grandis <[email protected]>
Co-authored-by: Chris Rehn <[email protected]>
Co-authored-by: Wing Fung Lau <[email protected]>
Co-authored-by: Jacob Fuss <[email protected]>
Co-authored-by: Jacob Fuss <[email protected]>
Co-authored-by: Tarun Mall <[email protected]>
Co-authored-by: Raymond Wang <[email protected]>
@c2tarun c2tarun mentioned this pull request Jul 16, 2021
4 tasks
c2tarun added a commit that referenced this pull request Jul 19, 2021
* test: New test group to test for side effects (#2046)

* test: New test group to test for side effects

* refactor: Updated to use _compare_transform and test CN and GOV partitions

* docs: fix dead link (#2045)

* Percentage-based Enablement for Feature Toggle (#1952)

* Percentage-based Enablement for Feature Toggle

* Update Feature Toggle to accept stage, account_id and region during instanciation

* remove unnecessary uses of dict.get method

* Refactor feature toggle methods

* Update test names

* black reformat

* Update FeatureToggle to require stage, region and account_id to instanciate

* Update log message

* Implement calculating account percentile based on hash of account_id and feature_name

* Refactor _is_feature_enabled_for_region_config

* Refactor dialup logic into its own classes

* Add comments for dialup classes

* Rename NeverEnabledDialup to DisabledDialup

* chore(tests): Adding any tests (#2053)

* Adding api_request_model any tests

* Add any to api_request_model_openapi_3 cases

* Add rest of relevant any test cases

* Fix hashing to match python2

* add api_with_swagger_authorizer_none to be run

* fix py2 hashes in api_with_swagger_authorizer_none tests

Co-authored-by: Jacob Fuss <[email protected]>

* Add modes support for RestApi (#2055)

* Adding Mode passthrough property to RestApi with unit tests.

* Adding integration test for Mode

* Fixing sam-translate for manual translation.

* running black formatting

* Running black formatting, again.

* Clearing pip-wheel-metadata.

* Clearing tmp folder created by integ test.

Co-authored-by: Tarun Mall <[email protected]>

* chore: bump version to 1.38.0 (#2081)

Co-authored-by: Mathieu Grandis <[email protected]>
Co-authored-by: Chris Rehn <[email protected]>
Co-authored-by: Wing Fung Lau <[email protected]>
Co-authored-by: Jacob Fuss <[email protected]>
Co-authored-by: Jacob Fuss <[email protected]>
Co-authored-by: Tarun Mall <[email protected]>
Co-authored-by: Raymond Wang <[email protected]>

Co-authored-by: Mathieu Grandis <[email protected]>
Co-authored-by: Chris Rehn <[email protected]>
Co-authored-by: Wing Fung Lau <[email protected]>
Co-authored-by: Jacob Fuss <[email protected]>
Co-authored-by: Jacob Fuss <[email protected]>
Co-authored-by: Tarun Mall <[email protected]>
Co-authored-by: Raymond Wang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants