|
104 | 104 | @test all(scenario1_rows.value .≈ 0.9) |
105 | 105 | @test all(scenario2_rows.value .≈ 0.8) |
106 | 106 | end |
| 107 | + |
| 108 | +@testitem "Timeframe profiles across multiple milestone years" tags = |
| 109 | + [:unit, :fast, :schema] setup = [CommonSetup, CreateConnectionSetup, TestSchema] begin |
| 110 | + using DuckDB: DuckDB |
| 111 | + using DataFrames: DataFrame |
| 112 | + |
| 113 | + tulipa = TulipaData() |
| 114 | + add_asset!(tulipa, "storage", :storage) |
| 115 | + attach_profile!(tulipa, "storage", :availability, 2030, ones(24)) |
| 116 | + attach_profile!(tulipa, "storage", :availability, 2040, ones(48)) |
| 117 | + attach_timeframe_profile!(tulipa, "storage", :max_storage_level, 2030, 0.9 .* ones(5)) |
| 118 | + attach_timeframe_profile!(tulipa, "storage", :max_storage_level, 2040, 0.7 .* ones(8)) |
| 119 | + |
| 120 | + connection = create_connection(tulipa, TestSchema.schema) |
| 121 | + |
| 122 | + atp_df = |
| 123 | + DuckDB.query( |
| 124 | + connection, |
| 125 | + "SELECT * FROM assets_timeframe_profiles ORDER BY milestone_year", |
| 126 | + ) |> DataFrame |
| 127 | + @test size(atp_df, 1) == 2 |
| 128 | + @test atp_df.milestone_year == [2030, 2040] |
| 129 | + @test all(atp_df.asset .== "storage") |
| 130 | + |
| 131 | + tf_df = |
| 132 | + DuckDB.query( |
| 133 | + connection, |
| 134 | + "SELECT * FROM profiles_timeframe ORDER BY milestone_year, period", |
| 135 | + ) |> DataFrame |
| 136 | + @test size(tf_df, 1) == 13 # 5 periods (2030) + 8 periods (2040) |
| 137 | + rows_2030 = filter(r -> r.milestone_year == 2030, tf_df) |
| 138 | + rows_2040 = filter(r -> r.milestone_year == 2040, tf_df) |
| 139 | + @test size(rows_2030, 1) == 5 |
| 140 | + @test size(rows_2040, 1) == 8 |
| 141 | + @test all(rows_2030.value .≈ 0.9) |
| 142 | + @test all(rows_2040.value .≈ 0.7) |
| 143 | +end |
0 commit comments