fix tests

This commit is contained in:
Milos Kozak 2022-11-10 11:30:33 +01:00
parent 886dc6d0a4
commit 59e885110b
15 changed files with 3747 additions and 56 deletions

View file

@ -8,10 +8,8 @@ import info.nightscout.androidaps.dana.DanaPump
import info.nightscout.androidaps.danar.DanaRPlugin import info.nightscout.androidaps.danar.DanaRPlugin
import info.nightscout.androidaps.danars.DanaRSPlugin import info.nightscout.androidaps.danars.DanaRSPlugin
import info.nightscout.androidaps.data.PumpEnactResultImpl import info.nightscout.androidaps.data.PumpEnactResultImpl
import info.nightscout.database.impl.AppRepository
import info.nightscout.androidaps.insight.database.InsightDatabaseDao import info.nightscout.androidaps.insight.database.InsightDatabaseDao
import info.nightscout.androidaps.insight.database.InsightDbHelper import info.nightscout.androidaps.insight.database.InsightDbHelper
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin
import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin
import info.nightscout.androidaps.plugins.aps.openAPSSMBDynamicISF.OpenAPSSMBDynamicISFPlugin import info.nightscout.androidaps.plugins.aps.openAPSSMBDynamicISF.OpenAPSSMBDynamicISFPlugin
@ -30,6 +28,7 @@ import info.nightscout.androidaps.plugins.source.GlimpPlugin
import info.nightscout.androidaps.utils.HardLimits import info.nightscout.androidaps.utils.HardLimits
import info.nightscout.androidaps.utils.Profiler import info.nightscout.androidaps.utils.Profiler
import info.nightscout.androidaps.utils.buildHelper.BuildHelperImpl import info.nightscout.androidaps.utils.buildHelper.BuildHelperImpl
import info.nightscout.database.impl.AppRepository
import info.nightscout.implementation.constraints.ConstraintsImpl import info.nightscout.implementation.constraints.ConstraintsImpl
import info.nightscout.interfaces.BuildHelper import info.nightscout.interfaces.BuildHelper
import info.nightscout.interfaces.Constraint import info.nightscout.interfaces.Constraint
@ -58,7 +57,6 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
@Mock lateinit var glimpPlugin: GlimpPlugin @Mock lateinit var glimpPlugin: GlimpPlugin
@Mock lateinit var sensitivityOref1Plugin: SensitivityOref1Plugin @Mock lateinit var sensitivityOref1Plugin: SensitivityOref1Plugin
@Mock lateinit var profiler: Profiler @Mock lateinit var profiler: Profiler
@Mock lateinit var uel: UserEntryLogger
@Mock lateinit var fileListProvider: PrefFileListProvider @Mock lateinit var fileListProvider: PrefFileListProvider
@Mock lateinit var repository: AppRepository @Mock lateinit var repository: AppRepository
@Mock lateinit var pumpSync: PumpSync @Mock lateinit var pumpSync: PumpSync
@ -80,7 +78,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
private lateinit var openAPSSMBDynamicISFPlugin: OpenAPSSMBDynamicISFPlugin private lateinit var openAPSSMBDynamicISFPlugin: OpenAPSSMBDynamicISFPlugin
private lateinit var hardLimits: HardLimits private lateinit var hardLimits: HardLimits
val injector = HasAndroidInjector { private val injector = HasAndroidInjector {
AndroidInjector { AndroidInjector {
if (it is Objective) { if (it is Objective) {
it.sp = sp it.sp = sp
@ -135,7 +133,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
danaPump = DanaPump(aapsLogger, sp, dateUtil, injector) danaPump = DanaPump(aapsLogger, sp, dateUtil, injector)
hardLimits = HardLimits(aapsLogger, rxBus, sp, rh, context, repository) hardLimits = HardLimits(aapsLogger, rxBus, sp, rh, context, repository)
objectivesPlugin = ObjectivesPlugin(injector, aapsLogger, rh, activePlugin, sp, config) objectivesPlugin = ObjectivesPlugin(injector, aapsLogger, rh, activePlugin, sp, config)
comboPlugin = ComboPlugin(injector, aapsLogger, rxBus, rh, profileFunction, sp, commandQueue, context, pumpSync, dateUtil, ruffyScripter) comboPlugin = ComboPlugin(injector, aapsLogger, rxBus, rh, profileFunction, sp, commandQueue, pumpSync, dateUtil, ruffyScripter)
danaRPlugin = DanaRPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePlugin, sp, commandQueue, danaPump, dateUtil, fabricPrivacy, pumpSync) danaRPlugin = DanaRPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePlugin, sp, commandQueue, danaPump, dateUtil, fabricPrivacy, pumpSync)
danaRSPlugin = danaRSPlugin =
DanaRSPlugin( DanaRSPlugin(

View file

@ -11,6 +11,7 @@ import info.nightscout.shared.utils.DateUtil
import info.nightscout.interfaces.utils.TimerUtil import info.nightscout.interfaces.utils.TimerUtil
import info.nightscout.automation.R import info.nightscout.automation.R
import info.nightscout.automation.elements.InputString import info.nightscout.automation.elements.InputString
import info.nightscout.interfaces.Config
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
@ -26,6 +27,7 @@ class ActionAlarmTest : TestBase() {
@Mock lateinit var context: Context @Mock lateinit var context: Context
@Mock lateinit var timerUtil: TimerUtil @Mock lateinit var timerUtil: TimerUtil
@Mock lateinit var dateUtil: DateUtil @Mock lateinit var dateUtil: DateUtil
@Mock lateinit var config: Config
private lateinit var sut: ActionAlarm private lateinit var sut: ActionAlarm
var injector: HasAndroidInjector = HasAndroidInjector { var injector: HasAndroidInjector = HasAndroidInjector {
@ -36,6 +38,7 @@ class ActionAlarmTest : TestBase() {
it.context = context it.context = context
it.timerUtil = timerUtil it.timerUtil = timerUtil
it.dateUtil = dateUtil it.dateUtil = dateUtil
it.config = config
} }
if (it is PumpEnactResultImpl) { if (it is PumpEnactResultImpl) {
it.rh = rh it.rh = rh

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.extensions package info.nightscout.core.pumpExtensions
import info.nightscout.database.entities.UserEntry import info.nightscout.database.entities.UserEntry
import info.nightscout.database.entities.embedments.InterfaceIDs import info.nightscout.database.entities.embedments.InterfaceIDs

View file

@ -107,14 +107,6 @@
<!-- Green Colors --> <!-- Green Colors -->
<color name="notificationInfo">#009705</color> <color name="notificationInfo">#009705</color>
<!-- Toasts-->
<color name="toastBorder">#666666</color>
<color name="toastBase">#000000</color>
<color name="toastOk">#77dd77</color>
<color name="toastError">#ff0400</color>
<color name="toastWarn">#FF8C00</color>
<color name="toastInfo">#03A9F4</color>
<!-- Black and White transparent - glass effect--> <!-- Black and White transparent - glass effect-->
<color name="black_alpha_10">#1A000000</color> <color name="black_alpha_10">#1A000000</color>
<color name="black_alpha_20">#33000000</color> <color name="black_alpha_20">#33000000</color>
@ -141,11 +133,6 @@
<color name="transparent">#00000000</color> <color name="transparent">#00000000</color>
<!-- Maintenance -->
<color name="metadataOk">#77dd77</color>
<color name="metadataTextWarning">#FF8C00</color>
<color name="metadataTextError">#FF5555</color>
<!-- Import/Export --> <!-- Import/Export -->
<color name="importListAdditionalInfo">#BBBBBB</color> <color name="importListAdditionalInfo">#BBBBBB</color>
<color name="importListFileName">#FFFFFF</color> <color name="importListFileName">#FFFFFF</color>

View file

@ -109,14 +109,6 @@
<!-- Green Colors --> <!-- Green Colors -->
<color name="notificationInfo">#009705</color> <color name="notificationInfo">#009705</color>
<!-- Toasts-->
<color name="toastBorder">#666666</color>
<color name="toastBase">#000000</color>
<color name="toastOk">#77dd77</color>
<color name="toastError">#ff0400</color>
<color name="toastWarn">#FF8C00</color>
<color name="toastInfo">#03A9F4</color>
<!-- Black and White transparent - glass effect--> <!-- Black and White transparent - glass effect-->
<color name="black_alpha_10">#1A000000</color> <color name="black_alpha_10">#1A000000</color>
<color name="black_alpha_20">#33000000</color> <color name="black_alpha_20">#33000000</color>

View file

@ -4,7 +4,6 @@ import android.content.Context
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.ProfileSealed import info.nightscout.androidaps.data.ProfileSealed
import info.nightscout.database.impl.AppRepository
import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.Profile import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
@ -12,7 +11,7 @@ import info.nightscout.androidaps.interfaces.ProfileStore
import info.nightscout.androidaps.utils.DefaultValueHelper import info.nightscout.androidaps.utils.DefaultValueHelper
import info.nightscout.androidaps.utils.HardLimits import info.nightscout.androidaps.utils.HardLimits
import info.nightscout.androidaps.utils.extensions.pureProfileFromJson import info.nightscout.androidaps.utils.extensions.pureProfileFromJson
import info.nightscout.core.fabric.FabricPrivacy import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
@ -28,7 +27,6 @@ open class TestBaseWithProfile : TestBase() {
@Mock lateinit var activePluginProvider: ActivePlugin @Mock lateinit var activePluginProvider: ActivePlugin
@Mock lateinit var rh: ResourceHelper @Mock lateinit var rh: ResourceHelper
@Mock lateinit var fabricPrivacy: FabricPrivacy
@Mock lateinit var profileFunction: ProfileFunction @Mock lateinit var profileFunction: ProfileFunction
@Mock lateinit var defaultValueHelper: DefaultValueHelper @Mock lateinit var defaultValueHelper: DefaultValueHelper
@Mock lateinit var dateUtil: DateUtil @Mock lateinit var dateUtil: DateUtil

View file

@ -19,7 +19,7 @@ class DetailedBolusInfoTest : TestBase() {
@Test fun toStringShouldBeOverloaded() { @Test fun toStringShouldBeOverloaded() {
val detailedBolusInfo = DetailedBolusInfo() val detailedBolusInfo = DetailedBolusInfo()
Assert.assertEquals(true, detailedBolusInfo.toString().contains("insulin")) Assert.assertEquals(true, detailedBolusInfo.toJsonString().contains("insulin"))
} }
@Test fun copyShouldCopyAllProperties() { @Test fun copyShouldCopyAllProperties() {
@ -36,7 +36,7 @@ class DetailedBolusInfoTest : TestBase() {
detailedBolusInfo.context = context detailedBolusInfo.context = context
detailedBolusInfo.eventType = DetailedBolusInfo.EventType.BOLUS_WIZARD detailedBolusInfo.eventType = DetailedBolusInfo.EventType.BOLUS_WIZARD
val serialized = detailedBolusInfo.toJsonString() val serialized = detailedBolusInfo.toJsonString()
val deserialized = DetailedBolusInfo.fromJsonString(serialized) val deserialized = DetailedBolusInfo().fromJsonString(serialized)
Assert.assertEquals(1L, deserialized.bolusCalculatorResult?.timestamp) Assert.assertEquals(1L, deserialized.bolusCalculatorResult?.timestamp)
Assert.assertEquals(DetailedBolusInfo.EventType.BOLUS_WIZARD, deserialized.eventType) Assert.assertEquals(DetailedBolusInfo.EventType.BOLUS_WIZARD, deserialized.eventType)
// Context should be excluded // Context should be excluded

File diff suppressed because it is too large Load diff

View file

@ -19,9 +19,9 @@ import info.nightscout.database.impl.transactions.SyncPumpExtendedBolusTransacti
import info.nightscout.database.impl.transactions.SyncPumpTemporaryBasalTransaction import info.nightscout.database.impl.transactions.SyncPumpTemporaryBasalTransaction
import info.nightscout.database.impl.transactions.SyncPumpTotalDailyDoseTransaction import info.nightscout.database.impl.transactions.SyncPumpTotalDailyDoseTransaction
import info.nightscout.database.impl.transactions.SyncTemporaryBasalWithTempIdTransaction import info.nightscout.database.impl.transactions.SyncTemporaryBasalWithTempIdTransaction
import info.nightscout.androidaps.extensions.fromDbPumpType import info.nightscout.core.pumpExtensions.fromDbPumpType
import info.nightscout.androidaps.extensions.toDbPumpType import info.nightscout.core.pumpExtensions.toDbPumpType
import info.nightscout.androidaps.extensions.toDbSource import info.nightscout.core.pumpExtensions.toDbSource
import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.PumpSync import info.nightscout.androidaps.interfaces.PumpSync

View file

@ -76,14 +76,14 @@ class DetailedBolusInfo {
fun toDBbEventType(): TherapyEvent.Type = fun toDBbEventType(): TherapyEvent.Type =
when (this) { when (this) {
MEAL_BOLUS -> TherapyEvent.Type.MEAL_BOLUS MEAL_BOLUS -> TherapyEvent.Type.MEAL_BOLUS
BOLUS_WIZARD -> TherapyEvent.Type.BOLUS_WIZARD BOLUS_WIZARD -> TherapyEvent.Type.BOLUS_WIZARD
CORRECTION_BOLUS -> TherapyEvent.Type.CORRECTION_BOLUS CORRECTION_BOLUS -> TherapyEvent.Type.CORRECTION_BOLUS
CARBS_CORRECTION -> TherapyEvent.Type.CARBS_CORRECTION CARBS_CORRECTION -> TherapyEvent.Type.CARBS_CORRECTION
CANNULA_CHANGE -> TherapyEvent.Type.CANNULA_CHANGE CANNULA_CHANGE -> TherapyEvent.Type.CANNULA_CHANGE
INSULIN_CHANGE -> TherapyEvent.Type.INSULIN_CHANGE INSULIN_CHANGE -> TherapyEvent.Type.INSULIN_CHANGE
PUMP_BATTERY_CHANGE -> TherapyEvent.Type.PUMP_BATTERY_CHANGE PUMP_BATTERY_CHANGE -> TherapyEvent.Type.PUMP_BATTERY_CHANGE
NOTE -> TherapyEvent.Type.NOTE NOTE -> TherapyEvent.Type.NOTE
} }
} }
@ -142,7 +142,4 @@ class DetailedBolusInfo {
n.carbsTimestamp = carbsTimestamp n.carbsTimestamp = carbsTimestamp
return n return n
} }
companion object {
}
} }

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Maintenance -->
<color name="metadataOk">#77dd77</color>
<color name="metadataTextWarning">#FF8C00</color>
<color name="metadataTextError">#FF5555</color>
<!-- Toasts-->
<color name="toastBorder">#666666</color>
<color name="toastBase">#000000</color>
<color name="toastOk">#77dd77</color>
<color name="toastError">#ff0400</color>
<color name="toastWarn">#FF8C00</color>
<color name="toastInfo">#03A9F4</color>
</resources>

View file

@ -5,4 +5,12 @@
<color name="metadataTextWarning">#FF8C00</color> <color name="metadataTextWarning">#FF8C00</color>
<color name="metadataTextError">#FF5555</color> <color name="metadataTextError">#FF5555</color>
<!-- Toasts-->
<color name="toastBorder">#666666</color>
<color name="toastBase">#000000</color>
<color name="toastOk">#77dd77</color>
<color name="toastError">#ff0400</color>
<color name="toastWarn">#FF8C00</color>
<color name="toastInfo">#03A9F4</color>
</resources> </resources>

View file

@ -1,23 +1,21 @@
package info.nightscout.androidaps.plugins.pump.combo package info.nightscout.androidaps.plugins.pump.combo
import android.content.Context
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.TestBase
import info.nightscout.androidaps.combo.R import info.nightscout.androidaps.combo.R
import info.nightscout.androidaps.data.PumpEnactResultImpl import info.nightscout.androidaps.data.PumpEnactResultImpl
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.CommandQueue import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.interfaces.Constraint
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.PumpSync import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.androidaps.plugins.pump.combo.ruffyscripter.RuffyScripter import info.nightscout.androidaps.plugins.pump.combo.ruffyscripter.RuffyScripter
import info.nightscout.androidaps.plugins.pump.combo.ruffyscripter.history.Bolus import info.nightscout.androidaps.plugins.pump.combo.ruffyscripter.history.Bolus
import info.nightscout.shared.utils.DateUtil import info.nightscout.interfaces.Constraint
import info.nightscout.interfaces.PluginType import info.nightscout.interfaces.PluginType
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
@ -28,15 +26,13 @@ class ComboPluginTest : TestBase() {
@Mock lateinit var rh: ResourceHelper @Mock lateinit var rh: ResourceHelper
@Mock lateinit var profileFunction: ProfileFunction @Mock lateinit var profileFunction: ProfileFunction
@Mock lateinit var activePlugin: ActivePlugin
@Mock lateinit var commandQueue: CommandQueue @Mock lateinit var commandQueue: CommandQueue
@Mock lateinit var pumpSync: PumpSync @Mock lateinit var pumpSync: PumpSync
@Mock lateinit var sp: SP @Mock lateinit var sp: SP
@Mock lateinit var context: Context
@Mock lateinit var dateUtil: DateUtil @Mock lateinit var dateUtil: DateUtil
@Mock lateinit var ruffyScripter: RuffyScripter @Mock lateinit var ruffyScripter: RuffyScripter
val injector = HasAndroidInjector { private val injector = HasAndroidInjector {
AndroidInjector { AndroidInjector {
if (it is PumpEnactResultImpl) { if (it is PumpEnactResultImpl) {
it.rh = rh it.rh = rh
@ -50,7 +46,7 @@ class ComboPluginTest : TestBase() {
fun prepareMocks() { fun prepareMocks() {
`when`(rh.gs(R.string.novalidbasalrate)).thenReturn("No valid basal rate read from pump") `when`(rh.gs(R.string.novalidbasalrate)).thenReturn("No valid basal rate read from pump")
`when`(rh.gs(R.string.combo_pump_unsupported_operation)).thenReturn("Requested operation not supported by pump") `when`(rh.gs(R.string.combo_pump_unsupported_operation)).thenReturn("Requested operation not supported by pump")
comboPlugin = ComboPlugin(injector, aapsLogger, RxBus(aapsSchedulers, aapsLogger), rh, profileFunction, sp, commandQueue, context, pumpSync, dateUtil, ruffyScripter) comboPlugin = ComboPlugin(injector, aapsLogger, RxBus(aapsSchedulers, aapsLogger), rh, profileFunction, sp, commandQueue, pumpSync, dateUtil, ruffyScripter)
} }
@Test @Test

View file

@ -25,4 +25,5 @@ dependencies {
implementation project(':pump:rileylink') implementation project(':pump:rileylink')
implementation project(':interfaces') implementation project(':interfaces')
implementation project(path: ':core:fabric') implementation project(path: ':core:fabric')
testImplementation project(path: ':database:impl')
} }

View file

@ -11,7 +11,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.TempBasalProce
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil
import info.nightscout.androidaps.utils.serialisation.SealedClassHelper.gson import info.nightscout.database.impl.serialisation.SealedClassHelper
import info.nightscout.pump.core.utils.ByteUtil import info.nightscout.pump.core.utils.ByteUtil
import info.nightscout.rx.TestAapsSchedulers import info.nightscout.rx.TestAapsSchedulers
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
@ -139,7 +139,7 @@ class MedtronicHistoryDataUTest : TestBase() {
println("PumpHistoryEntries: getFilteredItems: " + tbrs.size) println("PumpHistoryEntries: getFilteredItems: " + tbrs.size)
println("PumpHistoryEntries: getRewindItems: $rewindRecords.size : " + gson.toJson(rewindRecords)) println("PumpHistoryEntries: getRewindItems: $rewindRecords.size : " + SealedClassHelper.gson.toJson(rewindRecords))
val processList: MutableList<TempBasalProcessDTO> = medtronicHistoryData.createTBRProcessList(tbrs) val processList: MutableList<TempBasalProcessDTO> = medtronicHistoryData.createTBRProcessList(tbrs)