コード例 #1
0
ファイル: test_awslambda.py プロジェクト: kolanos/iopipe-cli
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"]
    )
コード例 #2
0
ファイル: test_awslambda.py プロジェクト: kolanos/iopipe-cli
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"])
コード例 #3
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
コード例 #4
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,
        )