예제 #1
0
def test_invalid_event():
    get_interfaces()
    return_all_interfaces_to_pool()

    event2 = copy.deepcopy(event)
    event2["source"] = "aws.unknown"
    handler(event2, {})

    _, available, _ = get_interfaces()
    assert len(available) == 3
예제 #2
0
def test_remove_and_add():
    return_all_interfaces_to_pool()

    instances = get_pool_instances("bastion")
    for instance in instances:
        event["detail"]["state"] = "running"
        event["detail"]["instance-id"] = instance.instance_id
        handler(event, {})

    _, available, allocated = get_interfaces()
    assert len(available) == 0

    event["detail"]["state"] = "terminated"
    event["detail"]["instance-id"] = instances[0].instance_id
    handler(event, {})

    _, available, _ = get_interfaces()
    assert len(available) == 0
예제 #3
0
def test_timer():
    get_interfaces()
    return_all_interfaces_to_pool()

    event = {
        "detail-type": "Scheduled Event",
        "source": "aws.events",
        "detail": {}
    }
    handler(event, {})

    _, available, _ = get_interfaces()
    assert len(available) == 0

    event = {
        "detail-type": "Scheduled Event",
        "source": "aws.events",
        "detail": {}
    }
    handler(event, {})

    _, available, _ = get_interfaces()
    assert len(available) == 0
예제 #4
0
def test_remove_non_existing_instance():
    event["detail"]["state"] = "terminated"
    event["detail"]["instance-id"] = " i-000000000000a4a41"
    handler(event, {})
예제 #5
0
def test_add_non_existing_instance():
    return_all_interfaces_to_pool()
    event["detail"]["state"] = "running"
    event["detail"]["instance-id"] = "i-000000000000a4a41"
    handler(event, {})