Skip to content

Commit

Permalink
test: amsterdam 2020-01-01 with models
Browse files Browse the repository at this point in the history
  • Loading branch information
DadiBit committed Jun 5, 2023
1 parent 5ccc68d commit a7a41ad
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions lib/src/test/kotlin/com/openmeteo/api/HistoricalTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,74 @@ class HistoricalTest {
}
}



@Test
fun `Amsterdam, 1st January 2020, with models`() {
val query = Historical.Query(
latitude = City.Amsterdam.latitude,
longitude = City.Amsterdam.longitude,
hourly = Options.list(Historical.Hourly) { of(
temperature2m
) },
startDate = Date("2020-01-01"),
endDate = Date("2020-01-01"),
models = Options.list(Historical.Models) { of(
era5, cerra
) }
)
Historical(query)
.getOrThrow().run {
assertEquals(52.25f, latitude)
assertEquals(5f, longitude)
assertEquals(0, utcOffsetSeconds)
assertEquals("GMT", timezone.id)
assertEquals("GMT", timezoneAbbreviation)
assertEquals(17f, elevation)
assert(hourlyUnits == mapOf(
"time" to Unit.UnixTime,
"temperature_2m_era5" to Unit.Celsius,
"temperature_2m_cerra" to Unit.Celsius,
)
)
assertContains(hourlyValues, "time")
assertContentEquals(arrayOf(
1577836800.0,
1577840400.0,
1577844000.0,
1577847600.0,
1577851200.0,
1577854800.0,
1577858400.0,
1577862000.0,
1577865600.0,
1577869200.0,
1577872800.0,
1577876400.0,
1577880000.0,
1577883600.0,
1577887200.0,
1577890800.0,
1577894400.0,
1577898000.0,
1577901600.0,
1577905200.0,
1577908800.0,
1577912400.0,
1577916000.0,
1577919600.0
), hourlyValues["time"])
assertContains(hourlyValues, "temperature_2m_era5")
assertContentEquals(
arrayOf(1.9, 1.8, 1.5, 1.5, 1.2, 1.2, 1.1, 0.8, 0.5, 0.5, 0.6, 1.0, 1.3, 1.4, 1.2, 1.5, 0.9, 0.6, 0.4, 0.3, 0.6, 1.1, 1.4, 1.5),
hourlyValues["temperature_2m_era5"]
)
assertContains(hourlyValues, "temperature_2m_cerra")
assertContentEquals(
arrayOf(1.1, 0.6, 0.1, -0.3, 0.0, 0.3, 0.9, 1.1, 1.2, 1.4, 1.7, 2.0, 2.2, 2.5, 2.4, 2.2, 1.7, 1.2, 0.5, 0.1, -0.1, -0.1, 0.2, 0.1),
hourlyValues["temperature_2m_cerra"]
)
}
}

}

0 comments on commit a7a41ad

Please sign in to comment.