async def s3_client(request, region, config, event_loop, s3_server, bucket_name): session = Session(region_name=region, **moto_config()) async with session.client('s3', region_name=region, endpoint_url=s3_server, config=config) as client: yield client
async def s3_resource(request, region, config, event_loop, s3_server, bucket_name): session = Session(region_name=region, **moto_config()) async with session.resource('s3', region_name=region, endpoint_url=s3_server, config=config) as resource: yield resource
async def dynamodb_resource(request, region, config, event_loop, dynamodb2_server): session = Session(region_name=region, **moto_config()) async with session.resource('dynamodb', region_name=region, endpoint_url=dynamodb2_server, config=config) as resource: yield resource
def s3_client(request, region, config, event_loop, s3_server, bucket_name): session = Session(region_name=region, loop=event_loop, **moto_config()) client = session.client('s3', region_name=region, endpoint_url=s3_server, config=config) yield client def fin(): event_loop.run_until_complete(client.close()) request.addfinalizer(fin)
def dynamodb_resource(request, region, config, event_loop, dynamodb2_server): session = Session(region_name=region, loop=event_loop, **moto_config()) resource = session.resource('dynamodb', region_name=region, endpoint_url=dynamodb2_server, config=config) yield resource def fin(): event_loop.run_until_complete(resource.close()) request.addfinalizer(fin)
def setup_default_session(**kwargs): """ Set up a default session, passing through any parameters to the session constructor. There is no need to call this unless you wish to pass custom parameters, because a default session will be created for you. """ global DEFAULT_SESSION DEFAULT_SESSION = Session(**kwargs)
def s3_resource(request, region, config, event_loop, s3_server, bucket_name): session = Session(region_name=region, loop=event_loop, **moto_config()) async def f(): return session.resource('s3', region_name=region, endpoint_url=s3_server, config=config) resource = event_loop.run_until_complete(f()) yield resource def fin(): event_loop.run_until_complete(resource.close()) request.addfinalizer(fin)