import pandas as pd
import pytest
from heatpro.external_factors import kasuda_soil_temperature, ExternalFactors, SOIL_TEMPERATURE_NAME

# Sample data for testing
sample_data = pd.DataFrame({
    'external_temperature': [10.0, 15.0, 20.0, 25.0, 30.0],
    'heating_season': [True, True, True, False, False],
}, index=pd.date_range('2022-01-01', periods=5, freq='D'))

def test_kasuda_soil_temperature():
    external_factors = ExternalFactors(sample_data)
    d, alpha = 1.0, 0.5
    result = kasuda_soil_temperature(external_factors, d, alpha)

    assert isinstance(result, pd.DataFrame)
    assert SOIL_TEMPERATURE_NAME in result.columns
    assert result.index.equals(sample_data.index)

    # Add more specific assertions based on your expectations

# Additional test for handling invalid input
def test_kasuda_soil_temperature_invalid_input():
    invalid_factors = pd.DataFrame({'temperature': [10.0, 15.0, 20.0]}, index=pd.date_range('2022-01-01', periods=3, freq='D'))
    
    with pytest.raises(ValueError, match="Missing required features"):
        kasuda_soil_temperature(ExternalFactors(invalid_factors), 1.0, 0.5)
