botocore icon indicating copy to clipboard operation
botocore copied to clipboard

Update Protocol Tests

Open jonathan343 opened this issue 1 year ago • 1 comments

Context

This PR replaces the existing protocol tests in botocore/tests/unit/protocols/... with new tests generated from Smithy protocol test models. We use a version of these Smithy tests that are converted to the format currently supported by our existing test runner (test_protocols.py).

Issues

Many of the new protocol tests are failing due to test runner, serialization, and parsing issues. I've highlighted the notable issues below to provide additional context for reviwers:

Test Runner (test_protocols.py)

  • Response Body Normalization - The new protocol tests define expected body values with JSON and XML that includes extra white space and newlines. This prohibits us from continuing to do direct assertions between expected and actual values. Instead, we normalize the expected body value by attempting to parse the content as a JSON or XML object based on the protocol.
  • Handle Special Float Types - In the protocol test suite, certain special float types are represented as strings: "Infinity", "-Infinity", and "NaN". However, we parse these values as actual floats types, so we need to convert them back to their string representation before comparing with the expected values.

Input Serialization (serialize.py)

...

Response Parsing (parsers.py)

  • Infer Root XML Node - We should be trying to infer the following root nodes when parsing responses.
    • ec2 - Serializes XML responses within an XML root node with the name of the operation's output suffixed with "Response" such as <OperationNameResponse>. (see more)
    • query - Serializes a nested element with the name of the operation's output suffixed with "Result" such as <OperationNameResult>. (see more)
  • JSON Error Parsing - Parse errors as described in Operation error serialization for ALL json-based protocols. This behavior currently only exists for the rest-json protocol and doesn't handle : characters.
  • JSON Parse Header Values - This PR includes updates to the rest-json parser to handle boolean, float, and double values when represented as strings in a header. ...

jonathan343 avatar Jul 26 '24 15:07 jonathan343

:warning: Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 99.24242% with 1 line in your changes missing coverage. Please review.

Project coverage is 93.10%. Comparing base (c68aa1a) to head (2ec3a18). Report is 624 commits behind head on develop.

Files with missing lines Patch % Lines
botocore/serialize.py 98.93% 1 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3227      +/-   ##
===========================================
- Coverage    93.12%   93.10%   -0.03%     
===========================================
  Files           66       66              
  Lines        14252    14354     +102     
===========================================
+ Hits         13272    13364      +92     
- Misses         980      990      +10     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Aug 21 '24 23:08 codecov-commenter

Closing this PR in favor of the following:

  • https://github.com/boto/botocore/pull/3247
  • https://github.com/boto/botocore/pull/3378

jonathan343 avatar Feb 09 '25 17:02 jonathan343