def lambda_ctx() -> LambdaContext: lambda_cognito_identity = LambdaCognitoIdentity() lambda_cognito_identity.cognito_identity_id = "cognito_identity_id" lambda_cognito_identity.cognito_identity_pool_id = "cognito_identity_pool_id" lambda_client_context_mobile_client = LambdaClientContextMobileClient() lambda_client_context_mobile_client.installation_id = "installation_id" lambda_client_context_mobile_client.app_title = "app_title" lambda_client_context_mobile_client.app_version_name = "app_version_name" lambda_client_context_mobile_client.app_version_code = "app_version_code" lambda_client_context_mobile_client.app_package_name = "app_package_name" lambda_client_context = LambdaClientContext() lambda_client_context.client = lambda_client_context_mobile_client lambda_client_context.custom = {"custom": True} lambda_client_context.env = {"env": "test"} lambda_context = LambdaContext() lambda_context.function_name = "function_name" lambda_context.function_version = "function_version" lambda_context.invoked_function_arn = "invoked_function_arn" lambda_context.memory_limit_in_mb = 1234 lambda_context.aws_request_id = "aws_request_id" lambda_context.log_group_name = "log_group_name" lambda_context.log_stream_name = "log_stream_name" lambda_context.identity = lambda_cognito_identity lambda_context.client_context = lambda_client_context return lambda_context
def mock_context(): context = LambdaContext() context.function_name = 'test' context.function_version = 'test' context.invoked_function_arn = 'test' context.memory_limit_in_mb = 'test' context.aws_request_id = 'test' context.log_group_name = 'test' context.log_stream_name = 'test' return context
parser.add_argument( "--cache_url", required=False, default="", help="memcache configuration url is host:port form") parser.add_argument("--daemon", action="store_true") args = parser.parse_args() test_event = { "program": args.program, "api_token": args.token, "cache_url": args.cache_url, "daemon": args.daemon } if args.endpoint: test_event["api_endpoint"] = args.endpoint if args.start_time_ms: test_event["start_time_ms"] = args.start_time_ms if args.end_time_ms: test_event["end_time_ms"] = args.end_time_ms if args.resolution_hint_ms: test_event["resolution_hint_ms"] = args.resolution_hint_ms context = LambdaContext() context.aws_request_id = utils.millitime() context.invoked_function_arn = None lambda_handler(test_event, context) except Exception as e: print("Exception", e, traceback.format_exc()) os._exit(1)