fix tests
This commit is contained in:
parent
d04cf567b8
commit
5104dc1416
4 changed files with 20 additions and 3 deletions
|
@ -24,7 +24,6 @@ class ActionStartTempTargetTest : ActionsTestBase() {
|
|||
|
||||
@Before
|
||||
fun setup() {
|
||||
PowerMockito.mockStatic(MainApp::class.java)
|
||||
`when`(resourceHelper.gs(R.string.starttemptarget)).thenReturn("Start temp target")
|
||||
|
||||
sut = ActionStartTempTarget(injector)
|
||||
|
|
|
@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.general.automation.actions
|
|||
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.TestBaseWithProfile
|
||||
import info.nightscout.androidaps.data.PumpEnactResult
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||
|
@ -9,11 +10,14 @@ import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
|||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||
import info.nightscout.androidaps.plugins.general.automation.elements.InputTempTarget
|
||||
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin
|
||||
import info.nightscout.androidaps.plugins.profile.local.LocalProfilePlugin
|
||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import org.junit.Before
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
|
||||
@PrepareForTest(VirtualPumpPlugin::class, RxBusWrapper::class, LocalProfilePlugin::class, SmsCommunicatorPlugin::class, ConfigBuilderPlugin::class)
|
||||
|
@ -25,8 +29,8 @@ open class ActionsTestBase : TestBaseWithProfile() {
|
|||
@Mock lateinit var virtualPumpPlugin: VirtualPumpPlugin
|
||||
@Mock lateinit var loopPlugin: LoopPlugin
|
||||
@Mock lateinit var activePlugin: ActivePluginProvider
|
||||
@Mock lateinit var localProfilePlugin : LocalProfilePlugin
|
||||
@Mock lateinit var smsCommunicatorPlugin : SmsCommunicatorPlugin
|
||||
@Mock lateinit var localProfilePlugin: LocalProfilePlugin
|
||||
@Mock lateinit var smsCommunicatorPlugin: SmsCommunicatorPlugin
|
||||
|
||||
var injector: HasAndroidInjector = HasAndroidInjector {
|
||||
AndroidInjector {
|
||||
|
@ -87,7 +91,14 @@ open class ActionsTestBase : TestBaseWithProfile() {
|
|||
it.aapsLogger = aapsLogger
|
||||
it.resourceHelper = resourceHelper
|
||||
}
|
||||
if (it is InputTempTarget) {
|
||||
it.profileFunction = profileFunction
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Before
|
||||
fun mock() {
|
||||
`when`(profileFunction.getUnits()).thenReturn(Constants.MGDL)
|
||||
}
|
||||
}
|
|
@ -1,10 +1,12 @@
|
|||
package info.nightscout.androidaps.plugins.general.automation.elements
|
||||
|
||||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTestBase
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
|
|
|
@ -6,9 +6,11 @@ import dagger.android.HasAndroidInjector
|
|||
import info.nightscout.androidaps.TestBaseWithProfile
|
||||
import info.nightscout.androidaps.db.BgReading
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin
|
||||
import info.nightscout.androidaps.plugins.general.automation.elements.InputBg
|
||||
import info.nightscout.androidaps.plugins.general.automation.elements.InputTempTarget
|
||||
import info.nightscout.androidaps.plugins.general.automation.elements.StaticLabel
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
|
||||
|
@ -71,6 +73,9 @@ open class TriggerTestBase : TestBaseWithProfile() {
|
|||
if (it is InputBg) {
|
||||
it.profileFunction = profileFunction
|
||||
}
|
||||
if (it is InputTempTarget) {
|
||||
it.profileFunction = profileFunction
|
||||
}
|
||||
if (it is GlucoseStatus) {
|
||||
it.aapsLogger = aapsLogger
|
||||
it.iobCobCalculatorPlugin = iobCobCalculatorPlugin
|
||||
|
|
Loading…
Reference in a new issue