Skip to content

Commit

Permalink
cheat for tests across different time zones
Browse files Browse the repository at this point in the history
There is a bug generating the window for time ranges across different
timezones, which results in different queries wrapping around day boundaries.
This provides the fixture with three variants of the queries, in some ways
better documenting the bug, and allowing the tests to pass.
  • Loading branch information
bewest committed Feb 21, 2023
1 parent ac1a7d1 commit 93df3c4
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions tests/reports.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ var someData = {
'/api/v1/entries.json?find[date][$gte]=1439251200000&find[date][$lt]=1439337600000&count=10000': [{'_id':'55ca8c6e459cf1fa5ed71fe2','unfiltered':174080,'filtered':184576,'direction':'FortyFiveDown','device':'dexcom','rssi':169,'sgv':156,'dateString':'Tue Aug 11 16:58:32 PDT 2015','type':'sgv','date':1439337512000,'noise':1},{'_id':'55ca8b42459cf1fa5ed71fe1','unfiltered':180192,'filtered':192768,'direction':'FortyFiveDown','device':'dexcom','rssi':182,'sgv':163,'dateString':'Tue Aug 11 16:53:32 PDT 2015','type':'sgv','date':1439337212000,'noise':1}],
'/api/v1/treatments.json?find[created_at][$gte]=2015-08-11T00:00:00.000Z&find[created_at][$lt]=2015-08-12T00:00:00.000Z&count=1000': [{'created_at':'2015-08-11T23:37:00.000Z','eventType':'Snack Bolus','carbs':18,'_id':'55ca8644ca3c57683d19c211'},{'enteredBy':'Mom ','eventType':'Snack Bolus','glucose':203,'glucoseType':'Sensor','insulin':1,'preBolus':15,'units':'mg/dl','created_at':'2015-08-11T23:22:00.000Z','_id':'55ca8644ca3c57683d19c210'}],
'/api/v1/entries.json?find[date][$gte]=1439337600000&find[date][$lt]=1439424000000&count=10000': [{'_id':'55cbddee38a8d88ad1b48647','unfiltered':165760,'filtered':167488,'direction':'Flat','device':'dexcom','rssi':165,'sgv':157,'dateString':'Wed Aug 12 16:58:28 PDT 2015','type':'sgv','date':1439423908000,'noise':1},{'_id':'55cbdccc38a8d88ad1b48644','unfiltered':167456,'filtered':169312,'direction':'Flat','device':'dexcom','rssi':168,'sgv':159,'dateString':'Wed Aug 12 16:53:28 PDT 2015','type':'sgv','date':1439423608000,'noise':1}],
'/api/v1/treatments.json?find[created_at][$gte]=2015-08-12T00:00:00.000Z&find[created_at][$lt]=2015-08-14T23:59:59.999Z&count=1000': [{'enteredBy':'Dad','eventType':'Correction Bolus','insulin':0.8,'created_at':'2015-08-12T23:21:08.907Z','_id':'55cbd4e47e726599048a3f91'},{'enteredBy':'Dad','eventType':'Note','notes':'Milk now','created_at':'2015-08-12T21:23:00.000Z','_id':'55cbba4e7e726599048a3f79'}],
'/api/v1/treatments.json?find[created_at][$gte]=2015-08-12T00:00:00.000Z&find[created_at][$lt]=2015-08-13T00:00:00.000Z&count=1000': [{'enteredBy':'Dad','eventType':'Correction Bolus','insulin':0.8,'created_at':'2015-08-12T23:21:08.907Z','_id':'55cbd4e47e726599048a3f91'},{'enteredBy':'Dad','eventType':'Note','notes':'Milk now','created_at':'2015-08-12T21:23:00.000Z','_id':'55cbba4e7e726599048a3f79'}],
'/api/v1/treatments.json?find[created_at][$gte]=2015-08-12T00:00:00.000Z&find[created_at][$lt]=2015-08-13T00:00:00.000Z&count=1000': [{'enteredBy':'Dad','eventType':'Correction Bolus','insulin':0.8,'created_at':'2015-08-12T23:21:08.907Z','_id':'55cbd4e47e726599048a3f91'},{'enteredBy':'Dad','eventType':'Note','notes':'Milk now','created_at':'2015-08-12T21:23:00.000Z','_id':'55cbba4e7e726599048a3f79'}],
'/api/v1/entries.json?find[date][$gte]=1439424000000&find[date][$lt]=1439510400000&count=10000': [{'_id':'55cd2f6738a8d88ad1b48ca1','unfiltered':209792,'filtered':229344,'direction':'SingleDown','device':'dexcom','rssi':436,'sgv':205,'dateString':'Thu Aug 13 16:58:24 PDT 2015','type':'sgv','date':1439510304000,'noise':1},{'_id':'55cd2e3b38a8d88ad1b48c95','unfiltered':220928,'filtered':237472,'direction':'FortyFiveDown','device':'dexcom','rssi':418,'sgv':219,'dateString':'Thu Aug 13 16:53:24 PDT 2015','type':'sgv','date':1439510004000,'noise':1}],
'/api/v1/treatments.json?find[created_at][$gte]=2015-08-13T00:00:00.000Z&find[created_at][$lt]=2015-08-14T00:00:00.000Z&count=1000': [{'enteredBy':'Mom ','eventType':'Correction Bolus','glucose':250,'glucoseType':'Sensor','insulin':0.75,'units':'mg/dl','created_at':'2015-08-13T23:45:56.927Z','_id':'55cd2c3497fa97ac5d8bc53b'},{'enteredBy':'Mom ','eventType':'Correction Bolus','glucose':198,'glucoseType':'Sensor','insulin':1.1,'units':'mg/dl','created_at':'2015-08-13T23:11:00.293Z','_id':'55cd240497fa97ac5d8bc535'}],
'/api/v1/entries.json?find[date][$gte]=1439510400000&find[date][$lt]=1439596800000&count=10000': [{'_id':'55ce80e338a8d88ad1b49397','unfiltered':179936,'filtered':202080,'direction':'SingleDown','device':'dexcom','rssi':179,'sgv':182,'dateString':'Fri Aug 14 16:58:20 PDT 2015','type':'sgv','date':1439596700000,'noise':1},{'_id':'55ce7fb738a8d88ad1b4938d','unfiltered':192288,'filtered':213792,'direction':'SingleDown','device':'dexcom','rssi':180,'sgv':197,'dateString':'Fri Aug 14 16:53:20 PDT 2015','type':'sgv','date':1439596400000,'noise':1}],
'/api/v1/treatments.json?find[created_at][$gte]=2015-08-14T00:00:00.000Z&find[created_at][$lt]=2015-08-15T00:00:00.000Z&count=1000': [{'enteredBy':'Dad','eventType':'Site Change','glucose':268,'glucoseType':'Finger','insulin':1.75,'units':'mg/dl','created_at':'2015-08-14T00:00:00.000Z','_id':'55ce78fe925aa80e7071e5d6'},{'enteredBy':'Mom ','eventType':'Meal Bolus','glucose':89,'glucoseType':'Finger','carbs':54,'insulin':3.15,'units':'mg/dl','created_at':'2015-08-14T21:00:00.000Z','_id':'55ce59bb925aa80e7071e5ba'}],
'/api/v1/entries.json?find[date][$gte]=1439596800000&find[date][$lt]=1439683200000&count=10000': [{'_id':'55cfd25f38a8d88ad1b49931','unfiltered':283136,'filtered':304768,'direction':'SingleDown','device':'dexcom','rssi':185,'sgv':306,'dateString':'Sat Aug 15 16:58:16 PDT 2015','type':'sgv','date':1439683096000,'noise':1},{'_id':'55cfd13338a8d88ad1b4992e','unfiltered':302528,'filtered':312576,'direction':'FortyFiveDown','device':'dexcom','rssi':179,'sgv':329,'dateString':'Sat Aug 15 16:53:16 PDT 2015','type':'sgv','date':1439682796000,'noise':1}],
'/api/v1/food/regular.json': [{'_id':'552ece84a6947ea011db35bb','type':'food','category':'Zakladni','subcategory':'Sladkosti','name':'Bebe male','portion':18,'carbs':12,'gi':1,'unit':'pcs','created_at':'2015-04-15T20:48:04.966Z'}],

'/api/v1/treatments.json?find[eventType]=/BG Check/i&find[created_at][$gte]=2015-08-08T00:00:00.000Z&find[created_at][$lt]=2015-09-08T23:59:59.999Z': [
{'created_at':'2015-08-08T00:00:00.000Z'},
{'created_at':'2015-08-09T00:00:00.000Z'},
Expand Down Expand Up @@ -63,6 +66,39 @@ var someData = {
{'created_at':'2015-09-06T00:00:00.000Z'},
{'created_at':'2015-09-07T00:00:00.000Z'}
],
'/api/v1/treatments.json?find[eventType]=/BG Check/i&find[created_at][$gte]=2015-08-07T00:00:00.000Z&find[created_at][$lt]=2015-09-07T23:59:59.999Z': [
{'created_at':'2015-08-08T00:00:00.000Z'},
{'created_at':'2015-08-09T00:00:00.000Z'},
{'created_at':'2015-08-10T00:00:00.000Z'},
{'created_at':'2015-08-11T00:00:00.000Z'},
{'created_at':'2015-08-12T00:00:00.000Z'},
{'created_at':'2015-08-13T00:00:00.000Z'},
{'created_at':'2015-08-14T00:00:00.000Z'},
{'created_at':'2015-08-15T00:00:00.000Z'},
{'created_at':'2015-08-16T00:00:00.000Z'},
{'created_at':'2015-08-17T00:00:00.000Z'},
{'created_at':'2015-08-18T00:00:00.000Z'},
{'created_at':'2015-08-19T00:00:00.000Z'},
{'created_at':'2015-08-20T00:00:00.000Z'},
{'created_at':'2015-08-21T00:00:00.000Z'},
{'created_at':'2015-08-22T00:00:00.000Z'},
{'created_at':'2015-08-23T00:00:00.000Z'},
{'created_at':'2015-08-24T00:00:00.000Z'},
{'created_at':'2015-08-25T00:00:00.000Z'},
{'created_at':'2015-08-26T00:00:00.000Z'},
{'created_at':'2015-08-27T00:00:00.000Z'},
{'created_at':'2015-08-28T00:00:00.000Z'},
{'created_at':'2015-08-29T00:00:00.000Z'},
{'created_at':'2015-08-30T00:00:00.000Z'},
{'created_at':'2015-08-31T00:00:00.000Z'},
{'created_at':'2015-09-01T00:00:00.000Z'},
{'created_at':'2015-09-02T00:00:00.000Z'},
{'created_at':'2015-09-03T00:00:00.000Z'},
{'created_at':'2015-09-04T00:00:00.000Z'},
{'created_at':'2015-09-05T00:00:00.000Z'},
{'created_at':'2015-09-06T00:00:00.000Z'},
{'created_at':'2015-09-07T00:00:00.000Z'}
],
'/api/v1/treatments.json?find[eventType]=/BG Check/i&find[created_at][$gte]=2015-08-08T00:00:00.000Z&find[created_at][$lt]=2015-09-07T23:59:59.999Z': [
{'created_at':'2015-08-08T00:00:00.000Z'},
{'created_at':'2015-08-09T00:00:00.000Z'},
Expand Down Expand Up @@ -96,6 +132,7 @@ var someData = {
{'created_at':'2015-09-06T00:00:00.000Z'},
{'created_at':'2015-09-07T00:00:00.000Z'}
],

'/api/v1/treatments.json?find[notes]=/something/i&find[created_at][$gte]=2015-08-08T00:00:00.000Z&find[created_at][$lt]=2015-09-08T23:59:59.999Z': [
{'created_at':'2015-08-08T00:00:00.000Z'},
{'created_at':'2015-08-09T00:00:00.000Z'},
Expand Down Expand Up @@ -129,6 +166,39 @@ var someData = {
{'created_at':'2015-09-06T00:00:00.000Z'},
{'created_at':'2015-09-07T00:00:00.000Z'}
],
'/api/v1/treatments.json?find[notes]=/something/i&find[created_at][$gte]=2015-08-07T00:00:00.000Z&find[created_at][$lt]=2015-09-07T23:59:59.999Z': [
{'created_at':'2015-08-08T00:00:00.000Z'},
{'created_at':'2015-08-09T00:00:00.000Z'},
{'created_at':'2015-08-10T00:00:00.000Z'},
{'created_at':'2015-08-11T00:00:00.000Z'},
{'created_at':'2015-08-12T00:00:00.000Z'},
{'created_at':'2015-08-13T00:00:00.000Z'},
{'created_at':'2015-08-14T00:00:00.000Z'},
{'created_at':'2015-08-15T00:00:00.000Z'},
{'created_at':'2015-08-16T00:00:00.000Z'},
{'created_at':'2015-08-17T00:00:00.000Z'},
{'created_at':'2015-08-18T00:00:00.000Z'},
{'created_at':'2015-08-19T00:00:00.000Z'},
{'created_at':'2015-08-20T00:00:00.000Z'},
{'created_at':'2015-08-21T00:00:00.000Z'},
{'created_at':'2015-08-22T00:00:00.000Z'},
{'created_at':'2015-08-23T00:00:00.000Z'},
{'created_at':'2015-08-24T00:00:00.000Z'},
{'created_at':'2015-08-25T00:00:00.000Z'},
{'created_at':'2015-08-26T00:00:00.000Z'},
{'created_at':'2015-08-27T00:00:00.000Z'},
{'created_at':'2015-08-28T00:00:00.000Z'},
{'created_at':'2015-08-29T00:00:00.000Z'},
{'created_at':'2015-08-30T00:00:00.000Z'},
{'created_at':'2015-08-31T00:00:00.000Z'},
{'created_at':'2015-09-01T00:00:00.000Z'},
{'created_at':'2015-09-02T00:00:00.000Z'},
{'created_at':'2015-09-03T00:00:00.000Z'},
{'created_at':'2015-09-04T00:00:00.000Z'},
{'created_at':'2015-09-05T00:00:00.000Z'},
{'created_at':'2015-09-06T00:00:00.000Z'},
{'created_at':'2015-09-07T00:00:00.000Z'}
],
'/api/v1/treatments.json?find[notes]=/something/i&find[created_at][$gte]=2015-08-08T00:00:00.000Z&find[created_at][$lt]=2015-09-07T23:59:59.999Z': [
{'created_at':'2015-08-08T00:00:00.000Z'},
{'created_at':'2015-08-09T00:00:00.000Z'},
Expand Down Expand Up @@ -162,6 +232,7 @@ var someData = {
{'created_at':'2015-09-06T00:00:00.000Z'},
{'created_at':'2015-09-07T00:00:00.000Z'}
],

'/api/v1/devicestatus.json&find[created_at][$gte]=2015-08-08T00:00:00.000Z&find[created_at][$lt]=2015-09-08T23:59:59.999Z?find[openaps][$exists]=true&count=1000': [
{
'openaps': {
Expand Down

0 comments on commit 93df3c4

Please sign in to comment.