Ejemplo n.º 1
0
async def test_moto_s3_service():
    async with MotoService("s3") as s3_service:
        assert s3_service._server  # __aenter__ starts a moto.server

        url = s3_service.endpoint_url
        s3_xmlns = "http://s3.amazonaws.com/doc/2006-03-01"
        async with aiohttp.ClientSession() as session:
            # https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListBuckets.html
            async with session.get(url, timeout=5) as resp:
                assert resp.status == 200
                content = await resp.text()  # ListAllMyBucketsResult XML
                assert s3_xmlns in content
Ejemplo n.º 2
0
async def test_moto_batch_service():
    async with MotoService("batch") as batch_service:
        assert batch_service._server  # __aenter__ starts a moto.server

        url = batch_service.endpoint_url + "/v1/describejobqueues"
        batch_query = {"jobQueues": [], "maxResults": 10}
        async with aiohttp.ClientSession() as session:
            async with session.post(url, data=batch_query, timeout=5) as resp:
                assert resp.status == 200
                job_queues = await resp.text()
                job_queues = json.loads(job_queues)
                assert job_queues["jobQueues"] == []
Ejemplo n.º 3
0
def test_moto_service():
    # this instantiates a MotoService but does not start a server
    service = MotoService("s3")
    assert HOST in service.endpoint_url
    assert service._server is None
Ejemplo n.º 4
0
async def aio_aws_logs_server():
    # cloud watch logs
    async with MotoService("logs") as svc:
        svc.reset()
        yield svc.endpoint_url
Ejemplo n.º 5
0
async def aio_aws_sqs_server():
    async with MotoService("sqs") as svc:
        svc.reset()
        yield svc.endpoint_url
Ejemplo n.º 6
0
async def aio_aws_dynamodb2_server():
    async with MotoService("dynamodb2") as svc:
        svc.reset()
        yield svc.endpoint_url
Ejemplo n.º 7
0
async def aio_aws_iam_server():
    async with MotoService("iam") as svc:
        yield svc.endpoint_url
Ejemplo n.º 8
0
async def aio_aws_cloudformation_server():
    async with MotoService("cloudformation") as svc:
        svc.reset()
        yield svc.endpoint_url
Ejemplo n.º 9
0
async def aio_aws_batch_server():
    async with MotoService("batch") as svc:
        svc.reset()
        yield svc.endpoint_url
Ejemplo n.º 10
0
 async def _get_client(service_name):
     async with MotoService(service_name) as srv:
         async with aio_aws_session.create_client(
                 service_name, endpoint_url=srv.endpoint_url) as client:
             yield client