MCPcopy Index your code
hub / github.com/aws/aws-cli / _assert_requests_equal

Function _assert_requests_equal

tests/unit/botocore/test_protocols.py:463–497  ·  view source on GitHub ↗
(actual, expected, protocol, operation_model)

Source from the content-addressed store, hash-verified

461
462
463def _assert_requests_equal(actual, expected, protocol, operation_model):
464 # For CBOR, we need to assert that the bodies are equal based on their parsed
465 # values to ensure we are properly testing things like
466 if protocol == 'smithy-rpc-v2-cbor' and actual['body']:
467 parser = RpcV2CBORParser()
468 actual_body_stream = parser.get_peekable_stream_from_bytes(
469 actual['body']
470 )
471 expected_body_stream = parser.get_peekable_stream_from_bytes(
472 base64.b64decode(expected['body'])
473 )
474 actual_body = _convert_special_floats_to_string(
475 parser.parse_data_item(actual_body_stream)
476 )
477 expected_body = _convert_special_floats_to_string(
478 parser.parse_data_item(expected_body_stream)
479 )
480 assert_equal(actual_body, expected_body, 'Body value')
481 elif 'body' in expected:
482 expected_body = expected['body'].encode('utf-8')
483 actual_body = actual['body']
484 _assert_request_body(actual_body, expected_body, protocol)
485 actual_headers = HeadersDict(actual['headers'])
486 expected_headers = HeadersDict(expected.get('headers', {}))
487 excluded_headers = expected.get('forbidHeaders', [])
488 _assert_expected_headers_in_request(
489 actual_headers,
490 expected_headers,
491 excluded_headers,
492 protocol,
493 operation_model,
494 )
495 assert_equal(actual['url_path'], expected.get('uri', ''), "URI")
496 if 'method' in expected:
497 assert_equal(actual['method'], expected['method'], "Method")
498
499
500def _assert_request_body(actual, expected, protocol_type):

Callers 1

test_input_complianceFunction · 0.85

Calls 9

RpcV2CBORParserClass · 0.90
HeadersDictClass · 0.90
_assert_request_bodyFunction · 0.85
parse_data_itemMethod · 0.80
assert_equalFunction · 0.70
encodeMethod · 0.45

Tested by

no test coverage detected