|
146 | 146 | end |
147 | 147 | end |
148 | 148 |
|
| 149 | +@testset "Check flow_both does not only contain non-transport flows" begin |
| 150 | + @testset "Using fake data" begin |
| 151 | + flow = DataFrame( |
| 152 | + :from_asset => ["A1", "A2"], |
| 153 | + :to_asset => ["B", "B"], |
| 154 | + :is_transport => [false, true], |
| 155 | + ) |
| 156 | + flow_both = DataFrame( |
| 157 | + :from_asset => ["A1", "A2"], |
| 158 | + :to_asset => ["B", "B"], |
| 159 | + :milestone_year => [1, 2], |
| 160 | + :commission_year => [1, 2], |
| 161 | + ) |
| 162 | + connection = DBInterface.connect(DuckDB.DB) |
| 163 | + DuckDB.register_data_frame(connection, flow, "flow") |
| 164 | + DuckDB.register_data_frame(connection, flow_both, "flow_both") |
| 165 | + |
| 166 | + error_messages = |
| 167 | + TEM._validate_flow_both_table_does_not_contain_non_transport_flows!(connection) |
| 168 | + @test error_messages == [ |
| 169 | + "Unexpected (flow=('A1', 'B'), milestone_year=1, commission_year=1) in 'flow_both' because 'flow_both' should only contain transport flows.", |
| 170 | + ] |
| 171 | + end |
| 172 | + |
| 173 | + @testset "Using Multi-year data" begin |
| 174 | + connection = _multi_year_fixture() |
| 175 | + DuckDB.query( |
| 176 | + connection, |
| 177 | + """ |
| 178 | + INSERT INTO flow_both (from_asset, to_asset, milestone_year, commission_year) |
| 179 | + VALUES ('wind', 'demand', 2030, 2030); |
| 180 | + """, |
| 181 | + ) |
| 182 | + |
| 183 | + error_messages = |
| 184 | + TEM._validate_flow_both_table_does_not_contain_non_transport_flows!(connection) |
| 185 | + @test error_messages == [ |
| 186 | + "Unexpected (flow=('wind', 'demand'), milestone_year=2030, commission_year=2030) in 'flow_both' because 'flow_both' should only contain transport flows.", |
| 187 | + ] |
| 188 | + end |
| 189 | +end |
| 190 | + |
149 | 191 | @testset "Check that foreign keys are valid" begin |
150 | 192 | @testset "Using fake data" begin |
151 | 193 | # Main table |
|
0 commit comments