Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/development' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
huss committed Oct 1, 2023
2 parents df5af96 + dd778b0 commit d34ca44
Show file tree
Hide file tree
Showing 4 changed files with 189 additions and 0 deletions.
99 changes: 99 additions & 0 deletions src/server/test/web/readings.js
Original file line number Diff line number Diff line change
Expand Up @@ -1635,6 +1635,105 @@ mocha.describe('readings API', () => {
expect(res.body).to.have.property(`${METER_ID}`).to.have.property('0').to.have.property('startTimestamp');
expect(res.body).to.have.property(`${METER_ID}`).to.have.property('0').to.have.property('endTimestamp');
});
mocha.it('1 day bars for 15 minute reading intervals and quantity units with +-inf start/end time & kWh as kWh', async () => {
// Create 2D array for meter to feed into the database
// Note the meter ID is set so we know what to expect when a query is made.
const meterData = [
{
name: 'Electric Utility kWh',
unit: 'Electric_Utility',
defaultGraphicUnit: 'kWh',
displayable: true,
gps: undefined,
note: 'special meter',
file: 'test/web/readingsData/readings_ri_15_days_75.csv',
deleteFile: false,
readingFrequency: '15 minutes',
id: METER_ID
}
];
// Load the data into the database
await prepareTest(unitDatakWh, conversionDatakWh, meterData);
// Get the unit ID since the DB could use any value.
const unitId = await getUnitId('kWh');
// Load the expected response data from the corresponding csv file
const expected = await parseExpectedCsv('src/server/test/web/readingsData/expected_bar_ri_15_mu_kWh_gu_kWh_st_-inf_et_inf_bd_1.csv');
// Create a request to the API for unbounded reading times and save the response
const res = await chai.request(app).get(`/api/unitReadings/bar/meters/${METER_ID}`)
.query({
timeInterval: ETERNITY.toString(),
barWidthDays: 1,
graphicUnitId: unitId
});
// Check that the API reading is equal to what it is expected to equal
expectReadingToEqualExpected(res, expected);
});
mocha.it('7 day bars for 15 minute reading intervals and quantity units with +-inf start/end time & kWh as kWh', async () => {
// Create 2D array for meter to feed into the database
// Note the meter ID is set so we know what to expect when a query is made.
const meterData = [
{
name: 'Electric Utility kWh',
unit: 'Electric_Utility',
defaultGraphicUnit: 'kWh',
displayable: true,
gps: undefined,
note: 'special meter',
file: 'test/web/readingsData/readings_ri_15_days_75.csv',
deleteFile: false,
readingFrequency: '15 minutes',
id: METER_ID
}
];
// Load the data into the database
await prepareTest(unitDatakWh, conversionDatakWh, meterData);
// Get the unit ID since the DB could use any value.
const unitId = await getUnitId('kWh');
// Load the expected response data from the corresponding csv file
const expected = await parseExpectedCsv('src/server/test/web/readingsData/expected_bar_ri_15_mu_kWh_gu_kWh_st_-inf_et_inf_bd_7.csv');
// Create a request to the API for unbounded reading times and save the response
const res = await chai.request(app).get(`/api/unitReadings/bar/meters/${METER_ID}`)
.query({
timeInterval: ETERNITY.toString(),
barWidthDays: 7,
graphicUnitId: unitId
});
// Check that the API reading is equal to what it is expected to equal
expectReadingToEqualExpected(res, expected);
});
mocha.it('28 day bars for 15 minute reading intervals and quantity units with +-inf start/end time & kWh as kWh', async () => {
// Create 2D array for meter to feed into the database
// Note the meter ID is set so we know what to expect when a query is made.
const meterData = [
{
name: 'Electric Utility kWh',
unit: 'Electric_Utility',
defaultGraphicUnit: 'kWh',
displayable: true,
gps: undefined,
note: 'special meter',
file: 'test/web/readingsData/readings_ri_15_days_75.csv',
deleteFile: false,
readingFrequency: '15 minutes',
id: METER_ID
}
];
// Load the data into the database
await prepareTest(unitDatakWh, conversionDatakWh, meterData);
// Get the unit ID since the DB could use any value.
const unitId = await getUnitId('kWh');
// Load the expected response data from the corresponding csv file
const expected = await parseExpectedCsv('src/server/test/web/readingsData/expected_bar_ri_15_mu_kWh_gu_kWh_st_-inf_et_inf_bd_28.csv');
// Create a request to the API for unbounded reading times and save the response
const res = await chai.request(app).get(`/api/unitReadings/bar/meters/${METER_ID}`)
.query({
timeInterval: ETERNITY.toString(),
barWidthDays: 28,
graphicUnitId: unitId
});
// Check that the API reading is equal to what it is expected to equal
expectReadingToEqualExpected(res, expected);
});
});
mocha.describe('for groups', () => {
mocha.it('response should have a valid reading, startTimestamp, and endTimestamp', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
reading,start time,end time
4977.893128498,2022-08-18 00:00:00,2022-08-19 00:00:00
3953.26321968193,2022-08-19 00:00:00,2022-08-20 00:00:00
4916.6765481827,2022-08-20 00:00:00,2022-08-21 00:00:00
4859.62719076162,2022-08-21 00:00:00,2022-08-22 00:00:00
4565.70468718381,2022-08-22 00:00:00,2022-08-23 00:00:00
4692.88390512545,2022-08-23 00:00:00,2022-08-24 00:00:00
4691.06491254326,2022-08-24 00:00:00,2022-08-25 00:00:00
4869.16320631968,2022-08-25 00:00:00,2022-08-26 00:00:00
4312.58603290188,2022-08-26 00:00:00,2022-08-27 00:00:00
4780.411380864,2022-08-27 00:00:00,2022-08-28 00:00:00
4625.99892197977,2022-08-28 00:00:00,2022-08-29 00:00:00
4449.90004526236,2022-08-29 00:00:00,2022-08-30 00:00:00
4771.46579613657,2022-08-30 00:00:00,2022-08-31 00:00:00
4644.11060928806,2022-08-31 00:00:00,2022-09-01 00:00:00
4608.72788105763,2022-09-01 00:00:00,2022-09-02 00:00:00
5089.81042904272,2022-09-02 00:00:00,2022-09-03 00:00:00
4871.31864700904,2022-09-03 00:00:00,2022-09-04 00:00:00
4707.3863496913,2022-09-04 00:00:00,2022-09-05 00:00:00
4502.29136699128,2022-09-05 00:00:00,2022-09-06 00:00:00
4776.89319506074,2022-09-06 00:00:00,2022-09-07 00:00:00
4686.84763237131,2022-09-07 00:00:00,2022-09-08 00:00:00
4522.16634372149,2022-09-08 00:00:00,2022-09-09 00:00:00
4947.68225269031,2022-09-09 00:00:00,2022-09-10 00:00:00
4568.41799179167,2022-09-10 00:00:00,2022-09-11 00:00:00
5360.64682210954,2022-09-11 00:00:00,2022-09-12 00:00:00
4728.21616493888,2022-09-12 00:00:00,2022-09-13 00:00:00
4995.37806849453,2022-09-13 00:00:00,2022-09-14 00:00:00
4549.34153142048,2022-09-14 00:00:00,2022-09-15 00:00:00
4885.26209088548,2022-09-15 00:00:00,2022-09-16 00:00:00
4573.34504568515,2022-09-16 00:00:00,2022-09-17 00:00:00
4901.58681305082,2022-09-17 00:00:00,2022-09-18 00:00:00
5147.72364028936,2022-09-18 00:00:00,2022-09-19 00:00:00
4442.26014181883,2022-09-19 00:00:00,2022-09-20 00:00:00
5361.34123385844,2022-09-20 00:00:00,2022-09-21 00:00:00
4492.87888734816,2022-09-21 00:00:00,2022-09-22 00:00:00
4998.60455213579,2022-09-22 00:00:00,2022-09-23 00:00:00
4524.9423730622,2022-09-23 00:00:00,2022-09-24 00:00:00
4571.04952447909,2022-09-24 00:00:00,2022-09-25 00:00:00
4843.70056285797,2022-09-25 00:00:00,2022-09-26 00:00:00
4603.06793869098,2022-09-26 00:00:00,2022-09-27 00:00:00
4611.12902602756,2022-09-27 00:00:00,2022-09-28 00:00:00
4860.80508065946,2022-09-28 00:00:00,2022-09-29 00:00:00
5095.19417274387,2022-09-29 00:00:00,2022-09-30 00:00:00
4794.13083115735,2022-09-30 00:00:00,2022-10-01 00:00:00
4663.23349202509,2022-10-01 00:00:00,2022-10-02 00:00:00
4720.90341018342,2022-10-02 00:00:00,2022-10-03 00:00:00
4450.48736719453,2022-10-03 00:00:00,2022-10-04 00:00:00
4870.86748645093,2022-10-04 00:00:00,2022-10-05 00:00:00
4797.55306275087,2022-10-05 00:00:00,2022-10-06 00:00:00
4640.70486295399,2022-10-06 00:00:00,2022-10-07 00:00:00
5077.03627015989,2022-10-07 00:00:00,2022-10-08 00:00:00
4669.62317066277,2022-10-08 00:00:00,2022-10-09 00:00:00
4232.73276173624,2022-10-09 00:00:00,2022-10-10 00:00:00
4847.7408352229,2022-10-10 00:00:00,2022-10-11 00:00:00
4610.9376047644,2022-10-11 00:00:00,2022-10-12 00:00:00
5036.0998925712,2022-10-12 00:00:00,2022-10-13 00:00:00
4768.51307882197,2022-10-13 00:00:00,2022-10-14 00:00:00
4832.86685151642,2022-10-14 00:00:00,2022-10-15 00:00:00
4620.88411037972,2022-10-15 00:00:00,2022-10-16 00:00:00
4713.99937767654,2022-10-16 00:00:00,2022-10-17 00:00:00
4885.18039907724,2022-10-17 00:00:00,2022-10-18 00:00:00
4650.17194827144,2022-10-18 00:00:00,2022-10-19 00:00:00
4513.47476507829,2022-10-19 00:00:00,2022-10-20 00:00:00
4649.38885688699,2022-10-20 00:00:00,2022-10-21 00:00:00
4974.44319694756,2022-10-21 00:00:00,2022-10-22 00:00:00
4749.28026208309,2022-10-22 00:00:00,2022-10-23 00:00:00
4814.97662268041,2022-10-23 00:00:00,2022-10-24 00:00:00
4894.51070062811,2022-10-24 00:00:00,2022-10-25 00:00:00
5391.40965029964,2022-10-25 00:00:00,2022-10-26 00:00:00
4542.31010939904,2022-10-26 00:00:00,2022-10-27 00:00:00
4367.67151816391,2022-10-27 00:00:00,2022-10-28 00:00:00
4814.54181926608,2022-10-28 00:00:00,2022-10-29 00:00:00
5396.55949001254,2022-10-29 00:00:00,2022-10-30 00:00:00
4842.21261747704,2022-10-30 00:00:00,2022-10-31 00:00:00
4290.60000224332,2022-10-31 00:00:00,2022-11-01 00:00:00
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
reading,start time,end time
133677.236186752,2022-09-06 00:00:00,2022-10-04 00:00:00
133496.291324183,2022-10-04 00:00:00,2022-11-01 00:00:00
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
reading,start time,end time
32422.0084049964,2022-08-23 00:00:00,2022-08-30 00:00:00
33195.1110792166,2022-08-30 00:00:00,2022-09-06 00:00:00
33590.8704026839,2022-09-06 00:00:00,2022-09-13 00:00:00
33494.8973316447,2022-09-13 00:00:00,2022-09-20 00:00:00
33395.5850724326,2022-09-20 00:00:00,2022-09-27 00:00:00
33195.8833799913,2022-09-27 00:00:00,2022-10-04 00:00:00
33136.2584499376,2022-10-04 00:00:00,2022-10-11 00:00:00
33468.4813148075,2022-10-11 00:00:00,2022-10-18 00:00:00
33246.2463525759,2022-10-18 00:00:00,2022-10-25 00:00:00
33645.3052068616,2022-10-25 00:00:00,2022-11-01 00:00:00

0 comments on commit d34ca44

Please sign in to comment.