Medtrum: Fix unit tests, more lints
This commit is contained in:
parent
56832e8ff0
commit
7662f3cc45
2 changed files with 8 additions and 6 deletions
|
@ -293,12 +293,12 @@ import kotlin.math.abs
|
||||||
val pumpRate = constraintChecker.applyBasalConstraints(Constraint(absoluteRate), profile).value()
|
val pumpRate = constraintChecker.applyBasalConstraints(Constraint(absoluteRate), profile).value()
|
||||||
temporaryBasalStorage.add(PumpSync.PumpState.TemporaryBasal(dateUtil.now(), T.mins(durationInMinutes.toLong()).msecs(), pumpRate, true, tbrType, 0L, 0L))
|
temporaryBasalStorage.add(PumpSync.PumpState.TemporaryBasal(dateUtil.now(), T.mins(durationInMinutes.toLong()).msecs(), pumpRate, true, tbrType, 0L, 0L))
|
||||||
val connectionOK = medtrumService?.setTempBasal(pumpRate, durationInMinutes) ?: false
|
val connectionOK = medtrumService?.setTempBasal(pumpRate, durationInMinutes) ?: false
|
||||||
if (connectionOK
|
return if (connectionOK
|
||||||
&& medtrumPump.tempBasalInProgress
|
&& medtrumPump.tempBasalInProgress
|
||||||
&& abs(medtrumPump.tempBasalAbsoluteRate - pumpRate) <= 0.05
|
&& abs(medtrumPump.tempBasalAbsoluteRate - pumpRate) <= 0.05
|
||||||
) {
|
) {
|
||||||
|
|
||||||
return PumpEnactResult(injector).success(true).enacted(true).duration(durationInMinutes).absolute(medtrumPump.tempBasalAbsoluteRate)
|
PumpEnactResult(injector).success(true).enacted(true).duration(durationInMinutes).absolute(medtrumPump.tempBasalAbsoluteRate)
|
||||||
.isPercent(false)
|
.isPercent(false)
|
||||||
.isTempCancel(false)
|
.isTempCancel(false)
|
||||||
} else {
|
} else {
|
||||||
|
@ -306,7 +306,7 @@ import kotlin.math.abs
|
||||||
LTag.PUMP,
|
LTag.PUMP,
|
||||||
"setTempBasalAbsolute failed, connectionOK: $connectionOK, tempBasalInProgress: ${medtrumPump.tempBasalInProgress}, tempBasalAbsoluteRate: ${medtrumPump.tempBasalAbsoluteRate}"
|
"setTempBasalAbsolute failed, connectionOK: $connectionOK, tempBasalInProgress: ${medtrumPump.tempBasalInProgress}, tempBasalAbsoluteRate: ${medtrumPump.tempBasalAbsoluteRate}"
|
||||||
)
|
)
|
||||||
return PumpEnactResult(injector).success(false).enacted(false).comment("Medtrum setTempBasalAbsolute failed")
|
PumpEnactResult(injector).success(false).enacted(false).comment("Medtrum setTempBasalAbsolute failed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,11 +325,11 @@ import kotlin.math.abs
|
||||||
|
|
||||||
aapsLogger.info(LTag.PUMP, "cancelTempBasal - enforceNew: $enforceNew")
|
aapsLogger.info(LTag.PUMP, "cancelTempBasal - enforceNew: $enforceNew")
|
||||||
val connectionOK = medtrumService?.cancelTempBasal() ?: false
|
val connectionOK = medtrumService?.cancelTempBasal() ?: false
|
||||||
if (connectionOK && !medtrumPump.tempBasalInProgress) {
|
return if (connectionOK && !medtrumPump.tempBasalInProgress) {
|
||||||
return PumpEnactResult(injector).success(true).enacted(true).isTempCancel(true)
|
PumpEnactResult(injector).success(true).enacted(true).isTempCancel(true)
|
||||||
} else {
|
} else {
|
||||||
aapsLogger.error(LTag.PUMP, "cancelTempBasal failed, connectionOK: $connectionOK, tempBasalInProgress: ${medtrumPump.tempBasalInProgress}")
|
aapsLogger.error(LTag.PUMP, "cancelTempBasal failed, connectionOK: $connectionOK, tempBasalInProgress: ${medtrumPump.tempBasalInProgress}")
|
||||||
return PumpEnactResult(injector).success(false).enacted(false).comment("Medtrum cancelTempBasal failed")
|
PumpEnactResult(injector).success(false).enacted(false).comment("Medtrum cancelTempBasal failed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import info.nightscout.interfaces.pump.TemporaryBasalStorage
|
||||||
import info.nightscout.interfaces.stats.TddCalculator
|
import info.nightscout.interfaces.stats.TddCalculator
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
import org.mockito.Mockito
|
||||||
|
|
||||||
open class MedtrumTestBase : TestBaseWithProfile() {
|
open class MedtrumTestBase : TestBaseWithProfile() {
|
||||||
|
|
||||||
|
@ -19,6 +20,7 @@ open class MedtrumTestBase : TestBaseWithProfile() {
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
fun setup() {
|
fun setup() {
|
||||||
|
Mockito.`when`(sp.getString(R.string.key_active_alarms, "")).thenReturn("")
|
||||||
medtrumPump = MedtrumPump(aapsLogger, rh, sp, dateUtil, pumpSync, temporaryBasalStorage)
|
medtrumPump = MedtrumPump(aapsLogger, rh, sp, dateUtil, pumpSync, temporaryBasalStorage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue