def test_config_required_keys(config_file):
    """Test that all required sections and keys (per R2RConfig.REQUIRED_KEYS)
    exist.

    In the new structure the 'agent' section no longer includes the key
    'generation_config', so we filter that out.
    """
    if config_file == "r2r.toml":
        file_path = Path(__file__).parent.parent.parent / "r2r/r2r.toml"
    else:
        file_path = (Path(__file__).parent.parent.parent / "core" / "configs" /
                     config_file)

    with open(file_path) as f:
        config_data = toml.load(f)

    config = R2RConfig(config_data)

    # Check for required sections
    for section in R2RConfig.REQUIRED_KEYS:
        assert hasattr(config, section), f"Missing required section: {section}"

    # Check for required keys in each section.
    # For the agent section, remove 'generation_config' since it no longer exists.
    for section, required_keys in R2RConfig.REQUIRED_KEYS.items():
        keys_to_check = required_keys
        if section == "agent":
            keys_to_check = [
                key for key in required_keys if key != "generation_config"
            ]
        if keys_to_check:
            section_config = getattr(config, section)
            for key in keys_to_check:
                if isinstance(section_config, dict):
                    assert key in section_config, (
                        f"Missing required key {key} in section {section}")
                else:
                    assert hasattr(section_config, key), (
                        f"Missing required key {key} in section {section}")
Test that all required sections and keys (per R2RConfig.REQUIRED_KEYS)
    exist.

    In the new structure the 'agent' section no longer includes the key
    'generation_config', so we filter that out.
    
py/tests/unit/app/test_config.py