Пример #1
0
async def test_moto_s3_service():
    async with MotoService("s3") as s3_service:
        assert s3_service._server  # __aenter__ starts a moto.server
        assert s3_service._main_app
        assert s3_service._main_app.app_instances["s3"]

        s3_service.reset()  # clear all the backends

        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
Пример #2
0
async def test_moto_batch_service():
    async with MotoService("batch") as batch_service:
        assert batch_service._server  # __aenter__ starts a moto.server
        assert batch_service._main_app
        assert batch_service._main_app.app_instances["batch"]

        batch_service.reset()  # clear all the backends

        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"] == []
Пример #3
0
async def aio_aws_lambda_server():
    async with MotoService("lambda") as svc:
        svc.reset()
        yield svc.endpoint_url
        svc.reset()
Пример #4
0
async def aio_aws_dynamodb2_server():
    async with MotoService("dynamodb2") as svc:
        svc.reset()
        yield svc.endpoint_url
        svc.reset()
Пример #5
0
async def aio_aws_iam_server():
    async with MotoService("iam") as svc:
        svc.reset()
        yield svc.endpoint_url
        svc.reset()
Пример #6
0
async def aio_aws_cloudformation_server():
    async with MotoService("cloudformation") as svc:
        svc.reset()
        yield svc.endpoint_url
        svc.reset()
Пример #7
0
async def aio_aws_batch_server():
    async with MotoService("batch") as svc:
        svc.reset()
        yield svc.endpoint_url
        svc.reset()
Пример #8
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
Пример #9
0
async def aio_aws_logs_server():
    # cloud watch logs
    async with MotoService("logs") as svc:
        svc.reset()
        yield svc.endpoint_url
        svc.reset()
Пример #10
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