From 1529c8c64cdf1a508054a73ba99f64dbef2de8e1 Mon Sep 17 00:00:00 2001 From: Helen Ton <147019752+heleeon@users.noreply.github.com> Date: Sat, 22 Feb 2025 03:07:51 +0000 Subject: [PATCH] Final test C10 Co-authored by: Caden Carpenter Co-authored by: Anthony Theng --- .../test/web/readingsCompareMeterQuantity.js | 94 ++++++++++++++++++- 1 file changed, 93 insertions(+), 1 deletion(-) diff --git a/src/server/test/web/readingsCompareMeterQuantity.js b/src/server/test/web/readingsCompareMeterQuantity.js index 720324b5b..f9a4226d9 100644 --- a/src/server/test/web/readingsCompareMeterQuantity.js +++ b/src/server/test/web/readingsCompareMeterQuantity.js @@ -156,7 +156,99 @@ mocha.describe('readings API', () => { // Add C9 here - // Add C10 here + mocha.it('C10: 1 day shift end 2022-10-31 17:00:00 for 15 minute reading intervals and quantity units & kWh as BTU', async () => { + // Use predefined unit and conversion data + const unitData = unitDatakWh.concat([ + //adding u1, u2, u3, u16 + { //u1 + name: 'kWh', + identifier: '', + unitRepresent: Unit.unitRepresentType.QUANTITY, + secInRate: 3600, + typeOfUnit: Unit.unitType.UNIT, + suffix: '', + displayable: Unit.displayableType.ALL, + preferredDisplay: false, + note: 'OED created standard unit' + }, + { //u2 + name: 'Electric_Utility', + identifier: '', + unitRepresent: Unit.unitRepresentType.QUANTITY, + secInRate: 3600, + typeOfUnit: Unit.unitType.METER, + suffix: '', + displayable: Unit.displayableType.NONE, + preferredDisplay: false, + note: 'special unit' + }, + { //u3 + name: 'MJ', + identifier: 'megaJoules', + unitRepresent: Unit.unitRepresentType.QUANTITY, + secInRate: 3600, + typeOfUnit: Unit.unitType.UNIT, + suffix: '', + displayable: Unit.displayableType.ALL, + preferredDisplay: false, + note: 'MJ' + }, + { // u16 + name: 'BTU', + identifier: '', + unitRepresent: Unit.unitRepresentType.QUANTITY, + secInRate: 3600, + typeOfUnit: Unit.unitType.UNIT, + suffix: '', + displayable: Unit.displayableType.ALL, + preferredDisplay: true, + note: 'OED created standard unit' + } + ]); + const conversionData = conversionDatakWh.concat([ + // adding c1, c2, c3 + { // c1 + sourceName: 'Electric_Utility', + destinationName: 'kWh', + bidirectional: false, + slope: 1, + intercept: 0, + note: 'Electric_Utility → kWh' + }, + { // c2 + sourceName: 'kWh', + destinationName: 'MJ', + bidirectional: true, + slope: 3.6, + intercept: 0, + note: 'MJ → BTU' + }, + { //c3 + sourceName: 'MJ', + destinationName: 'BTU', + bidirectional: true, + slope: 947.8, + intercept: 0, + note: 'MJ → BTU' + } + ]); + + // load data into database + await prepareTest(unitData, conversionData, meterDatakWh); + + // Get the unit ID since the DB could use any value + const unitId = await getUnitId('BTU'); + const expected = [10645752.224022, 11490184.2415072]; + // for compare, need the unitID, currentStart, currentEnd, shift + const res = await chai.request(app).get(`/api/compareReadings/meters/${METER_ID}`) + .query({ + curr_start: '2022-10-31 00:00:00', + curr_end: '2022-10-31 17:00:00', + shift: 'P1D', + graphicUnitId: unitId + }); + expectCompareToEqualExpected(res, expected); + }); // Add C11 here