From c1e5330b7147393598821a5034c719536fa487bf Mon Sep 17 00:00:00 2001 From: Pete Schwamb Date: Mon, 31 Jul 2023 09:39:24 -0500 Subject: [PATCH] Fix isf schedule to match previous, and fix tests --- .../live_capture_predicted_glucose.json | 124 +++++++++--------- .../Managers/LoopDataManagerDosingTests.swift | 8 +- LoopTests/Managers/LoopDataManagerTests.swift | 7 +- 3 files changed, 71 insertions(+), 68 deletions(-) diff --git a/LoopTests/Fixtures/live_capture/live_capture_predicted_glucose.json b/LoopTests/Fixtures/live_capture/live_capture_predicted_glucose.json index b2570f0587..8ec8f4688c 100644 --- a/LoopTests/Fixtures/live_capture/live_capture_predicted_glucose.json +++ b/LoopTests/Fixtures/live_capture/live_capture_predicted_glucose.json @@ -12,311 +12,311 @@ { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T19:30:00Z", - "quantity" : 177.65020176872684 + "quantity" : 177.56455527893289 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T19:35:00Z", - "quantity" : 177.94580229441291 + "quantity" : 177.67338252385397 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T19:40:00Z", - "quantity" : 175.46611293843657 + "quantity" : 174.91272423228034 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T19:45:00Z", - "quantity" : 172.59722791126055 + "quantity" : 171.75695070238604 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T19:50:00Z", - "quantity" : 169.87495105555067 + "quantity" : 168.76244616110549 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T19:55:00Z", - "quantity" : 167.32206948698089 + "quantity" : 165.95427643567874 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T20:00:00Z", - "quantity" : 164.95802828894384 + "quantity" : 163.35383111783804 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T20:05:00Z", - "quantity" : 162.799237889301 + "quantity" : 160.97916167823055 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T20:10:00Z", - "quantity" : 160.85935776247501 + "quantity" : 158.84529353872236 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T20:15:00Z", - "quantity" : 159.14955811070476 + "quantity" : 156.96451392177406 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T20:20:00Z", - "quantity" : 157.67876106975845 + "quantity" : 155.34663717673348 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T20:25:00Z", - "quantity" : 156.45386288277368 + "quantity" : 153.99924917105037 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T20:30:00Z", - "quantity" : 155.47993839055547 + "quantity" : 152.92793222961055 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T20:35:00Z", - "quantity" : 154.76042909743759 + "quantity" : 152.13647200718029 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T20:40:00Z", - "quantity" : 154.29731598814382 + "quantity" : 151.62704758695727 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T20:45:00Z", - "quantity" : 154.05608025922115 + "quantity" : 151.36168828514261 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T20:50:00Z", - "quantity" : 153.87872253327541 + "quantity" : 151.16659478660213 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T20:55:00Z", - "quantity" : 153.74477419409126 + "quantity" : 151.01925161349905 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T21:00:00Z", - "quantity" : 153.65183422706659 + "quantity" : 150.9170176497727 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T21:05:00Z", - "quantity" : 153.59671237426855 + "quantity" : 150.85638361169495 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T21:10:00Z", - "quantity" : 153.57553108615807 + "quantity" : 150.83308419477353 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T21:15:00Z", - "quantity" : 153.58221248644404 + "quantity" : 150.84043373508726 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T21:20:00Z", - "quantity" : 153.60736142719529 + "quantity" : 150.86809756991411 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T21:25:00Z", - "quantity" : 153.64251644837177 + "quantity" : 150.9067680932084 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T21:30:00Z", - "quantity" : 153.6805897321145 + "quantity" : 150.94864870532584 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T21:35:00Z", - "quantity" : 153.71382876489778 + "quantity" : 150.98521164138711 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T21:40:00Z", - "quantity" : 153.73532014905877 + "quantity" : 151.00885216396446 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T21:45:00Z", - "quantity" : 153.73944380707744 + "quantity" : 151.01338818778473 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T21:50:00Z", - "quantity" : 153.71948579563409 + "quantity" : 150.99143437519743 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T21:55:00Z", - "quantity" : 153.66633596110259 + "quantity" : 150.93296955721272 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T22:00:00Z", - "quantity" : 153.57131359166951 + "quantity" : 150.82844495083614 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T22:05:00Z", - "quantity" : 153.42733862575696 + "quantity" : 150.67007248833207 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T22:10:00Z", - "quantity" : 153.22562081288501 + "quantity" : 150.44818289417267 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T22:15:00Z", - "quantity" : 152.95757302315255 + "quantity" : 150.15333032546724 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T22:20:00Z", - "quantity" : 152.6168486074574 + "quantity" : 149.77853346820271 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T22:25:00Z", - "quantity" : 152.19791624412059 + "quantity" : 149.31770786853204 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T22:30:00Z", - "quantity" : 151.69512603552343 + "quantity" : 148.76463863907512 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T22:35:00Z", - "quantity" : 151.10190276047783 + "quantity" : 148.11209303652518 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T22:40:00Z", - "quantity" : 150.41252429050209 + "quantity" : 147.3537767195518 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T22:45:00Z", - "quantity" : 149.62228184545992 + "quantity" : 146.48451003000551 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T22:50:00Z", - "quantity" : 148.72654511478126 + "quantity" : 145.49919962625873 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T22:55:00Z", - "quantity" : 147.72075310438126 + "quantity" : 144.39282841481932 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T23:00:00Z", - "quantity" : 146.63562181392635 + "quantity" : 143.1991839953188 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T23:05:00Z", - "quantity" : 145.62427893410708 + "quantity" : 142.08670682751759 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T23:10:00Z", - "quantity" : 144.70139300297419 + "quantity" : 141.07153230327131 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T23:15:00Z", - "quantity" : 143.86276464047646 + "quantity" : 140.14904110452417 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T23:20:00Z", - "quantity" : 143.10429998676349 + "quantity" : 139.31472998543964 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T23:25:00Z", - "quantity" : 142.42201473268764 + "quantity" : 138.56421620595611 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T23:30:00Z", - "quantity" : 141.81203730584602 + "quantity" : 137.8932410364304 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T23:35:00Z", - "quantity" : 141.27061129418698 + "quantity" : 137.29767242360586 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T23:40:00Z", - "quantity" : 140.79409718279939 + "quantity" : 136.77350690107906 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T23:45:00Z", - "quantity" : 140.37897347352472 + "quantity" : 136.3168708208772 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T23:50:00Z", - "quantity" : 140.02183725149743 + "quantity" : 135.92402097664686 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-29T23:55:00Z", - "quantity" : 139.71940425754278 + "quantity" : 135.59134468329685 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-30T00:00:00Z", - "quantity" : 139.46850852060183 + "quantity" : 135.31535937266145 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-30T00:05:00Z", - "quantity" : 139.26610159988408 + "quantity" : 135.09271175987229 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-30T00:10:00Z", - "quantity" : 139.10925148234227 + "quantity" : 134.92017663057632 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-30T00:15:00Z", - "quantity" : 138.99514117722615 + "quantity" : 134.79465529494851 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-30T00:20:00Z", - "quantity" : 138.92106704593706 + "quantity" : 134.71317375053073 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-30T00:25:00Z", - "quantity" : 138.88443690211088 + "quantity" : 134.67288059232183 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-30T00:30:00Z", - "quantity" : 138.87759728271371 + "quantity" : 134.66535701098488 }, { "quantityUnit" : "mg\/dL", "startDate" : "2023-07-30T01:20:54Z", - "quantity" : 138.87759728271371 + "quantity" : 134.66535701098488 } ] diff --git a/LoopTests/Managers/LoopDataManagerDosingTests.swift b/LoopTests/Managers/LoopDataManagerDosingTests.swift index cfc96a6f54..621aa348a5 100644 --- a/LoopTests/Managers/LoopDataManagerDosingTests.swift +++ b/LoopTests/Managers/LoopDataManagerDosingTests.swift @@ -56,7 +56,7 @@ class LoopDataManagerDosingTests: LoopDataManagerTests { // MARK: Tests func testForecastFromLiveCaptureInputData() { setUp(for: .liveCapture) - let predictedGlucoseOutput = loadPredictedGlucoseFixture("live_capture_predicted_glucose") + let expectedPredictedGlucose = loadPredictedGlucoseFixture("live_capture_predicted_glucose") let updateGroup = DispatchGroup() updateGroup.enter() @@ -71,14 +71,14 @@ class LoopDataManagerDosingTests: LoopDataManagerTests { updateGroup.wait() XCTAssertNotNil(predictedGlucose) - XCTAssertEqual(predictedGlucoseOutput.count, predictedGlucose!.count) + XCTAssertEqual(expectedPredictedGlucose.count, predictedGlucose!.count) - for (expected, calculated) in zip(predictedGlucoseOutput, predictedGlucose!) { + for (expected, calculated) in zip(expectedPredictedGlucose, predictedGlucose!) { XCTAssertEqual(expected.startDate, calculated.startDate) XCTAssertEqual(expected.quantity.doubleValue(for: .milligramsPerDeciliter), calculated.quantity.doubleValue(for: .milligramsPerDeciliter), accuracy: defaultAccuracy) } - XCTAssertEqual(2.27, recommendedBasal!.unitsPerHour, accuracy: defaultAccuracy) + XCTAssertEqual(1.99, recommendedBasal!.unitsPerHour, accuracy: defaultAccuracy) } diff --git a/LoopTests/Managers/LoopDataManagerTests.swift b/LoopTests/Managers/LoopDataManagerTests.swift index 45a3faf682..32c7d66f19 100644 --- a/LoopTests/Managers/LoopDataManagerTests.swift +++ b/LoopTests/Managers/LoopDataManagerTests.swift @@ -133,8 +133,11 @@ class LoopDataManagerTests: XCTestCase { let insulinSensitivitySchedule = InsulinSensitivitySchedule( unit: .milligramsPerDeciliter, dailyItems: [ - RepeatingScheduleValue(startTime: 0, value: 50) - ]) + RepeatingScheduleValue(startTime: 0, value: 45), + RepeatingScheduleValue(startTime: 32400, value: 55) + ], + timeZone: .utcTimeZone + )! let carbRatioSchedule = CarbRatioSchedule( unit: .gram(), dailyItems: [