parent
102cac6fa8
commit
df233bbb81
1 changed files with 23 additions and 25 deletions
|
@ -11,6 +11,7 @@ import app.aaps.core.interfaces.utils.DecimalFormatter
|
||||||
import app.aaps.implementation.utils.DecimalFormatterImpl
|
import app.aaps.implementation.utils.DecimalFormatterImpl
|
||||||
import app.aaps.shared.tests.TestBase
|
import app.aaps.shared.tests.TestBase
|
||||||
import app.aaps.shared.tests.rx.TestAapsSchedulers
|
import app.aaps.shared.tests.rx.TestAapsSchedulers
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil
|
||||||
|
@ -19,7 +20,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.eros.manager.AapsOmnipodE
|
||||||
import info.nightscout.pump.common.defs.TempBasalPair
|
import info.nightscout.pump.common.defs.TempBasalPair
|
||||||
import org.joda.time.DateTimeZone
|
import org.joda.time.DateTimeZone
|
||||||
import org.joda.time.tz.UTCProvider
|
import org.joda.time.tz.UTCProvider
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.ArgumentMatchers
|
import org.mockito.ArgumentMatchers
|
||||||
|
@ -100,17 +100,17 @@ class OmnipodErosPumpPluginTest : TestBase() {
|
||||||
val result5 =
|
val result5 =
|
||||||
plugin.setTempBasalPercent(-50, 60, profile, false, PumpSync.TemporaryBasalType.NORMAL)
|
plugin.setTempBasalPercent(-50, 60, profile, false, PumpSync.TemporaryBasalType.NORMAL)
|
||||||
// Then return correct values
|
// Then return correct values
|
||||||
Assertions.assertEquals(result1.absolute, 0.4, 0.01)
|
assertThat(result1.absolute).isWithin(0.01).of(0.4)
|
||||||
Assertions.assertEquals(result1.duration, 30)
|
assertThat(result1.duration).isEqualTo(30)
|
||||||
Assertions.assertEquals(result2.absolute, 25.0, 0.01)
|
assertThat(result2.absolute).isWithin(0.01).of(25.0)
|
||||||
Assertions.assertEquals(result2.duration, 30000)
|
assertThat(result2.duration).isEqualTo(30000)
|
||||||
Assertions.assertEquals(result3.absolute, 0.0, 0.01)
|
assertThat(result3.absolute).isWithin(0.01).of(0.0)
|
||||||
Assertions.assertEquals(result3.duration, 30)
|
assertThat(result3.duration).isEqualTo(30)
|
||||||
Assertions.assertEquals(result4.absolute, -1.0, 0.01)
|
assertThat(result4.absolute).isWithin(0.01).of(-1.0)
|
||||||
Assertions.assertEquals(result4.duration, -1)
|
assertThat(result4.duration).isEqualTo(-1)
|
||||||
// this is validated downstream, see TempBasalExtraCommand
|
// this is validated downstream, see TempBasalExtraCommand
|
||||||
Assertions.assertEquals(result5.absolute, -0.25, 0.01)
|
assertThat(result5.absolute).isWithin(0.01).of(-0.25)
|
||||||
Assertions.assertEquals(result5.duration, 60)
|
assertThat(result5.duration).isEqualTo(60)
|
||||||
|
|
||||||
// Given zero basal
|
// Given zero basal
|
||||||
`when`(profile.getBasal()).thenReturn(0.0)
|
`when`(profile.getBasal()).thenReturn(0.0)
|
||||||
|
@ -120,10 +120,10 @@ class OmnipodErosPumpPluginTest : TestBase() {
|
||||||
result2 =
|
result2 =
|
||||||
plugin.setTempBasalPercent(0, 0, profile, false, PumpSync.TemporaryBasalType.NORMAL)
|
plugin.setTempBasalPercent(0, 0, profile, false, PumpSync.TemporaryBasalType.NORMAL)
|
||||||
// Then return zero values
|
// Then return zero values
|
||||||
Assertions.assertEquals(result1.absolute, 0.0, 0.01)
|
assertThat(result1.absolute).isWithin(0.01).of(0.0)
|
||||||
Assertions.assertEquals(result1.duration, 90)
|
assertThat(result1.duration).isEqualTo(90)
|
||||||
Assertions.assertEquals(result2.absolute, -1.0, 0.01)
|
assertThat(result2.absolute).isWithin(0.01).of(-1.0)
|
||||||
Assertions.assertEquals(result2.duration, -1)
|
assertThat(result2.duration).isEqualTo(-1)
|
||||||
|
|
||||||
// Given unhealthy basal
|
// Given unhealthy basal
|
||||||
`when`(profile.getBasal()).thenReturn(500.0)
|
`when`(profile.getBasal()).thenReturn(500.0)
|
||||||
|
@ -131,12 +131,10 @@ class OmnipodErosPumpPluginTest : TestBase() {
|
||||||
result1 =
|
result1 =
|
||||||
plugin.setTempBasalPercent(80, 30, profile, false, PumpSync.TemporaryBasalType.NORMAL)
|
plugin.setTempBasalPercent(80, 30, profile, false, PumpSync.TemporaryBasalType.NORMAL)
|
||||||
// Then return sane values
|
// Then return sane values
|
||||||
Assertions.assertEquals(
|
assertThat(result1.absolute).isWithin(0.01).of(
|
||||||
result1.absolute,
|
PumpType.OMNIPOD_EROS.determineCorrectBasalSize(500.0 * 0.8)
|
||||||
PumpType.OMNIPOD_EROS.determineCorrectBasalSize(500.0 * 0.8),
|
|
||||||
0.01
|
|
||||||
)
|
)
|
||||||
Assertions.assertEquals(result1.duration, 30)
|
assertThat(result1.duration).isEqualTo(30)
|
||||||
|
|
||||||
// Given weird basal
|
// Given weird basal
|
||||||
`when`(profile.getBasal()).thenReturn(1.234567)
|
`when`(profile.getBasal()).thenReturn(1.234567)
|
||||||
|
@ -144,8 +142,8 @@ class OmnipodErosPumpPluginTest : TestBase() {
|
||||||
result1 =
|
result1 =
|
||||||
plugin.setTempBasalPercent(280, 600, profile, false, PumpSync.TemporaryBasalType.NORMAL)
|
plugin.setTempBasalPercent(280, 600, profile, false, PumpSync.TemporaryBasalType.NORMAL)
|
||||||
// Then return sane values
|
// Then return sane values
|
||||||
Assertions.assertEquals(result1.absolute, 3.4567876, 0.01)
|
assertThat(result1.absolute).isWithin(0.01).of(3.4567876)
|
||||||
Assertions.assertEquals(result1.duration, 600)
|
assertThat(result1.duration).isEqualTo(600)
|
||||||
|
|
||||||
// Given negative basal
|
// Given negative basal
|
||||||
`when`(profile.getBasal()).thenReturn(-1.234567)
|
`when`(profile.getBasal()).thenReturn(-1.234567)
|
||||||
|
@ -153,7 +151,7 @@ class OmnipodErosPumpPluginTest : TestBase() {
|
||||||
result1 =
|
result1 =
|
||||||
plugin.setTempBasalPercent(280, 510, profile, false, PumpSync.TemporaryBasalType.NORMAL)
|
plugin.setTempBasalPercent(280, 510, profile, false, PumpSync.TemporaryBasalType.NORMAL)
|
||||||
// Then return negative value (this is validated further downstream, see TempBasalExtraCommand)
|
// Then return negative value (this is validated further downstream, see TempBasalExtraCommand)
|
||||||
Assertions.assertEquals(result1.absolute, -3.4567876, 0.01)
|
assertThat(result1.absolute).isWithin(0.01).of(-3.4567876)
|
||||||
Assertions.assertEquals(result1.duration, 510)
|
assertThat(result1.duration).isEqualTo(510)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue