Fix unit test, cleanup

This commit is contained in:
jbr7rr 2023-07-16 11:59:36 +02:00
parent 41f51d26c0
commit 966939a9de
35 changed files with 36 additions and 37 deletions

View file

@ -10,4 +10,4 @@ interface Medtrum {
fun clearAlarms(): PumpEnactResult // clear alarms
fun deactivate(): PumpEnactResult // deactivate patch
fun updateTime(): PumpEnactResult // update time
}
}

View file

@ -393,7 +393,7 @@
<string name="carbs_g">CARBS %1$d g</string>
<string name="extended_bolus_u_min">EXTENDED BOLUS %1$.2f U %2$d min</string>
<string name="load_events">LOAD EVENTS</string>
<string name="clear_alarms">CLEAR_ALARMS</string>
<string name="clear_alarms">CLEAR ALARMS</string>
<string name="deactivate">DEACTIVATE</string>
<string name="update_time">UPDATE TIME</string>
<string name="load_history">LOAD HISTORY %1$d</string>

View file

@ -14,4 +14,4 @@
android:exported="false" />
</application>
</manifest>
</manifest>

View file

@ -23,4 +23,4 @@ class OnSafeClickListener(
// Set duplicate click prevention time
private const val MIN_CLICK_INTERVAL: Long = 1000
}
}
}

View file

@ -5,4 +5,4 @@ enum class ConnectionState {
DISCONNECTED,
CONNECTING,
DISCONNECTING;
}
}

View file

@ -20,4 +20,4 @@ enum class AlarmState {
BASE_FAULT, // Mapped from pump status 101
BATTERY_OUT, // Mapped from pump status 102
NO_CALIBRATION // Mapped from pump status 103
}
}

View file

@ -223,7 +223,7 @@ class GetRecordPacket(injector: HasAndroidInjector, private val recordIndex: Int
var duration = (basalEndTime - basalStartTime)
// Work around for pumpSync not accepting 0 duration.
// sometimes we get 0 duration for very short basal because the pump only reports time in seconds
if (duration < 250) duration = 250 // 250ms to make sure timestamp is unique
if (duration < 250) duration = 250 // 250ms to make sure AAPS accepts it
val newRecord = pumpSync.syncTemporaryBasalWithPumpId(
timestamp = basalStartTime,
@ -306,4 +306,4 @@ class GetRecordPacket(injector: HasAndroidInjector, private val recordIndex: Int
return success
}
}
}

View file

@ -16,4 +16,4 @@ private inline fun FragmentManager.transact(action: FragmentTransaction.() -> Un
beginTransaction().apply {
action()
}.commit()
}
}

View file

@ -240,7 +240,7 @@ class MedtrumService : DaggerService(), BLECommCallback {
fun loadEvents(): Boolean {
rxBus.send(EventPumpStatusChanged(rh.gs(R.string.gettingpumpstatus)))
// Sync records (based on the info we have from the sync)
// Sync records
val result = syncRecords()
if (result) {
aapsLogger.debug(LTag.PUMPCOMM, "Events loaded")

View file

@ -54,4 +54,4 @@ abstract class MedtrumBaseActivity<B : ViewDataBinding> : DaggerAppCompatActivit
finish()
}
}
}
}

View file

@ -63,4 +63,4 @@ abstract class MedtrumBaseFragment<B : ViewDataBinding> : DaggerFragment(), Medt
override fun finish(finishAffinity: Boolean) {
baseActivity?.finish(finishAffinity)
}
}
}

View file

@ -4,4 +4,4 @@ interface MedtrumBaseNavigator {
fun back()
fun finish(finishAffinity: Boolean = false)
}
}

View file

@ -61,4 +61,4 @@ class MedtrumOverviewFragment : MedtrumBaseFragment<FragmentMedtrumOverviewBindi
override fun onResume() {
super.onResume()
}
}
}

View file

@ -26,4 +26,4 @@ open class SingleLiveEvent<T> : MutableLiveData<T>() {
fun call() {
value = null
}
}
}

View file

@ -187,4 +187,3 @@ class MedtrumOverviewViewModel @Inject constructor(
}
}
}

View file

@ -140,6 +140,7 @@ class MedtrumViewModel @Inject constructor(
when (newPatchStep) {
PatchStep.CANCEL -> {
if (oldPatchStep !in listOf(
PatchStep.PREPARE_PATCH,
PatchStep.START_DEACTIVATION,
PatchStep.DEACTIVATE,
PatchStep.FORCE_DEACTIVATION,
@ -148,7 +149,6 @@ class MedtrumViewModel @Inject constructor(
) {
medtrumService?.disconnect("Cancel")
}
medtrumService?.disconnect("Cancel")
}
PatchStep.COMPLETE -> {

View file

@ -37,4 +37,4 @@ class ViewModelFactory @Inject constructor(private val creators: Map<Class<out V
}
}
}
}

View file

@ -47,4 +47,4 @@
</LinearLayout>
</layout>
</layout>

View file

@ -77,4 +77,4 @@
</ScrollView>
</layout>
</layout>

View file

@ -76,4 +76,4 @@
</ScrollView>
</layout>
</layout>

View file

@ -91,4 +91,4 @@
</ScrollView>
</layout>
</layout>

View file

@ -78,4 +78,4 @@
</ScrollView>
</layout>
</layout>

View file

@ -89,4 +89,4 @@
</ScrollView>
</layout>
</layout>

View file

@ -106,4 +106,4 @@
</ScrollView>
</layout>
</layout>

View file

@ -106,4 +106,4 @@
</ScrollView>
</layout>
</layout>

View file

@ -93,4 +93,4 @@
</ScrollView>
</layout>
</layout>

View file

@ -93,4 +93,4 @@
</ScrollView>
</layout>
</layout>

View file

@ -104,4 +104,4 @@
</ScrollView>
</layout>
</layout>

View file

@ -90,4 +90,4 @@
</ScrollView>
</layout>
</layout>

View file

@ -63,4 +63,4 @@
</ScrollView>
</layout>
</layout>

View file

@ -88,4 +88,4 @@
</ScrollView>
</layout>
</layout>

View file

@ -104,4 +104,4 @@ class ProfileStoreObject(val injector: HasAndroidInjector, override val data: JS
.map { profileName -> getSpecificProfile(profileName.toString()) }
.map { pureProfile -> pureProfile?.let { ProfileSealed.Pure(pureProfile).isValid("allProfilesValid", activePlugin.activePump, config, rh, rxBus, hardLimits, false) } }
.all { it?.isValid == true }
}
}

View file

@ -59,4 +59,4 @@ class GetRecordPacketTest : MedtrumTestBase() {
assertEquals(false, result)
assertEquals(true, packet.failed)
}
}
}

View file

@ -88,4 +88,4 @@ class NotificationPacketTest : MedtrumTestBase() {
assertEquals(1.65, medtrumPump.bolusingTreatment!!.insulin, 0.01)
assertEquals(161.95, medtrumPump.reservoir, 0.01)
}
}
}

View file

@ -93,10 +93,10 @@ class SynchronizePacketTest : MedtrumTestBase() {
assertEquals(25, packet.medtrumPump.lastBasalSequence)
assertEquals(14, packet.medtrumPump.lastBasalPatchId)
assertEquals(1685126612000, packet.medtrumPump.lastBasalStartTime)
assertEquals(8123, packet.medtrumPump.patchAge)
assertEquals(186.80, packet.medtrumPump.reservoir, 0.01)
assertEquals(296585720, packet.medtrumPump.patchAge)
assertEquals(1685120120000, packet.medtrumPump.patchStartTime)
assertEquals(5.96875, packet.medtrumPump.batteryVoltage_A, 0.01)
assertEquals(2.8125, packet.medtrumPump.batteryVoltage_B, 0.01)
assertEquals(1388542523000, packet.medtrumPump.patchStartTime)
}
}