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()
|
||||
temporaryBasalStorage.add(PumpSync.PumpState.TemporaryBasal(dateUtil.now(), T.mins(durationInMinutes.toLong()).msecs(), pumpRate, true, tbrType, 0L, 0L))
|
||||
val connectionOK = medtrumService?.setTempBasal(pumpRate, durationInMinutes) ?: false
|
||||
if (connectionOK
|
||||
return if (connectionOK
|
||||
&& medtrumPump.tempBasalInProgress
|
||||
&& 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)
|
||||
.isTempCancel(false)
|
||||
} else {
|
||||
|
@ -306,7 +306,7 @@ import kotlin.math.abs
|
|||
LTag.PUMP,
|
||||
"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")
|
||||
val connectionOK = medtrumService?.cancelTempBasal() ?: false
|
||||
if (connectionOK && !medtrumPump.tempBasalInProgress) {
|
||||
return PumpEnactResult(injector).success(true).enacted(true).isTempCancel(true)
|
||||
return if (connectionOK && !medtrumPump.tempBasalInProgress) {
|
||||
PumpEnactResult(injector).success(true).enacted(true).isTempCancel(true)
|
||||
} else {
|
||||
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 org.junit.jupiter.api.BeforeEach
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito
|
||||
|
||||
open class MedtrumTestBase : TestBaseWithProfile() {
|
||||
|
||||
|
@ -19,6 +20,7 @@ open class MedtrumTestBase : TestBaseWithProfile() {
|
|||
|
||||
@BeforeEach
|
||||
fun setup() {
|
||||
Mockito.`when`(sp.getString(R.string.key_active_alarms, "")).thenReturn("")
|
||||
medtrumPump = MedtrumPump(aapsLogger, rh, sp, dateUtil, pumpSync, temporaryBasalStorage)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue