Skip to content

Commit 566fb2d

Browse files
committed
Ins Conc PumpRate Fix tests
1 parent c3bd0f0 commit 566fb2d

File tree

8 files changed

+18
-11
lines changed

8 files changed

+18
-11
lines changed

app/src/test/kotlin/app/aaps/receivers/KeepAliveWorkerTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class KeepAliveWorkerTest : TestBaseWithProfile() {
7474
it.localAlertUtils = localAlertUtils
7575
it.workManager = workManager
7676
it.rh = rh
77+
it.ch = ch
7778
}
7879

7980
@Test

plugins/aps/src/test/kotlin/app/aaps/plugins/aps/loop/LoopPluginTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class LoopPluginTest : TestBaseWithProfile() {
6565
loopPlugin = LoopPlugin(
6666
aapsLogger, aapsSchedulers, rxBus, preferences, sp, config,
6767
constraintChecker, rh, profileFunction, context, commandQueue, activePlugin, iobCobCalculator, processedTbrEbData, receiverStatusStore, fabricPrivacy, dateUtil, uel,
68-
persistenceLayer, runningConfiguration, uiInteraction, pumpEnactResultProvider, processedDeviceStatusData, pumpStatusProvider, testScope
68+
persistenceLayer, runningConfiguration, uiInteraction, pumpEnactResultProvider, processedDeviceStatusData, pumpStatusProvider, ch, testScope
6969
)
7070
whenever(activePlugin.activePump).thenReturn(virtualPumpPlugin)
7171
whenever(context.getSystemService(Context.NOTIFICATION_SERVICE)).thenReturn(notificationManager)

plugins/aps/src/test/kotlin/app/aaps/plugins/aps/openAPSAMA/OpenAPSAMAPluginTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class OpenAPSAMAPluginTest : TestBaseWithProfile() {
2222
openAPSAMAPlugin = OpenAPSAMAPlugin(
2323
aapsLogger, rxBus, constraintChecker, rh, config, profileFunction, activePlugin,
2424
iobCobCalculator, processedTbrEbData, hardLimits, dateUtil, persistenceLayer, glucoseStatusProvider, preferences, determineBasalAMA,
25-
GlucoseStatusCalculatorSMB(aapsLogger, iobCobCalculator, dateUtil, decimalFormatter, deltaCalculator), apsResultProvider
25+
GlucoseStatusCalculatorSMB(aapsLogger, iobCobCalculator, dateUtil, decimalFormatter, deltaCalculator), apsResultProvider, ch
2626
)
2727
}
2828

plugins/aps/src/test/kotlin/app/aaps/plugins/aps/openAPSAutoISF/OpenAPSAutoISFPluginTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class OpenAPSAutoISFPluginTest : TestBaseWithProfile() {
3636
aapsLogger, rxBus, constraintChecker, rh, profileFunction, profileUtil, config, activePlugin,
3737
iobCobCalculator, hardLimits, preferences, dateUtil, processedTbrEbData, persistenceLayer, glucoseStatusProvider,
3838
bgQualityCheck, uiInteraction, determineBasalSMB, profiler,
39-
GlucoseStatusCalculatorAutoIsf(aapsLogger, iobCobCalculator, dateUtil, decimalFormatter, deltaCalculator), apsResultProvider
39+
GlucoseStatusCalculatorAutoIsf(aapsLogger, iobCobCalculator, dateUtil, decimalFormatter, deltaCalculator), apsResultProvider, ch
4040
)
4141
}
4242

@@ -148,7 +148,7 @@ class OpenAPSAutoISFPluginTest : TestBaseWithProfile() {
148148
maxUAMSMBBasalMinutes = preferences.get(IntKey.ApsUamMaxMinutesOfBasalToLimitSmb),
149149
bolus_increment = 0.1,
150150
carbsReqThreshold = preferences.get(IntKey.ApsCarbsRequestThreshold),
151-
current_basal = activePlugin.activePump.baseBasalRate,
151+
current_basal = ch.fromPump(activePlugin.activePump.baseBasalRate),
152152
temptargetSet = true,
153153
autosens_max = preferences.get(DoubleKey.AutosensMax),
154154
out_units = "mg/dl",
@@ -235,7 +235,7 @@ class OpenAPSAutoISFPluginTest : TestBaseWithProfile() {
235235
maxUAMSMBBasalMinutes = preferences.get(IntKey.ApsUamMaxMinutesOfBasalToLimitSmb),
236236
bolus_increment = 0.1,
237237
carbsReqThreshold = preferences.get(IntKey.ApsCarbsRequestThreshold),
238-
current_basal = activePlugin.activePump.baseBasalRate,
238+
current_basal = ch.fromPump(activePlugin.activePump.baseBasalRate),
239239
temptargetSet = true,
240240
autosens_max = preferences.get(DoubleKey.AutosensMax),
241241
out_units = "mg/dl",

plugins/aps/src/test/kotlin/app/aaps/plugins/aps/openAPSSMB/OpenAPSSMBPluginTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class OpenAPSSMBPluginTest : TestBaseWithProfile() {
2929
openAPSSMBPlugin = OpenAPSSMBPlugin(
3030
aapsLogger, rxBus, constraintChecker, rh, profileFunction, profileUtil, config, activePlugin,
3131
iobCobCalculator, hardLimits, preferences, dateUtil, processedTbrEbData, persistenceLayer, glucoseStatusProvider,
32-
tddCalculator, bgQualityCheck, uiInteraction, determineBasalSMB, profiler, GlucoseStatusCalculatorSMB(aapsLogger, iobCobCalculator, dateUtil, decimalFormatter, deltaCalculator), apsResultProvider
32+
tddCalculator, bgQualityCheck, uiInteraction, determineBasalSMB, profiler, GlucoseStatusCalculatorSMB(aapsLogger, iobCobCalculator, dateUtil, decimalFormatter, deltaCalculator), apsResultProvider, ch
3333
)
3434
}
3535

pump/eopatch/src/test/kotlin/app/aaps/pump/eopatch/EopatchPumpPluginTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ class EopatchPumpPluginTest : EopatchTestBase() {
158158
fun `baseBasalRate should return 0 when not activated`() {
159159
patchConfig.lifecycleEvent = PatchLifecycleEvent.createShutdown()
160160

161-
assertThat(plugin.baseBasalRate).isWithin(0.001).of(0.0)
161+
assertThat(plugin.baseBasalRate.cU).isWithin(0.001).of(0.0)
162162
}
163163

164164
@Test
@@ -170,7 +170,7 @@ class EopatchPumpPluginTest : EopatchTestBase() {
170170
patchState.update(bytes, System.currentTimeMillis())
171171
whenever(eopatchPreferenceManager.patchState).thenReturn(patchState)
172172

173-
assertThat(plugin.baseBasalRate).isWithin(0.001).of(0.0)
173+
assertThat(plugin.baseBasalRate.cU).isWithin(0.001).of(0.0)
174174
}
175175

176176
@Test

shared/tests/src/main/kotlin/app/aaps/shared/tests/TestBaseWithProfile.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import app.aaps.core.interfaces.profile.ProfileFunction
2222
import app.aaps.core.interfaces.profile.ProfileStore
2323
import app.aaps.core.interfaces.profile.ProfileUtil
2424
import app.aaps.core.interfaces.pump.PumpEnactResult
25+
import app.aaps.core.interfaces.pump.PumpInsulin
26+
import app.aaps.core.interfaces.pump.PumpRate
2527
import app.aaps.core.interfaces.resources.ResourceHelper
2628
import app.aaps.core.interfaces.utils.DateUtil
2729
import app.aaps.core.interfaces.utils.DecimalFormatter
@@ -183,7 +185,7 @@ open class TestBaseWithProfile : TestBase() {
183185
whenever(preferences.get(StringKey.GeneralUnits)).thenReturn(GlucoseUnit.MGDL.asText)
184186
whenever(localProfileManager.profile).thenReturn(getValidProfileStore())
185187
deltaCalculator = DeltaCalculator(aapsLogger)
186-
apsResultProvider = Provider { DetermineBasalResult(aapsLogger, constraintsChecker, preferences, activePlugin, processedTbrEbData, profileFunction, rh, decimalFormatter, dateUtil, apsResultProvider) }
188+
apsResultProvider = Provider { DetermineBasalResult(aapsLogger, constraintsChecker, preferences, activePlugin, processedTbrEbData, profileFunction, rh, decimalFormatter, dateUtil, apsResultProvider, ch) }
187189
validProfile = ProfileSealed.Pure(pureProfileFromJson(JSONObject(validProfileJSON), dateUtil)!!, activePlugin)
188190
effectiveProfileSwitch = EPS(
189191
timestamp = dateUtil.now(),
@@ -320,7 +322,10 @@ open class TestBaseWithProfile : TestBase() {
320322
glucoseStatusCalculatorSMB = GlucoseStatusCalculatorSMB(aapsLogger, iobCobCalculator, dateUtil, decimalFormatter, DeltaCalculator(aapsLogger))
321323

322324
whenever(ch.bolusProgressString(any())).thenReturn("AnyString")
323-
whenever(ch.fromPump(any())).thenReturn(0.0)
325+
whenever(ch.fromPump(any<PumpRate>())).thenAnswer { invocation ->
326+
(invocation.arguments[0] as PumpRate).cU }
327+
whenever(ch.fromPump(any<PumpInsulin>())).thenAnswer { invocation ->
328+
(invocation.arguments[0] as PumpInsulin).cU }
324329
}
325330

326331
fun getValidProfileStore(): ProfileStore {

shared/tests/src/main/kotlin/app/aaps/shared/tests/TestPumpPlugin.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import app.aaps.core.interfaces.pump.Pump
1010
import app.aaps.core.interfaces.pump.PumpEnactResult
1111
import app.aaps.core.interfaces.pump.PumpInsulin
1212
import app.aaps.core.interfaces.pump.PumpProfile
13+
import app.aaps.core.interfaces.pump.PumpRate
1314
import app.aaps.core.interfaces.pump.PumpSync
1415
import app.aaps.core.interfaces.pump.PumpWithConcentration
1516
import app.aaps.core.interfaces.resources.ResourceHelper
@@ -56,7 +57,7 @@ class TestPumpPlugin(val rh: ResourceHelper) : PumpWithConcentration {
5657
override val lastBolusTime: Long? get() = null
5758
override val lastBolusAmount: PumpInsulin? get() = null
5859
override val lastDataTime: Long get() = lastData
59-
override val baseBasalRate: Double get() = baseBasal
60+
override val baseBasalRate: PumpRate get() = PumpRate(baseBasal)
6061
override val reservoirLevel: PumpInsulin = PumpInsulin(0.0)
6162
override val batteryLevel: Int? = null
6263
override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult = PumpEnactResultObject(rh).success(true)

0 commit comments

Comments
 (0)