forked from nightscout/AndroidAPS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a2fb04c
commit 22c1f8f
Showing
34 changed files
with
591 additions
and
712 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 0 additions & 37 deletions
37
pump/omnipod-eros/src/test/java/info/nightscout/androidaps/TestBase.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 0 additions & 114 deletions
114
...androidaps/plugins/pump/omnipod/eros/driver/communication/AapsOmnipodErosManagerTest.java
This file was deleted.
Oops, something went wrong.
94 changes: 94 additions & 0 deletions
94
...t/androidaps/plugins/pump/omnipod/eros/driver/communication/AapsOmnipodErosManagerTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.communication | ||
|
||
import info.nightscout.androidaps.plugins.pump.omnipod.eros.manager.AapsOmnipodErosManager | ||
import info.nightscout.interfaces.profile.Profile | ||
import info.nightscout.interfaces.profile.Profile.ProfileValue | ||
import org.joda.time.Duration | ||
import org.junit.jupiter.api.Assertions | ||
import org.junit.jupiter.api.Test | ||
import org.mockito.Mockito | ||
|
||
internal class AapsOmnipodErosManagerTest { | ||
|
||
@Test fun validProfile() { | ||
val profile = Mockito.mock(Profile::class.java) | ||
Mockito.`when`(profile.getBasalValues()).thenReturn( | ||
arrayOf( | ||
ProfileValue(0, 0.5), | ||
ProfileValue(18000, 1.0), | ||
ProfileValue(50400, 3.05) | ||
) | ||
) | ||
val basalSchedule = AapsOmnipodErosManager.mapProfileToBasalSchedule(profile) | ||
val entries = basalSchedule.entries | ||
Assertions.assertEquals(3, entries.size) | ||
val entry1 = entries[0] | ||
Assertions.assertEquals(Duration.standardSeconds(0), entry1.startTime) | ||
Assertions.assertEquals(0.5, entry1.rate, 0.000001) | ||
val entry2 = entries[1] | ||
Assertions.assertEquals(Duration.standardSeconds(18000), entry2.startTime) | ||
Assertions.assertEquals(1.0, entry2.rate, 0.000001) | ||
val entry3 = entries[2] | ||
Assertions.assertEquals(Duration.standardSeconds(50400), entry3.startTime) | ||
Assertions.assertEquals(3.05, entry3.rate, 0.000001) | ||
} | ||
|
||
@Test fun invalidProfileNullProfile() { | ||
Assertions.assertThrows(IllegalArgumentException::class.java) { AapsOmnipodErosManager.mapProfileToBasalSchedule(null) } | ||
} | ||
|
||
@Test fun invalidProfileNullEntries() { | ||
Assertions.assertThrows(IllegalArgumentException::class.java) { | ||
AapsOmnipodErosManager.mapProfileToBasalSchedule(Mockito.mock(Profile::class.java)) | ||
} | ||
} | ||
|
||
@Test fun invalidProfileZeroEntries() { | ||
val profile = Mockito.mock(Profile::class.java) | ||
Mockito.`when`(profile.getBasalValues()).thenReturn(emptyArray()) | ||
Assertions.assertThrows(IllegalArgumentException::class.java) { AapsOmnipodErosManager.mapProfileToBasalSchedule(profile) } | ||
} | ||
|
||
@Test fun invalidProfileNonZeroOffset() { | ||
val profile = Mockito.mock(Profile::class.java) | ||
Mockito.`when`(profile.getBasalValues()).thenReturn( | ||
arrayOf( | ||
ProfileValue(1800, 0.5) | ||
) | ||
) | ||
Assertions.assertThrows(IllegalArgumentException::class.java) { AapsOmnipodErosManager.mapProfileToBasalSchedule(profile) } | ||
} | ||
|
||
@Test fun invalidProfileMoreThan24Hours() { | ||
val profile = Mockito.mock(Profile::class.java) | ||
Mockito.`when`(profile.getBasalValues()).thenReturn( | ||
arrayOf( | ||
ProfileValue(0, 0.5), | ||
ProfileValue(86400, 0.5) | ||
) | ||
) | ||
Assertions.assertThrows(IllegalArgumentException::class.java) { AapsOmnipodErosManager.mapProfileToBasalSchedule(profile) } | ||
} | ||
|
||
@Test fun invalidProfileNegativeOffset() { | ||
val profile = Mockito.mock(Profile::class.java) | ||
Mockito.`when`(profile.getBasalValues()).thenReturn( | ||
arrayOf( | ||
ProfileValue(-1, 0.5) | ||
) | ||
) | ||
Assertions.assertThrows(IllegalArgumentException::class.java) { AapsOmnipodErosManager.mapProfileToBasalSchedule(profile) } | ||
} | ||
|
||
@Test fun roundsToSupportedPrecision() { | ||
val profile = Mockito.mock(Profile::class.java) | ||
Mockito.`when`(profile.getBasalValues()).thenReturn( | ||
arrayOf( | ||
ProfileValue(0, 0.04) | ||
) | ||
) | ||
val basalSchedule = AapsOmnipodErosManager.mapProfileToBasalSchedule(profile) | ||
val basalScheduleEntry = basalSchedule.entries[0] | ||
Assertions.assertEquals(0.05, basalScheduleEntry.rate, 0.000001) | ||
} | ||
} |
Oops, something went wrong.