def test_aws_s3_client(aws_s3_client):
    client = aws_s3_client
    assert isinstance(client, BaseClient)
    assert client.meta.config.region_name == AWS_REGION
    assert client.meta.region_name == AWS_REGION

    resp = client.list_buckets()
    assert response_success(resp)
    assert resp.get("Buckets") == []

    # the event-name mocks are dynamically generated after calling the method
    assert has_moto_mocks(client, "before-send.s3.ListBuckets")
def test_aws_iam_client(aws_iam_client):
    client = aws_iam_client
    assert isinstance(client, BaseClient)
    assert client.meta.config.region_name == "aws-global"  # not AWS_REGION
    assert client.meta.region_name == "aws-global"  # not AWS_REGION

    resp = client.list_roles()
    assert response_success(resp)
    assert resp.get("Roles") == []

    # the event-name mocks are dynamically generated after calling the method
    assert has_moto_mocks(client, "before-send.iam.ListRoles")
def test_aws_ecs_client(aws_ecs_client):
    client = aws_ecs_client
    assert isinstance(client, BaseClient)
    assert client.meta.config.region_name == AWS_REGION
    assert client.meta.region_name == AWS_REGION

    resp = client.list_task_definitions()
    assert response_success(resp)
    assert resp.get("taskDefinitionArns") == []

    # the event-name mocks are dynamically generated after calling the method
    assert has_moto_mocks(client, "before-send.ecs.ListTaskDefinitions")
def test_aws_ec2_client(aws_ec2_client):
    client = aws_ec2_client
    assert isinstance(client, BaseClient)
    assert client.meta.config.region_name == AWS_REGION
    assert client.meta.region_name == AWS_REGION

    resp = client.describe_instances()
    assert response_success(resp)
    assert resp.get("Reservations") == []

    # the event-name mocks are dynamically generated after calling the method
    assert has_moto_mocks(client, "before-send.ec2.DescribeInstances")
示例#5
0
async def test_aio_aws_iam_client(aio_aws_iam_client):
    client = aio_aws_iam_client
    assert isinstance(client, AioBaseClient)
    assert client.meta.config.region_name == "aws-global"  # not AWS_REGION
    assert client.meta.region_name == "aws-global"  # not AWS_REGION

    resp = await client.list_roles()
    assert response_success(resp)
    assert resp.get("Roles") == []

    # the event-name mocks are dynamically generated after calling the method;
    # for aio-clients, they should be disabled for aiohttp to hit moto.server.
    assert not has_moto_mocks(client, "before-send.iam.ListRoles")
示例#6
0
async def test_aio_aws_ecs_client(aio_aws_ecs_client):
    client = aio_aws_ecs_client
    assert isinstance(client, AioBaseClient)
    assert client.meta.config.region_name == AWS_REGION
    assert client.meta.region_name == AWS_REGION

    resp = await client.list_task_definitions()
    assert response_success(resp)
    assert resp.get("taskDefinitionArns") == []

    # the event-name mocks are dynamically generated after calling the method;
    # for aio-clients, they should be disabled for aiohttp to hit moto.server.
    assert not has_moto_mocks(client, "before-send.ecs.ListTaskDefinitions")
def test_aws_logs_client(aws_logs_client):
    client = aws_logs_client
    assert isinstance(client, BaseClient)
    assert client.meta.config.region_name == AWS_REGION
    assert client.meta.region_name == AWS_REGION

    resp = client.describe_log_groups()
    assert response_success(resp)
    assert resp.get("logGroups") == []

    # the event-name mocks are dynamically generated after calling the method
    assert has_moto_mocks(client,
                          "before-send.cloudwatch-logs.DescribeLogGroups")
示例#8
0
async def test_aio_aws_batch_client(aio_aws_batch_client):
    client = aio_aws_batch_client
    assert isinstance(client, AioBaseClient)

    assert client.meta.config.region_name == AWS_REGION
    assert client.meta.region_name == AWS_REGION

    resp = await client.describe_job_queues()
    assert response_success(resp)
    assert resp.get("jobQueues") == []

    # the event-name mocks are dynamically generated after calling the method;
    # for aio-clients, they should be disabled for aiohttp to hit moto.server.
    assert not has_moto_mocks(client, "before-send.batch.DescribeJobQueues")
示例#9
0
async def test_aio_aws_client(aio_aws_client):
    # aio_aws_client is an async generator
    # aio_aws_client(service_name) yields a client
    async for client in aio_aws_client("s3"):
        assert isinstance(client, AioBaseClient)
        assert client.meta.config.region_name == AWS_REGION
        assert client.meta.region_name == AWS_REGION

        resp = await client.list_buckets()
        assert response_success(resp)
        assert resp.get("Buckets") == []

        # the event-name mocks are dynamically generated after calling the method;
        # for aio-clients, they should be disabled for aiohttp to hit moto.server.
        assert not has_moto_mocks(client, "before-send.s3.ListBuckets")
示例#10
0
async def test_aio_aws_bucket_access(aio_aws_s3_client, aio_s3_bucket):
    resp = await aio_aws_s3_client.list_buckets()
    assert response_success(resp)
    bucket_names = [b["Name"] for b in resp["Buckets"]]
    assert bucket_names == [aio_s3_bucket]
示例#11
0
async def aio_s3_bucket(aio_s3_bucket_name, aio_aws_s3_client) -> str:
    resp = await aio_aws_s3_client.create_bucket(Bucket=aio_s3_bucket_name)
    assert response_success(resp)
    head = await aio_aws_s3_client.head_bucket(Bucket=aio_s3_bucket_name)
    assert response_success(head)
    return aio_s3_bucket_name
示例#12
0
def s3_bucket(s3_bucket_name, aws_s3_client) -> str:
    resp = aws_s3_client.create_bucket(Bucket=s3_bucket_name)
    assert response_success(resp)
    head = aws_s3_client.head_bucket(Bucket=s3_bucket_name)
    assert response_success(head)
    return s3_bucket_name