Beispiel #1
0
def test_call_with_sqs_modifies_state_in_moto_backend():
    """Whitebox test to check that moto backends are populated correctly"""
    from moto.sqs.models import sqs_backends

    qname = f"queue-{short_uid()}"

    response = moto.call_moto(
        moto.create_aws_request_context("sqs", "CreateQueue",
                                        {"QueueName": qname}))
    url = response["QueueUrl"]
    assert qname in sqs_backends.get(config.AWS_REGION_US_EAST_1).queues
    moto.call_moto(
        moto.create_aws_request_context("sqs", "DeleteQueue",
                                        {"QueueUrl": url}))
    assert qname not in sqs_backends.get(config.AWS_REGION_US_EAST_1).queues
Beispiel #2
0
def test_call_with_modified_request():
    from moto.sqs.models import sqs_backends

    qname1 = f"queue-{short_uid()}"
    qname2 = f"queue-{short_uid()}"

    context = moto.create_aws_request_context("sqs", "CreateQueue",
                                              {"QueueName": qname1})
    response = moto.call_moto_with_request(
        context, {"QueueName": qname2})  # overwrite old request

    url = response["QueueUrl"]
    assert qname2 in sqs_backends.get(config.AWS_REGION_US_EAST_1).queues
    assert qname1 not in sqs_backends.get(config.AWS_REGION_US_EAST_1).queues

    moto.call_moto(
        moto.create_aws_request_context("sqs", "DeleteQueue",
                                        {"QueueUrl": url}))
Beispiel #3
0
def test_call_multi_region_backends():
    from moto.sqs.models import sqs_backends

    qname_us = f"queue-us-{short_uid()}"
    qname_eu = f"queue-eu-{short_uid()}"

    moto.call_moto(
        moto.create_aws_request_context("sqs",
                                        "CreateQueue", {"QueueName": qname_us},
                                        region="us-east-1"))
    moto.call_moto(
        moto.create_aws_request_context("sqs",
                                        "CreateQueue", {"QueueName": qname_eu},
                                        region="eu-central-1"))

    assert qname_us in sqs_backends.get("us-east-1").queues
    assert qname_eu not in sqs_backends.get("us-east-1").queues

    assert qname_us not in sqs_backends.get("eu-central-1").queues
    assert qname_eu in sqs_backends.get("eu-central-1").queues

    del sqs_backends.get("us-east-1").queues[qname_us]
    del sqs_backends.get("eu-central-1").queues[qname_eu]