From a609d806d184441d27840de3274e9dd7e73ef210 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 8 Apr 2018 20:37:05 +0200 Subject: [PATCH] fix tests --- .../interfaces/ConstraintsCheckerTest.java | 20 ++++++++++++++++--- .../ConstraintsSafety/SafetyPluginTest.java | 5 ++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.java b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.java index 4617335c18..f3fa04603e 100644 --- a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.java +++ b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.java @@ -229,22 +229,36 @@ public class ConstraintsCheckerTest { // applyMaxIOBConstraints tests @Test - public void iobShouldBeLimited() throws Exception { + public void iobAMAShouldBeLimited() { // No limit by default when(SP.getDouble(R.string.key_openapsma_max_iob, 1.5d)).thenReturn(1.5d); when(SP.getString(R.string.key_age, "")).thenReturn("teenage"); OpenAPSMAPlugin.getPlugin().setPluginEnabled(PluginType.APS, true); OpenAPSAMAPlugin.getPlugin().setPluginEnabled(PluginType.APS, true); - OpenAPSSMBPlugin.getPlugin().setPluginEnabled(PluginType.APS, true); // Apply all limits Constraint d = constraintChecker.getMaxIOBAllowed(); Assert.assertEquals(1.5d, d.value()); - Assert.assertEquals(true, d.getReasonList().size() == 4); + Assert.assertEquals(3, d.getReasonList().size()); Assert.assertEquals("Safety: Limiting IOB to 1.5 U because of max value in preferences", d.getMostLimitedReasons()); } + @Test + public void iobSMBShouldBeLimited() { + // No limit by default + when(SP.getDouble(R.string.key_openapssmb_max_iob, 3d)).thenReturn(3d); + when(SP.getString(R.string.key_age, "")).thenReturn("teenage"); + OpenAPSSMBPlugin.getPlugin().setPluginEnabled(PluginType.APS, true); + + // Apply all limits + Constraint d = constraintChecker.getMaxIOBAllowed(); + Assert.assertEquals(3d, d.value()); + Assert.assertEquals(4, d.getReasonList().size()); + Assert.assertEquals("Safety: Limiting IOB to 3.0 U because of max value in preferences", d.getMostLimitedReasons()); + + } + @Before public void prepareMock() throws Exception { diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/ConstraintsSafety/SafetyPluginTest.java b/app/src/test/java/info/nightscout/androidaps/plugins/ConstraintsSafety/SafetyPluginTest.java index 0bd35e49ff..76901e5db4 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/ConstraintsSafety/SafetyPluginTest.java +++ b/app/src/test/java/info/nightscout/androidaps/plugins/ConstraintsSafety/SafetyPluginTest.java @@ -210,7 +210,7 @@ public class SafetyPluginTest { when(SP.getString(R.string.key_age, "")).thenReturn("teenage"); OpenAPSMAPlugin.getPlugin().setPluginEnabled(PluginType.APS, true); OpenAPSAMAPlugin.getPlugin().setPluginEnabled(PluginType.APS, true); - OpenAPSSMBPlugin.getPlugin().setPluginEnabled(PluginType.APS, true); + //OpenAPSSMBPlugin.getPlugin().setPluginEnabled(PluginType.APS, true); // Apply all limits Constraint d = new Constraint<>(Constants.REALLYHIGHIOB); @@ -218,8 +218,7 @@ public class SafetyPluginTest { Assert.assertEquals(1.5d, d.value()); Assert.assertEquals("Safety: Limiting IOB to 1.5 U because of max value in preferences\n" + "Safety: Limiting IOB to 7.0 U because of hard limit\n" + - "Safety: Limiting IOB to 7.0 U because of hard limit\n" + - "Safety: Limiting IOB to 12.0 U because of hard limit", d.getReasons()); + "Safety: Limiting IOB to 7.0 U because of hard limit", d.getReasons()); Assert.assertEquals("Safety: Limiting IOB to 1.5 U because of max value in preferences", d.getMostLimitedReasons()); }