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"] )
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"])
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
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, )