(Hopefully) fix iob(AMA|SMB)shouldBeLimited tests.

By making sure there is exactly one APS plugin enabled.
This commit is contained in:
Johannes Mockenhaupt 2018-06-23 13:12:29 +02:00
parent 8f647460b8
commit afe9a845d3
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -233,13 +233,14 @@ public class ConstraintsCheckerTest {
// 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);
OpenAPSMAPlugin.getPlugin().setPluginEnabled(PluginType.APS, false);
OpenAPSSMBPlugin.getPlugin().setPluginEnabled(PluginType.APS, false);
// Apply all limits
Constraint<Double> d = constraintChecker.getMaxIOBAllowed();
Assert.assertEquals(1.5d, d.value());
Assert.assertEquals(3, d.getReasonList().size());
Assert.assertEquals(d.getReasonList().toString(),2, d.getReasonList().size());
Assert.assertEquals("Safety: Limiting IOB to 1.5 U because of max value in preferences", d.getMostLimitedReasons());
}
@ -250,11 +251,13 @@ public class ConstraintsCheckerTest {
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);
OpenAPSAMAPlugin.getPlugin().setPluginEnabled(PluginType.APS, false);
OpenAPSMAPlugin.getPlugin().setPluginEnabled(PluginType.APS, false);
// Apply all limits
Constraint<Double> d = constraintChecker.getMaxIOBAllowed();
Assert.assertEquals(3d, d.value());
Assert.assertEquals(4, d.getReasonList().size());
Assert.assertEquals(d.getReasonList().toString(), 2, d.getReasonList().size());
Assert.assertEquals("Safety: Limiting IOB to 3.0 U because of max value in preferences", d.getMostLimitedReasons());
}