- fixing tests

This commit is contained in:
Andy Rozman 2022-05-31 13:45:53 +01:00
parent e0daa11ccd
commit 80b2eda1dd
4 changed files with 24 additions and 6 deletions

View file

@ -6,7 +6,9 @@ import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.PumpSync import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil
import info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncStorage import info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncStorage
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.MedtronicPumpHistoryDecoder import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.MedtronicPumpHistoryDecoder
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntry import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntry
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntryType import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntryType
@ -29,6 +31,8 @@ open class TestBase {
val aapsLogger = AAPSLoggerTest() val aapsLogger = AAPSLoggerTest()
val aapsSchedulers: AapsSchedulers = TestAapsSchedulers() val aapsSchedulers: AapsSchedulers = TestAapsSchedulers()
var rxBus: RxBus = RxBus(TestAapsSchedulers(), aapsLogger) var rxBus: RxBus = RxBus(TestAapsSchedulers(), aapsLogger)
var byteUtil = ByteUtil()
var rileyLinkUtil = RileyLinkUtil()
@Mock lateinit var pumpSync: PumpSync @Mock lateinit var pumpSync: PumpSync
@Mock lateinit var pumpSyncStorage: PumpSyncStorage @Mock lateinit var pumpSyncStorage: PumpSyncStorage

View file

@ -45,8 +45,7 @@ class MedtronicHistoryDataUTest : TestBase() {
// ) // )
var byteUtil = ByteUtil()
var rileyLinkUtil = RileyLinkUtil()
//lateinit var rxBus: RxBus //lateinit var rxBus: RxBus
lateinit var medtronicHistoryData: MedtronicHistoryData lateinit var medtronicHistoryData: MedtronicHistoryData

View file

@ -9,13 +9,11 @@ import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.RawHistory
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.interfaces.ResourceHelper
import info.nightscout.androidaps.utils.rx.TestAapsSchedulers import info.nightscout.androidaps.utils.rx.TestAapsSchedulers
import info.nightscout.shared.sharedPreferences.SP
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
import org.junit.Ignore
import org.junit.Test import org.junit.Test
import org.mockito.Answers
import org.mockito.Mock import org.mockito.Mock
/** /**
@ -27,13 +25,14 @@ class MedtronicPumpHistoryDecoderUTest : TestBase() {
//@Mock lateinit var injector: HasAndroidInjector //@Mock lateinit var injector: HasAndroidInjector
//@Mock lateinit var rh: ResourceHelper //@Mock lateinit var rh: ResourceHelper
// @Mock(answer = Answers.RETURNS_DEEP_STUBS) lateinit var activePlugin: ActivePlugin // @Mock(answer = Answers.RETURNS_DEEP_STUBS) lateinit var activePlugin: ActivePlugin
@Mock lateinit var rileyLinkUtil: RileyLinkUtil //@Mock lateinit var rileyLinkUtil: RileyLinkUtil
//@Mock lateinit var sp: SP //@Mock lateinit var sp: SP
private var medtronicPumpStatus: MedtronicPumpStatus? = null private var medtronicPumpStatus: MedtronicPumpStatus? = null
//private var medtronicUtil: MedtronicUtil? = null //private var medtronicUtil: MedtronicUtil? = null
//private var decoder: MedtronicPumpHistoryDecoder? = null //private var decoder: MedtronicPumpHistoryDecoder? = null
var rxBusWrapper = RxBus(TestAapsSchedulers(), aapsLogger) var rxBusWrapper = RxBus(TestAapsSchedulers(), aapsLogger)
@Before fun setup() { @Before fun setup() {
medtronicPumpStatus = medtronicPumpStatus =
MedtronicPumpStatus(rh, sp, rxBusWrapper, rileyLinkUtil) MedtronicPumpStatus(rh, sp, rxBusWrapper, rileyLinkUtil)

View file

@ -18,6 +18,8 @@ import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpSta
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil
import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import org.junit.Before
import org.junit.Ignore
import org.junit.Test import org.junit.Test
import org.mockito.Mock import org.mockito.Mock
@ -39,6 +41,20 @@ class MedtronicHistoryDataUTest : TestBase() {
// } // }
// } // }
@Before
fun setUp() {
medtronicUtil = MedtronicUtil(
aapsLogger, rxBus, rileyLinkUtil,
medtronicPumpStatus
)
decoder = MedtronicPumpHistoryDecoder(
aapsLogger,
medtronicUtil, byteUtil
)
}
@Test @Test
fun createTBRProcessList() { fun createTBRProcessList() {