Fix tests

This commit is contained in:
swissalpine 2023-11-30 11:49:54 +01:00 committed by GitHub
parent e6c9e13d51
commit 46c5e82e6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -57,6 +57,10 @@ class GarminPluginTest: TestBase() {
@AfterEach @AfterEach
fun verifyNoFurtherInteractions() { fun verifyNoFurtherInteractions() {
verify(loopHub, atMost(2)).currentProfileName verify(loopHub, atMost(2)).currentProfileName
verify(loopHub, atMost(3)).insulinOnboard
verify(loopHub, atMost(3)).insulinBasalOnboard
verify(loopHub, atMost(3)).temporaryBasal
verify(loopHub, atMost(3)).carbsOnboard
verifyNoMoreInteractions(loopHub) verifyNoMoreInteractions(loopHub)
} }
@ -227,8 +231,8 @@ class GarminPluginTest: TestBase() {
listOf(createGlucoseValue( listOf(createGlucoseValue(
clock.instant().minusSeconds(100L), 99.3))) clock.instant().minusSeconds(100L), 99.3)))
assertEquals( assertEquals(
"""[{"_id":"-900000","device":"RANDOM","deviceString":"1969-12-31T23:58:30Z","sysTime":"1969-12-31T23:58:30Z","unfiltered":90.0,"date":-90000,"sgv":99,"direction":"Flat","noise":4.5,"units_hint":"mmol","iob":4.8,"tbr":"120","cob":12.1}]""", """[{"_id":"-900000","device":"RANDOM","deviceString":"1969-12-31T23:58:30Z","sysTime":"1969-12-31T23:58:30Z","unfiltered":90.0,"date":-90000,"sgv":99,"direction":"Flat","noise":4.5,"units_hint":"mmol","iob":0.0,"tbr":0,"cob":0.0}]""",
gp.onSgv(mock(), createUri(mapOf()), null)) gp.onSgv(mock(), createUri(mapOf()), null))
verify(loopHub).getGlucoseValues(clock.instant().minusSeconds(25L * 300L), false) verify(loopHub).getGlucoseValues(clock.instant().minusSeconds(25L * 300L), false)
verify(loopHub).glucoseUnit verify(loopHub).glucoseUnit
} }
@ -242,20 +246,20 @@ class GarminPluginTest: TestBase() {
.map(Instant::ofEpochMilli) .map(Instant::ofEpochMilli)
.mapIndexed { idx, ts -> createGlucoseValue(ts, 100.0+(10 * idx)) }.reversed()} .mapIndexed { idx, ts -> createGlucoseValue(ts, 100.0+(10 * idx)) }.reversed()}
assertEquals( assertEquals(
"""[{"_id":"100000","device":"RANDOM","deviceString":"1970-01-01T00:00:10Z","sysTime":"1970-01-01T00:00:10Z","unfiltered":90.0,"date":10000,"sgv":120,"delta":10,"direction":"Flat","noise":4.5,"units_hint":"mmol","iob":4.8,"tbr":"120","cob":12.1}]""", """[{"_id":"100000","device":"RANDOM","deviceString":"1970-01-01T00:00:10Z","sysTime":"1970-01-01T00:00:10Z","unfiltered":90.0,"date":10000,"sgv":120,"delta":10,"direction":"Flat","noise":4.5,"units_hint":"mmol","iob":0.0,"tbr":0,"cob":0.0}]""",
gp.onSgv(mock(), createUri(mapOf("count" to "1")), null)) gp.onSgv(mock(), createUri(mapOf("count" to "1")), null))
verify(loopHub).getGlucoseValues( verify(loopHub).getGlucoseValues(
clock.instant().minusSeconds(600L), false) clock.instant().minusSeconds(600L), false)
assertEquals( assertEquals(
"""[{"_id":"100000","device":"RANDOM","deviceString":"1970-01-01T00:00:10Z","sysTime":"1970-01-01T00:00:10Z","unfiltered":90.0,"date":10000,"sgv":130,"delta":10,"direction":"Flat","noise":4.5,"units_hint":"mmol","iob":4.8,"tbr":"120","cob":12.1},""" + """[{"_id":"100000","device":"RANDOM","deviceString":"1970-01-01T00:00:10Z","sysTime":"1970-01-01T00:00:10Z","unfiltered":90.0,"date":10000,"sgv":130,"delta":10,"direction":"Flat","noise":4.5,"units_hint":"mmol","iob":0.0,"tbr":0,"cob":0.0},""" +
"""{"_id":"-2900000","device":"RANDOM","deviceString":"1969-12-31T23:55:10Z","sysTime":"1969-12-31T23:55:10Z","unfiltered":90.0,"date":-290000,"sgv":120,"delta":10,"direction":"Flat","noise":4.5}]""", """{"_id":"-2900000","device":"RANDOM","deviceString":"1969-12-31T23:55:10Z","sysTime":"1969-12-31T23:55:10Z","unfiltered":90.0,"date":-290000,"sgv":120,"delta":10,"direction":"Flat","noise":4.5}]""",
gp.onSgv(mock(), createUri(mapOf("count" to "2")), null)) gp.onSgv(mock(), createUri(mapOf("count" to "2")), null))
verify(loopHub).getGlucoseValues( verify(loopHub).getGlucoseValues(
clock.instant().minusSeconds(900L), false) clock.instant().minusSeconds(900L), false)
assertEquals( assertEquals(
"""[{"date":10000,"sgv":130,"delta":10,"direction":"Flat","noise":4.5,"units_hint":"mmol","iob":4.8,"tbr":"120","cob":12.1},""" + """[{"date":10000,"sgv":130,"delta":10,"direction":"Flat","noise":4.5,"units_hint":"mmol","iob":0.0,"tbr":0,"cob":0.0},""" +
"""{"date":-290000,"sgv":120,"delta":10,"direction":"Flat","noise":4.5}]""", """{"date":-290000,"sgv":120,"delta":10,"direction":"Flat","noise":4.5}]""",
gp.onSgv(mock(), createUri(mapOf("count" to "2", "brief_mode" to "true")), null)) gp.onSgv(mock(), createUri(mapOf("count" to "2", "brief_mode" to "true")), null))
verify(loopHub, times(2)).getGlucoseValues( verify(loopHub, times(2)).getGlucoseValues(