Best Python code snippet using localstack_python
apigateway_fixtures.py
Source:apigateway_fixtures.py
...24 assert response.get("ResponseMetadata").get("HTTPStatusCode") == status25def assert_response_is_200(response: Dict) -> bool:26 assert_response_status(response, 200)27 return True28def assert_response_is_201(response: Dict) -> bool:29 assert_response_status(response, 201)30 return True31def create_rest_api(apigateway_client, **kwargs):32 response = apigateway_client.create_rest_api(**kwargs)33 assert_response_is_201(response)34 resources = apigateway_client.get_resources(restApiId=response.get("id"))35 root_id = next(item for item in resources["items"] if item["path"] == "/")["id"]36 return response.get("id"), response.get("name"), root_id37def import_rest_api(apigateway_client, **kwargs):38 response = apigateway_client.import_rest_api(**kwargs)39 assert_response_is_201(response)40 resources = apigateway_client.get_resources(restApiId=response.get("id"))41 root_id = next(item for item in resources["items"] if item["path"] == "/")["id"]42 return response.get("id"), response.get("name"), root_id43def get_rest_api(apigateway_client, **kwargs):44 response = apigateway_client.get_rest_api(**kwargs)45 assert_response_is_200(response)46 return response.get("id"), response.get("name")47def get_rest_apis(apigateway_client, **kwargs):48 response = apigateway_client.get_rest_apis(**kwargs)49 assert_response_is_200(response)50 return response.get("items")51def delete_rest_api(apigateway_client, **kwargs):52 response = apigateway_client.delete_rest_api(**kwargs)53 assert_response_status(response, 202)54def create_rest_resource(apigateway_client, **kwargs):55 response = apigateway_client.create_resource(**kwargs)56 assert_response_is_201(response)57 return response.get("id"), response.get("parentId")58def delete_rest_resource(apigateway_client, **kwargs):59 response = apigateway_client.delete_resource(**kwargs)60 assert_response_is_200(response)61def create_rest_resource_method(apigateway_client, **kwargs):62 response = apigateway_client.put_method(**kwargs)63 assert_response_is_201(response)64 return response.get("httpMethod"), response.get("authorizerId")65def create_rest_authorizer(apigateway_client, **kwargs):66 response = apigateway_client.create_authorizer(**kwargs)67 assert_response_is_201(response)68 return response.get("id"), response.get("type")69def create_rest_api_integration(apigateway_client, **kwargs):70 response = apigateway_client.put_integration(**kwargs)71 assert_response_is_201(response)72 return response.get("uri"), response.get("type")73def delete_rest_api_integration(apigateway_client, **kwargs):74 response = apigateway_client.delete_integration(**kwargs)75 assert_response_is_200(response)76def get_rest_api_integration(apigateway_client, **kwargs):77 response = apigateway_client.get_integration(**kwargs)78 assert_response_is_200(response)79def create_rest_api_method_response(apigateway_client, **kwargs):80 response = apigateway_client.put_method_response(**kwargs)81 assert_response_is_201(response)82 return response.get("statusCode")83def create_rest_api_integration_response(apigateway_client, **kwargs):84 response = apigateway_client.put_integration_response(**kwargs)85 assert_response_is_201(response)86 return response.get("statusCode")87def create_domain_name(apigateway_client, **kwargs):88 response = apigateway_client.create_domain_name(**kwargs)89 assert_response_is_201(response)90def create_base_path_mapping(apigateway_client, **kwargs):91 response = apigateway_client.create_base_path_mapping(**kwargs)92 assert_response_is_201(response)93 return response.get("basePath"), response.get("stage")94def create_rest_api_deployment(apigateway_client, **kwargs):95 response = apigateway_client.create_deployment(**kwargs)96 assert_response_is_201(response)97 return response.get("id"), response.get("createdDate")98def update_rest_api_deployment(apigateway_client, **kwargs):99 response = apigateway_client.update_deployment(**kwargs)100 assert_response_is_200(response)101 return response102def create_rest_api_stage(apigateway_client, **kwargs):103 response = apigateway_client.create_stage(**kwargs)104 assert_response_is_201(response)105 return response.get("stageName")106def create_cognito_user_pool(cognito_idp, **kwargs):107 response = cognito_idp.create_user_pool(**kwargs)108 assert_response_is_200(response)109 return response.get("UserPool").get("Id"), response.get("UserPool").get("Arn")110def delete_cognito_user_pool(cognito_idp, **kwargs):111 response = cognito_idp.delete_user_pool(**kwargs)112 assert_response_is_200(response)113def create_cognito_user_pool_client(cognito_idp, **kwargs):114 response = cognito_idp.create_user_pool_client(**kwargs)115 assert_response_is_200(response)116 return (117 response.get("UserPoolClient").get("ClientId"),118 response.get("UserPoolClient").get("ClientName"),...
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!!