示例#1
0
def test_add_iopipe_error_no_token(runtime_config):
    with pytest.raises(awslambda.UpdateLambdaException):
        awslambda._add_iopipe(
            _mock_function_config(runtime_config.get("runtime")),
            "us-east-1",
            "fakeArn",
            None,
            None,
            runtime_config.get("java_type"),
            None,
        )
示例#2
0
def test_add_iopipe_keeps_existing_layers(runtime_config):
    fake_function_config = _mock_function_config(runtime_config.get("runtime"))
    result = awslambda._add_iopipe(
        fake_function_config,
        "us-east-1",
        "fakeArn",
        None,
        TEST_TOKEN,
        runtime_config.get("java_type"),
        None,
    )
    assert "existing_layer_arn" in result["Layers"]
示例#3
0
def test_add_iopipe_updates_handler(runtime_config):
    fake_function_config = _mock_function_config(runtime_config.get("runtime"))
    result = awslambda._add_iopipe(
        fake_function_config,
        "us-east-1",
        "fakeArn",
        None,
        TEST_TOKEN,
        runtime_config.get("java_type"),
        None,
    )
    assert utils.is_valid_handler(runtime_config.get("runtime"), result["Handler"])
示例#4
0
def test_on_off_on_again(runtime_config):
    fake_function_config = _mock_function_config(runtime_config.get("runtime"))
    print("Mock function: %s" % (fake_function_config,))
    wrapped = utils.local_apply_updates(
        fake_function_config,
        awslambda._add_iopipe(
            fake_function_config,
            "us-east-1",
            "fakeArn",
            None,
            TEST_TOKEN,
            runtime_config.get("java_type"),
            None,
        ),
    )
    print("Wrapped: %s" % (wrapped,))
    assert utils.is_valid_handler(
        runtime_config.get("runtime"), wrapped["Configuration"]["Handler"]
    )

    removal_updates = awslambda._remove_iopipe(wrapped, "us-east-1", "fakeArn", None)
    unwrapped = utils.local_apply_updates(wrapped, removal_updates)
    print("Unwrapped: %s" % (unwrapped,))
    assert not utils.is_valid_handler(
        runtime_config.get("runtime"), unwrapped["Configuration"]["Handler"]
    )

    rewrapped_updates = awslambda._add_iopipe(
        unwrapped,
        "us-east-1",
        "fakeArn",
        None,
        TEST_TOKEN,
        runtime_config.get("java_type"),
        None,
    )
    print("Rewrapped: %s" % (rewrapped_updates,))
    assert utils.is_valid_handler(
        runtime_config.get("runtime"), rewrapped_updates["Handler"]
    )
示例#5
0
def test_add_iopipe_upgrade_success(runtime_config):
    fake_function_config = _mock_function_config(runtime_config.get("runtime"))
    wrapped = utils.local_apply_updates(
        fake_function_config,
        awslambda._add_iopipe(
            fake_function_config,
            "us-east-1",
            "fakeArn",
            None,
            TEST_TOKEN,
            runtime_config.get("java_type"),
            None,
        ),
    )
    result = awslambda._add_iopipe(
        wrapped,
        "us-east-1",
        "fakeArn",
        None,
        TEST_TOKEN,
        runtime_config.get("java_type"),
        True,
    )
    assert result
示例#6
0
def test_add_iopipe_upgrade_requires_flag(runtime_config):
    fake_function_config = _mock_function_config(runtime_config.get("runtime"))
    wrapped = utils.local_apply_updates(
        fake_function_config,
        awslambda._add_iopipe(
            fake_function_config,
            "us-east-1",
            "fakeArn",
            None,
            TEST_TOKEN,
            runtime_config.get("java_type"),
            None,
        ),
    )
    with pytest.raises(awslambda.UpdateLambdaException):
        awslambda._add_iopipe(
            wrapped,
            "us-east-1",
            "fakeArn",
            None,
            TEST_TOKEN,
            runtime_config.get("java_type"),
            None,
        )
示例#7
0
def test_remove_iopipe_removes_handler(runtime_config):
    fake_function_config = _mock_function_config(runtime_config.get("runtime"))
    wrapped = utils.local_apply_updates(
        fake_function_config,
        awslambda._add_iopipe(
            fake_function_config,
            "us-east-1",
            "fakeArn",
            None,
            TEST_TOKEN,
            runtime_config.get("java_type"),
            None,
        ),
    )
    result = awslambda._remove_iopipe(wrapped, "us-east-1", "fakeArn", None)
    assert not utils.is_valid_handler(runtime_config.get("runtime"), result["Handler"])