Best Python code snippet using localstack_python
test_parser.py
Source:test_parser.py
...206 assert params == {207 "QueueUrl": "http://localhost:4566/000000000000/tf-acc-test-queue",208 "Entries": [{"Id": "bar", "ReceiptHandle": "foo"}, {"Id": "bar", "ReceiptHandle": "foo"}],209 }210def _botocore_parser_integration_test(211 service: str, action: str, headers: dict = None, expected: dict = None, **kwargs212):213 # Load the appropriate service214 service = load_service(service)215 # Use the serializer from botocore to serialize the request params216 serializer = create_serializer(service.protocol)217 operation_model = service.operation_model(action)218 serialized_request = serializer.serialize_to_request(kwargs, operation_model)219 prepare_request_dict(serialized_request, "")220 split_url = urlsplit(serialized_request.get("url"))221 path = split_url.path222 query_string = split_url.query223 body = serialized_request["body"]224 # use custom headers (if provided), or headers from serialized request as default225 headers = serialized_request.get("headers") if headers is None else headers226 if service.protocol in ["query", "ec2"]:227 # Serialize the body as query parameter228 body = urlencode(serialized_request["body"])229 # Use our parser to parse the serialized body230 parser = create_parser(service)231 parsed_operation_model, parsed_request = parser.parse(232 HttpRequest(233 method=serialized_request.get("method") or "GET",234 path=path,235 query_string=to_str(query_string),236 headers=headers,237 body=body,238 raw_path=path,239 )240 )241 # Check if the determined operation_model is correct242 assert parsed_operation_model == operation_model243 # Check if the result is equal to the given "expected" dict or the kwargs (if "expected" has not been set)244 expected = expected or kwargs245 # The parser adds None for none-existing members on purpose. Remove those for the assert246 expected = {key: value for key, value in expected.items() if value is not None}247 parsed_request = {key: value for key, value in parsed_request.items() if value is not None}248 assert parsed_request == expected249def test_query_parser_sqs_with_botocore():250 _botocore_parser_integration_test(251 service="sqs",252 action="SendMessage",253 QueueUrl="string",254 MessageBody="string",255 DelaySeconds=123,256 MessageAttributes={257 "string": {258 "StringValue": "string",259 "BinaryValue": b"bytes",260 "StringListValues": [261 "string",262 ],263 "BinaryListValues": [264 b"bytes",265 ],266 "DataType": "string",267 }268 },269 MessageSystemAttributes={270 "string": {271 "StringValue": "string",272 "BinaryValue": b"bytes",273 "StringListValues": [274 "string",275 ],276 "BinaryListValues": [277 b"bytes",278 ],279 "DataType": "string",280 }281 },282 MessageDeduplicationId="string",283 MessageGroupId="string",284 )285def test_query_parser_empty_required_members_sqs_with_botocore():286 _botocore_parser_integration_test(287 service="sqs",288 action="SendMessageBatch",289 QueueUrl="string",290 Entries=[],291 expected={"QueueUrl": "string"},292 )293def test_query_parser_no_input_shape_autoscaling_with_botocore():294 _botocore_parser_integration_test(295 service="autoscaling",296 action="DescribeMetricCollectionTypes",297 )298def test_query_parser_cloudformation_with_botocore():299 _botocore_parser_integration_test(300 service="cloudformation",301 action="CreateStack",302 StackName="string",303 TemplateBody="string",304 TemplateURL="string",305 Parameters=[306 {307 "ParameterKey": "string",308 "ParameterValue": "string",309 "UsePreviousValue": True,310 "ResolvedValue": "string",311 },312 ],313 DisableRollback=False,314 RollbackConfiguration={315 "RollbackTriggers": [316 {"Arn": "string", "Type": "string"},317 ],318 "MonitoringTimeInMinutes": 123,319 },320 TimeoutInMinutes=123,321 NotificationARNs=[322 "string",323 ],324 Capabilities=[325 "CAPABILITY_IAM",326 ],327 ResourceTypes=[328 "string",329 ],330 RoleARN="12345678901234567890",331 OnFailure="DO_NOTHING",332 StackPolicyBody="string",333 StackPolicyURL="string",334 Tags=[335 {"Key": "string", "Value": "string"},336 ],337 ClientRequestToken="string",338 EnableTerminationProtection=False,339 )340def test_query_parser_unflattened_list_of_maps():341 _botocore_parser_integration_test(342 service="rds",343 action="CreateDBCluster",344 DBClusterIdentifier="mydbcluster",345 Engine="aurora",346 Tags=[{"Key": "Hello", "Value": "There"}, {"Key": "Hello1", "Value": "There1"}],347 )348def test_restxml_parser_route53_with_botocore():349 _botocore_parser_integration_test(350 service="route53",351 action="CreateHostedZone",352 Name="string",353 VPC={"VPCRegion": "us-east-1", "VPCId": "string"},354 CallerReference="string",355 HostedZoneConfig={"Comment": "string", "PrivateZone": True},356 DelegationSetId="string",357 )358def test_json_parser_cognito_with_botocore():359 _botocore_parser_integration_test(360 service="cognito-idp",361 action="CreateUserPool",362 headers={"X-Amz-Target": "AWSCognitoIdentityProviderService.CreateUserPool"},363 PoolName="string",364 Policies={365 "PasswordPolicy": {366 "MinimumLength": 123,367 "RequireUppercase": True,368 "RequireLowercase": True,369 "RequireNumbers": True,370 "RequireSymbols": True,371 "TemporaryPasswordValidityDays": 123,372 }373 },374 LambdaConfig={375 "PreSignUp": "12345678901234567890",376 "CustomMessage": "12345678901234567890",377 "PostConfirmation": "12345678901234567890",378 "PreAuthentication": "12345678901234567890",379 "PostAuthentication": "12345678901234567890",380 "DefineAuthChallenge": "12345678901234567890",381 "CreateAuthChallenge": "12345678901234567890",382 "VerifyAuthChallengeResponse": "12345678901234567890",383 "PreTokenGeneration": "12345678901234567890",384 "UserMigration": "12345678901234567890",385 "CustomSMSSender": {"LambdaVersion": "V1_0", "LambdaArn": "12345678901234567890"},386 "CustomEmailSender": {"LambdaVersion": "V1_0", "LambdaArn": "12345678901234567890"},387 "KMSKeyID": "12345678901234567890",388 },389 AutoVerifiedAttributes=[390 "phone_number",391 ],392 AliasAttributes=[393 "phone_number",394 ],395 UsernameAttributes=[396 "phone_number",397 ],398 SmsVerificationMessage="string",399 EmailVerificationMessage="string",400 EmailVerificationSubject="string",401 VerificationMessageTemplate={402 "SmsMessage": "string",403 "EmailMessage": "string",404 "EmailSubject": "string",405 "EmailMessageByLink": "string",406 "EmailSubjectByLink": "string",407 "DefaultEmailOption": "CONFIRM_WITH_LINK",408 },409 SmsAuthenticationMessage="string",410 MfaConfiguration="OFF",411 DeviceConfiguration={412 "ChallengeRequiredOnNewDevice": True,413 "DeviceOnlyRememberedOnUserPrompt": True,414 },415 EmailConfiguration={416 "SourceArn": "12345678901234567890",417 "ReplyToEmailAddress": "string",418 "EmailSendingAccount": "COGNITO_DEFAULT",419 "From": "string",420 "ConfigurationSet": "string",421 },422 SmsConfiguration={"SnsCallerArn": "12345678901234567890", "ExternalId": "string"},423 UserPoolTags={"string": "string"},424 AdminCreateUserConfig={425 "AllowAdminCreateUserOnly": True,426 "UnusedAccountValidityDays": 123,427 "InviteMessageTemplate": {428 "SMSMessage": "string",429 "EmailMessage": "string",430 "EmailSubject": "string",431 },432 },433 Schema=[434 {435 "Name": "string",436 "AttributeDataType": "String",437 "DeveloperOnlyAttribute": True,438 "Mutable": True,439 "Required": True,440 "NumberAttributeConstraints": {"MinValue": "string", "MaxValue": "string"},441 "StringAttributeConstraints": {"MinLength": "string", "MaxLength": "string"},442 },443 ],444 UserPoolAddOns={"AdvancedSecurityMode": "OFF"},445 UsernameConfiguration={"CaseSensitive": True},446 AccountRecoverySetting={447 "RecoveryMechanisms": [448 {"Priority": 123, "Name": "verified_email"},449 ]450 },451 )452def test_restjson_parser_xray_with_botocore():453 _botocore_parser_integration_test(454 service="xray",455 action="PutTelemetryRecords",456 TelemetryRecords=[457 {458 "Timestamp": datetime(2015, 1, 1),459 "SegmentsReceivedCount": 123,460 "SegmentsSentCount": 123,461 "SegmentsSpilloverCount": 123,462 "SegmentsRejectedCount": 123,463 "BackendConnectionErrors": {464 "TimeoutCount": 123,465 "ConnectionRefusedCount": 123,466 "HTTPCode4XXCount": 123,467 "HTTPCode5XXCount": 123,468 "UnknownHostCount": 123,469 "OtherCount": 123,470 },471 },472 ],473 EC2InstanceId="string",474 Hostname="string",475 ResourceARN="string",476 )477def test_restjson_path_location_opensearch_with_botocore():478 _botocore_parser_integration_test(479 service="opensearch",480 action="DeleteDomain",481 DomainName="test-domain",482 )483def test_restjson_query_location_opensearch_with_botocore():484 _botocore_parser_integration_test(485 service="opensearch",486 action="ListVersions",487 NextToken="test-token",488 )489def test_restjson_opensearch_with_botocore():490 _botocore_parser_integration_test(491 service="opensearch",492 action="UpdateDomainConfig",493 DomainName="string",494 ClusterConfig={495 "InstanceType": "m3.medium.search",496 "InstanceCount": 123,497 "DedicatedMasterEnabled": True,498 "ZoneAwarenessEnabled": True,499 "ZoneAwarenessConfig": {"AvailabilityZoneCount": 123},500 "DedicatedMasterType": "m3.medium.search",501 "DedicatedMasterCount": 123,502 "WarmEnabled": True,503 "WarmType": "ultrawarm1.medium.search",504 "WarmCount": 123,505 "ColdStorageOptions": {"Enabled": True},506 },507 EBSOptions={"EBSEnabled": False, "VolumeType": "standard", "VolumeSize": 123, "Iops": 123},508 SnapshotOptions={"AutomatedSnapshotStartHour": 123},509 VPCOptions={510 "SubnetIds": [511 "string",512 ],513 "SecurityGroupIds": [514 "string",515 ],516 },517 CognitoOptions={518 "Enabled": True,519 "UserPoolId": "string",520 "IdentityPoolId": "string",521 "RoleArn": "12345678901234567890",522 },523 AdvancedOptions={"string": "string"},524 AccessPolicies="string",525 LogPublishingOptions={526 "string": {"CloudWatchLogsLogGroupArn": "12345678901234567890", "Enabled": True}527 },528 EncryptionAtRestOptions={"Enabled": False, "KmsKeyId": "string"},529 DomainEndpointOptions={530 "EnforceHTTPS": True,531 "TLSSecurityPolicy": "Policy-Min-TLS-1-0-2019-07",532 "CustomEndpointEnabled": True,533 "CustomEndpoint": "string",534 "CustomEndpointCertificateArn": "12345678901234567890",535 },536 NodeToNodeEncryptionOptions={"Enabled": True},537 AdvancedSecurityOptions={538 "Enabled": True,539 "InternalUserDatabaseEnabled": True,540 "MasterUserOptions": {541 "MasterUserARN": "12345678901234567890",542 "MasterUserName": "string",543 "MasterUserPassword": "12345678",544 },545 "SAMLOptions": {546 "Enabled": True,547 "Idp": {"MetadataContent": "string", "EntityId": "12345678"},548 "MasterUserName": "string",549 "MasterBackendRole": "string",550 "SubjectKey": "string",551 "RolesKey": "string",552 "SessionTimeoutMinutes": 123,553 },554 },555 AutoTuneOptions={556 "DesiredState": "ENABLED",557 "RollbackOnDisable": "DEFAULT_ROLLBACK",558 "MaintenanceSchedules": [559 {560 "StartAt": datetime(2015, 1, 1),561 "Duration": {"Value": 123, "Unit": "HOURS"},562 "CronExpressionForRecurrence": "string",563 },564 ],565 },566 )567def test_restjson_awslambda_invoke_with_botocore():568 _botocore_parser_integration_test(569 service="lambda",570 action="Invoke",571 FunctionName="test-function",572 )573def test_ec2_parser_ec2_with_botocore():574 _botocore_parser_integration_test(575 service="ec2",576 action="CreateImage",577 BlockDeviceMappings=[578 {579 "DeviceName": "string",580 "VirtualName": "string",581 "Ebs": {582 "DeleteOnTermination": True,583 "Iops": 123,584 "SnapshotId": "string",585 "VolumeSize": 123,586 "VolumeType": "standard",587 "KmsKeyId": "string",588 "Throughput": 123,589 "OutpostArn": "string",590 "Encrypted": True,591 },592 "NoDevice": "string",593 },594 ],595 Description="string",596 DryRun=True | False,597 InstanceId="string",598 Name="string",599 NoReboot=True | False,600 TagSpecifications=[601 {602 "ResourceType": "capacity-reservation",603 "Tags": [604 {"Key": "string", "Value": "string"},605 ],606 },607 ],608 )609def test_restjson_parser_path_params_with_slashes():610 _botocore_parser_integration_test(611 service="qldb",612 action="ListTagsForResource",613 ResourceArn="arn:aws:qldb:eu-central-1:000000000000:ledger/c-c67c827a",614 )615def test_parse_cloudtrail_with_botocore():616 _botocore_parser_integration_test(617 service="cloudtrail",618 action="DescribeTrails",619 trailNameList=["t1"],620 )621def test_parse_cloudfront_uri_location_with_botocore():622 _botocore_parser_integration_test(623 service="cloudfront",624 action="GetDistribution",625 Id="001",626 )627def test_parse_cloudfront_payload_with_botocore():628 _botocore_parser_integration_test(629 service="cloudfront",630 action="CreateOriginRequestPolicy",631 OriginRequestPolicyConfig={632 "Comment": "comment1",633 "Name": "name",634 "HeadersConfig": {"HeaderBehavior": "none"},635 "CookiesConfig": {"CookieBehavior": "all"},636 "QueryStringsConfig": {"QueryStringBehavior": "all"},637 },638 )639def test_parse_opensearch_conflicting_request_uris():640 """641 Tests if the operation detection works with conflicting regular expressions:642 - OpenSearch's DescribeDomain (/2021-01-01/opensearch/domain/{DomainName})643 - OpenSearch's DescribeDomainConfig (/2021-01-01/opensearch/domain/{DomainName}/config)644 Since the path parameters are greedy (they might contain slashes), "better" matches need to be preferred.645 """646 _botocore_parser_integration_test(647 service="opensearch",648 action="DescribeDomainConfig",649 DomainName="test-domain",650 )651 _botocore_parser_integration_test(652 service="opensearch",653 action="DescribeDomain",654 DomainName="test-domain",655 )656def test_parse_appconfig_non_json_blob_payload():657 """658 Tests if the parsing works correctly if the request contains a blob payload shape which does not contain valid JSON.659 """660 _botocore_parser_integration_test(661 service="appconfig",662 action="CreateHostedConfigurationVersion",663 ApplicationId="test-application-id",664 ConfigurationProfileId="test-configuration-profile-id",665 Content=b"<html></html>",666 ContentType="application/html",667 )668def test_parse_appconfig_deprecated_operation():669 """670 Tests if the parsing works correctly if the request targets a deprecated operation (without alternative, i.e.671 another function having the same signature).672 """673 _botocore_parser_integration_test(674 service="appconfig",675 action="GetConfiguration",676 Application="test-application",677 Environment="test-environment",678 Configuration="test-configuration",679 ClientId="test-client-id",680 )681def test_parse_s3_with_extended_uri_pattern():682 """683 Tests if the parsing works for operations where the operation defines a request URI with a "+" in the variable name,684 (for example "requestUri":"/{Bucket}/{Key+}").685 The parameter with the "+" directive is greedy. There can only be one explicitly greedy param.686 The corresponding shape definition does not contain the "+" in the "locationName" directive.687 """688 _botocore_parser_integration_test(689 service="s3", action="ListParts", Bucket="foo", Key="bar/test", UploadId="test-upload-id"690 )691def test_parse_s3_utf8_url():692 """Test the parsing of a map with the location trait 'headers'."""693 _botocore_parser_integration_test(694 service="s3",695 action="PutObject",696 ContentLength=0,697 Bucket="test-bucket",698 Key="Ä0",699 Metadata={"Key": "value", "Key2": "value2"},700 )701def test_parse_restjson_uri_location():702 """Tests if the parsing of uri parameters works correctly for the rest-json protocol"""703 _botocore_parser_integration_test(704 service="lambda",705 action="AddPermission",706 Action="lambda:InvokeFunction",707 FunctionName="arn:aws:lambda:us-east-1:000000000000:function:test-forward-sns",708 Principal="sns.amazonaws.com",709 StatementId="2e25f762",710 )711def test_parse_restjson_header_parsing():712 """Tests parsing shapes from the header location."""713 _botocore_parser_integration_test(714 service="ebs",715 action="CompleteSnapshot",716 SnapshotId="123",717 ChangedBlocksCount=5,718 Checksum="test-checksum-header-field",719 )720def test_parse_restjson_querystring_list_parsing():721 """Tests the parsing of lists of shapes with location querystring."""722 _botocore_parser_integration_test(723 service="amplify",724 action="UntagResource",725 resourceArn="arn:aws:lambda:us-east-1:000000000000:function:test-forward-sns",726 tagKeys=["Tag1", "Tag2"],727 )728def test_restjson_operation_detection_with_query_suffix_in_requesturi():729 """730 Test if the correct operation is detected if the requestURI pattern of the specification contains the first query731 parameter, f.e. API Gateway's ImportRestApi: "/restapis?mode=import732 """733 _botocore_parser_integration_test(service="apigateway", action="ImportRestApi", body=b"Test")734def test_rest_url_parameter_with_dashes():735 """736 Test if requestUri parameters with dashes in them (e.g., "/v2/tags/{resource-arn}") are parsed correctly.737 """738 _botocore_parser_integration_test(739 service="apigatewayv2",740 action="GetTags",741 ResourceArn="arn:aws:apigatewayv2:us-east-1:000000000000:foobar",742 )743def test_restxml_operation_detection_with_query_suffix_without_value_in_requesturi():744 """745 Test if the correct operation is detected if the requestURI pattern of the specification contains the first query746 parameter without a specific value, f.e. CloudFront's CreateDistributionWithTags:747 "/2020-05-31/distribution?WithTags"748 """749 _botocore_parser_integration_test(750 service="cloudfront",751 action="CreateDistributionWithTags",752 DistributionConfigWithTags={753 "DistributionConfig": {754 "CallerReference": "string",755 "Origins": {756 "Quantity": 1,757 "Items": [758 {759 "Id": "string",760 "DomainName": "string",761 }762 ],763 },764 "Comment": "string",765 "Enabled": True,766 "DefaultCacheBehavior": {767 "TargetOriginId": "string",768 "ViewerProtocolPolicy": "allow-all",769 },770 },771 "Tags": {772 "Items": [773 {"Key": "string", "Value": "string"},774 ]775 },776 },777 )778def test_restjson_operation_detection_with_length_prio():779 """780 Tests if the correct operation is detected if the requestURI patterns are conflicting and the length of the781 normalized regular expression for the path matching solves the conflict.782 For example: The detection of API Gateway PutIntegrationResponse (without the normalization PutMethodResponse would783 be detected).784 """785 _botocore_parser_integration_test(786 service="apigateway",787 action="PutIntegrationResponse",788 restApiId="rest-api-id",789 resourceId="resource-id",790 httpMethod="POST",791 statusCode="201",792 )793def test_restjson_operation_detection_with_subpath():794 """795 Tests if the operation lookup correctly fails for a subpath of an operation.796 For example: The detection of a URL which is routed through API Gateway.797 """798 service = load_service("apigateway")799 parser = create_parser(service)800 with pytest.raises(OperationNotFoundParserError):801 parser.parse(802 HttpRequest(803 method="GET",804 path="/restapis/cmqinv79uh/local/_user_request_/",805 raw_path="/restapis/cmqinv79uh/local/_user_request_/",806 )807 )808def test_s3_get_operation_detection():809 """810 Test if the S3 operation detection works for ambiguous operations. GetObject is the worst, because it is811 overloaded with the exact same requestURI by another non-deprecated function where the only distinction is the812 matched required parameter.813 """814 _botocore_parser_integration_test(815 service="s3", action="GetObject", Bucket="test-bucket", Key="foo/bar/test.json"816 )817def test_s3_head_operation_detection():818 """Test if the S3 operation detection works for HEAD operations."""819 _botocore_parser_integration_test(820 service="s3", action="HeadObject", Bucket="test-bucket", Key="foo/bar/test.json"821 )822def test_s3_put_object_keys_with_slashes():823 _botocore_parser_integration_test(824 service="s3",825 action="PutObject",826 Bucket="test-bucket",827 Key="/test-key",828 ContentLength=6,829 Body=b"foobar",830 Metadata={},831 )832def test_s3_get_object_keys_with_slashes():833 _botocore_parser_integration_test(834 service="s3",835 action="GetObject",836 Bucket="test-bucket",837 Key="/test-key",838 )839def test_restxml_headers_parsing():840 """Test the parsing of a map with the location trait 'headers'."""841 _botocore_parser_integration_test(842 service="s3",843 action="PutObject",844 ContentLength=0,845 Bucket="test-bucket",846 Key="test.json",847 Metadata={"Key": "value", "Key2": "value2"},848 )849def test_restxml_header_date_parsing():850 """Test the parsing of a map with the location trait 'headers'."""851 _botocore_parser_integration_test(852 service="s3",853 action="PutObject",854 Bucket="test-bucket",855 Key="test-key",856 ContentLength=3,857 Body=b"foo",858 Metadata={},859 Expires=datetime(2015, 1, 1, 0, 0, tzinfo=timezone.utc),860 )861def test_s3_virtual_host_addressing():862 """Test the parsing of a map with the location trait 'headers'."""863 request = HttpRequest(864 method="PUT", headers={"host": s3_utils.get_bucket_hostname("test-bucket")}865 )866 parser = create_parser(load_service("s3"))867 parsed_operation_model, parsed_request = parser.parse(request)868 assert parsed_operation_model.name == "CreateBucket"869 assert "Bucket" in parsed_request870 assert parsed_request["Bucket"] == "test-bucket"871def test_s3_list_buckets_with_localhost():872 # this is the canonical request of `awslocal s3 ls` when running on a standard port873 request = HttpRequest("GET", "/", headers={"host": "localhost"})874 parser = create_parser(load_service("s3"))875 parsed_operation_model, parsed_request = parser.parse(request)876 assert parsed_operation_model.name == "ListBuckets"877def test_s3_list_buckets_with_localhost_and_port():878 # this is the canonical request of `awslocal s3 ls`879 request = HttpRequest("GET", "/", headers={"host": "localhost:4566"})880 parser = create_parser(load_service("s3"))881 parsed_operation_model, parsed_request = parser.parse(request)882 assert parsed_operation_model.name == "ListBuckets"883def test_query_parser_error_on_protocol_error():884 """Test that the parser raises a ProtocolParserError in case of invalid data to parse."""885 parser = QueryRequestParser(load_service("sqs"))886 request = HttpRequest(887 body=to_bytes(888 "Action=UnknownOperation&Version=2012-11-05&"889 "QueueUrl=http%3A%2F%2Flocalhost%3A4566%2F000000000000%2Ftf-acc-test-queue&"890 "MessageBody=%7B%22foo%22%3A+%22bared%22%7D&"891 "DelaySeconds=2"892 ),893 method="POST",894 headers={},895 path="",896 )897 with pytest.raises(ProtocolParserError):898 parser.parse(request)899def test_restjson_parser_error_on_protocol_error():900 request = HttpRequest(901 body="invalid}",902 method="POST",903 path="/2021-01-01/opensearch/domain",904 )905 parser = RestJSONRequestParser(load_service("opensearch"))906 with pytest.raises(ProtocolParserError):907 parser.parse(request)908def test_parser_error_on_unknown_error():909 """Test that the parser raises a UnknownParserError in case of an unknown exception."""910 parser = QueryRequestParser(load_service("sqs"))911 request = HttpRequest(912 body=to_bytes(913 "Action=SendMessage&Version=2012-11-05&"914 "QueueUrl=http%3A%2F%2Flocalhost%3A4566%2F000000000000%2Ftf-acc-test-queue&"915 "MessageBody=%7B%22foo%22%3A+%22bared%22%7D&"916 "DelaySeconds=2"917 ),918 method="POST",919 headers={},920 path="",921 )922 # An unknown error is obviously hard to trigger (because we would fix it if we would know of a way to trigger it),923 # therefore we patch a function to raise an unexpected error924 def raise_error(*args, **kwargs):925 raise NotImplementedError()926 parser._process_member = raise_error927 with pytest.raises(UnknownParserError):928 parser.parse(request)929def test_restjson_get_element_from_location():930 """931 Some GET requests expect a body. While it is allowed in principle by HTTP, it is discouraged and the server932 should ignore the body of a GET request: https://stackoverflow.com/a/983458/804840.933 However, as of May 7, 2022, the following AWS GET requests expect a JSON body:934 - quicksight GET ListIAMPolicyAssignments (member=AssignmentStatus)935 - sesv2 GET ListContacts (member=Filter)936 - sesv2 GET ListImportJobs (member=ImportDestinationType)937 """938 _botocore_parser_integration_test(939 service="sesv2",940 action="ListContacts",941 ContactListName="foobar",942 Filter={943 "FilteredStatus": "OPT_IN",944 "TopicFilter": {945 "TopicName": "atopic",946 "UseDefaultIfPreferenceUnavailable": False,947 },948 },949 )950def test_restjson_raises_error_on_non_json_body():951 request = HttpRequest("GET", "/2021-01-01/opensearch/domain/mydomain", body="foobar")952 parser = create_parser(load_service("opensearch"))...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!