From a49a084824110930187dd7f06edeb371fd4b1e50 Mon Sep 17 00:00:00 2001 From: Phinhas Asmelash Date: Fri, 14 Feb 2025 01:00:26 -0800 Subject: [PATCH 01/16] new test feature branch --- src/server/test/web/readingsCompareMeterQuantity.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/server/test/web/readingsCompareMeterQuantity.js b/src/server/test/web/readingsCompareMeterQuantity.js index a602f9993..b3872ae5b 100644 --- a/src/server/test/web/readingsCompareMeterQuantity.js +++ b/src/server/test/web/readingsCompareMeterQuantity.js @@ -155,6 +155,7 @@ mocha.describe('readings API', () => { }); // Add C9 here + // started working on this // Add C10 here From 24daa9aa2e7e7995879ab730dfb6c0b4dc39a232 Mon Sep 17 00:00:00 2001 From: Phinhas Asmelash Date: Sat, 15 Feb 2025 16:57:45 -0800 Subject: [PATCH 02/16] C9 test draft --- .../test/web/readingsCompareMeterQuantity.js | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/src/server/test/web/readingsCompareMeterQuantity.js b/src/server/test/web/readingsCompareMeterQuantity.js index b3872ae5b..fb04fccef 100644 --- a/src/server/test/web/readingsCompareMeterQuantity.js +++ b/src/server/test/web/readingsCompareMeterQuantity.js @@ -156,6 +156,77 @@ mocha.describe('readings API', () => { // Add C9 here // started working on this + mocha.it('C9: 1 day shift end 2022-10-31 17:00:00 for 15 minute reading intervals and Fahrenheit as Widghet', async () => { + // Use predefined unit and conversion data + const unitData = [ + // adding units u7, u8, u9 + { + // u7 + name: 'Degrees', + identifier: '', + unitRepresent: Unit.unitRepresentType.RAW, + secInRate: 3600, + typeOfUnit: Unit.unitType.METER, + suffix: '', + displayable: Unit.displayableType.NONE, + preferredDisplay: false, + note: 'special unit' + }, + { + // u8 + name: 'F', + identifier: '', + unitRepresent: Unit.unitRepresentType.RAW, + secInRate: 3600, + typeOfUnit: Unit.unitType.UNIT, + suffix: '', + displayable: Unit.displayableType.ALL, + preferredDisplay: false, + note: 'OED created standard unit' + }, + { + // u9 + name: 'Widget', + identifier: '', + unitRepresent: Unit.unitRepresentType.RAW, + secInRate: 3600, + typeOfUnit: Unit.unitType.UNIT, + suffix: '', + displayable: Unit.displayableType.ALL, + preferredDisplay: false, + note: 'fake unit' + } + ]; + const conversionData = conversionDatakWh.concat([ + { + sourceName: 'F', + destinationName: 'Widget', + bidirectional: true, + slope: 5, + intercept: 3, + note: 'Fahrenheit → Widget' + } + ]); + // Prepare test with the standard data + console.log('C9'); + await prepareTest(unitData, conversionData, meterDatakWh); + process.stdout.write(JSON.stringify(unitData)); + process.stdout.write(JSON.stringify(conversionData)); + process.stdout.write(JSON.stringify(meterDatakWh)); + // Get the unit ID since the DB could use any value. + const unitId = await getUnitId('Widget'); + const expected = [15972.58, 17319.62]; // how do we calculate this? readings_ri_15_days_75.csv maybe??? + // 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 C10 here From 5aaa3d03361ea511efef121fe6dc58dfdc5a2995 Mon Sep 17 00:00:00 2001 From: Abas Date: Thu, 20 Feb 2025 19:09:19 -0800 Subject: [PATCH 03/16] Implemented test case C11 Co-authored-by: Mon Raphael Fernandez Co-authored-by: Hyun Oh Kwon Co-authored-by: Ezequiel Reyes --- .../test/web/readingsCompareMeterQuantity.js | 110 +++++++++++++++++- 1 file changed, 108 insertions(+), 2 deletions(-) diff --git a/src/server/test/web/readingsCompareMeterQuantity.js b/src/server/test/web/readingsCompareMeterQuantity.js index a602f9993..b37099682 100644 --- a/src/server/test/web/readingsCompareMeterQuantity.js +++ b/src/server/test/web/readingsCompareMeterQuantity.js @@ -158,8 +158,114 @@ mocha.describe('readings API', () => { // Add C10 here - // Add C11 here - + mocha.it('C11: 1 day shift end 2022-10-31 17:00:00 for 15 minute reading intervals and quantity units & kWh as BTU reverse conversion', async () => { + const unitData = [ + // adding units u1, u2, u3, u16 + { + //u1 + name: 'kWh', + identifier: '', + unitRepresent: Unit.unitRepresentType.QUANTITY, + secInRate: 3600, + typeOfUnit: Unit.unitType.UNIT, + suffix: '', + displayable: Unit.displayableType.ALL, + preferredDisplay: true, + 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 = [ + // adding conversions 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: 'kWh → MJ' + }, + { + // c3 + sourceName: 'MJ', + destinationName: 'BTU', + bidirectional: true, + slope: 947.8, + intercept: 0, + note: 'MJ → BTU' + }, + + ]; + // redefining the meterData as the unit is different + const meterData = [ + { + name: 'Electric Utility BTU', + unit: 'Electric_Utility', + 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 data into database + await prepareTest(unitData, conversionData, meterData); + // 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 C12 here // Add C13 here From 4fd3ca47708e0501a0966b8870df28d22aa54c70 Mon Sep 17 00:00:00 2001 From: Mon Raphael Fernandez Date: Fri, 21 Feb 2025 17:24:31 -0800 Subject: [PATCH 04/16] Updated the requested change for Test Case C11 --- .../test/web/readingsCompareMeterQuantity.js | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/server/test/web/readingsCompareMeterQuantity.js b/src/server/test/web/readingsCompareMeterQuantity.js index 09d88fd67..1266a3098 100644 --- a/src/server/test/web/readingsCompareMeterQuantity.js +++ b/src/server/test/web/readingsCompareMeterQuantity.js @@ -159,7 +159,7 @@ mocha.describe('readings API', () => { // Add C10 here mocha.it('C11: 1 day shift end 2022-10-31 17:00:00 for 15 minute reading intervals and quantity units & kWh as BTU reverse conversion', async () => { - const unitData = [ + const unitData = unitDatakWh.concat([ // adding units u1, u2, u3, u16 { //u1 @@ -205,9 +205,9 @@ mocha.describe('readings API', () => { preferredDisplay: true, note: 'OED created standard unit' }, - ]; - const conversionData = [ - // adding conversions c1, c2, c3 + ]); + const conversionData = conversionDatakWh.concat([ + // adding conversions c1, c6, c3 { // c1 sourceName: 'Electric_Utility', @@ -218,13 +218,13 @@ mocha.describe('readings API', () => { note: 'Electric_Utility → kWh' }, { - // c2 - sourceName: 'kWh', - destinationName: 'MJ', - bidirectional: true, - slope: 3.6, - intercept: 0, - note: 'kWh → MJ' + // c6 + sourceName: 'MJ', + destinationName: 'kWh', + bidirectional: true, + slope: 1 / 3.6, + intercept: 0, + note: 'MJ → KWh' }, { // c3 @@ -236,7 +236,7 @@ mocha.describe('readings API', () => { note: 'MJ → BTU' }, - ]; + ]); // redefining the meterData as the unit is different const meterData = [ { 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 05/16] 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 From c6c360b969c819d7a254fd8a0795d17d7da71ab7 Mon Sep 17 00:00:00 2001 From: Phinhas Asmelash Date: Fri, 21 Feb 2025 20:09:42 -0800 Subject: [PATCH 06/16] =?UTF-8?q?=F0=9F=9A=80=20solved=20C9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sophia Alexander Co-authored-by: Aaron Lui --- .../test/web/readingsCompareMeterQuantity.js | 62 +++++-------------- 1 file changed, 16 insertions(+), 46 deletions(-) diff --git a/src/server/test/web/readingsCompareMeterQuantity.js b/src/server/test/web/readingsCompareMeterQuantity.js index fb04fccef..566593554 100644 --- a/src/server/test/web/readingsCompareMeterQuantity.js +++ b/src/server/test/web/readingsCompareMeterQuantity.js @@ -156,66 +156,36 @@ mocha.describe('readings API', () => { // Add C9 here // started working on this - mocha.it('C9: 1 day shift end 2022-10-31 17:00:00 for 15 minute reading intervals and Fahrenheit as Widghet', async () => { - // Use predefined unit and conversion data - const unitData = [ - // adding units u7, u8, u9 - { - // u7 - name: 'Degrees', - identifier: '', - unitRepresent: Unit.unitRepresentType.RAW, - secInRate: 3600, - typeOfUnit: Unit.unitType.METER, - suffix: '', - displayable: Unit.displayableType.NONE, - preferredDisplay: false, - note: 'special unit' - }, - { - // u8 - name: 'F', - identifier: '', - unitRepresent: Unit.unitRepresentType.RAW, - secInRate: 3600, - typeOfUnit: Unit.unitType.UNIT, - suffix: '', - displayable: Unit.displayableType.ALL, - preferredDisplay: false, - note: 'OED created standard unit' - }, + mocha.it('C9: 1 day shift end 2022-10-31 17:00:00 for 15 minute reading intervals and quantity units & kWh as MJ reverse conversion', async () => { + // add u3 to existing unitData + const unitData = unitDatakWh.concat([ { - // u9 - name: 'Widget', - identifier: '', - unitRepresent: Unit.unitRepresentType.RAW, + name: 'MJ', + identifier: 'megaJoules', + unitRepresent: Unit.unitRepresentType.QUANTITY, secInRate: 3600, typeOfUnit: Unit.unitType.UNIT, suffix: '', displayable: Unit.displayableType.ALL, preferredDisplay: false, - note: 'fake unit' + note: 'MJ' } - ]; + ]); + // add c2 to existing conversionData const conversionData = conversionDatakWh.concat([ { - sourceName: 'F', - destinationName: 'Widget', + sourceName: 'kWh', + destinationName: 'MJ', bidirectional: true, - slope: 5, - intercept: 3, - note: 'Fahrenheit → Widget' + slope: 3.6, + intercept: 0, + note: 'kWh → MJ' } ]); - // Prepare test with the standard data - console.log('C9'); await prepareTest(unitData, conversionData, meterDatakWh); - process.stdout.write(JSON.stringify(unitData)); - process.stdout.write(JSON.stringify(conversionData)); - process.stdout.write(JSON.stringify(meterDatakWh)); // Get the unit ID since the DB could use any value. - const unitId = await getUnitId('Widget'); - const expected = [15972.58, 17319.62]; // how do we calculate this? readings_ri_15_days_75.csv maybe??? + const unitId = await getUnitId('MJ'); + const expected = [11232.0660730344, 12123.0051081528]; // for compare, need the unitID, currentStart, currentEnd, shift const res = await chai.request(app).get(`/api/compareReadings/meters/${METER_ID}`) .query({ From 11306e7693ae58aed56f2f7aa35de147c66c484a Mon Sep 17 00:00:00 2001 From: Phinhas Asmelash Date: Fri, 21 Feb 2025 20:27:40 -0800 Subject: [PATCH 07/16] =?UTF-8?q?=F0=9F=9A=80=20added=20C9=20test=20case?= =?UTF-8?q?=20Co-authored-by:=20Sophia=20Alexander=20=20Co-authored-by:=20Aaron=20Lui=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/test/web/readingsCompareMeterQuantity.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/server/test/web/readingsCompareMeterQuantity.js b/src/server/test/web/readingsCompareMeterQuantity.js index eb04dbd33..549e4f5d3 100644 --- a/src/server/test/web/readingsCompareMeterQuantity.js +++ b/src/server/test/web/readingsCompareMeterQuantity.js @@ -154,8 +154,6 @@ mocha.describe('readings API', () => { expectCompareToEqualExpected(res, expected); }); - // Add C9 here - // started working on this mocha.it('C9: 1 day shift end 2022-10-31 17:00:00 for 15 minute reading intervals and quantity units & kWh as MJ reverse conversion', async () => { // add u3 to existing unitData const unitData = unitDatakWh.concat([ From 8494d2bbbb3d5390bf0fb0d872b3b91f56e68a99 Mon Sep 17 00:00:00 2001 From: Abas Date: Fri, 21 Feb 2025 22:03:53 -0800 Subject: [PATCH 08/16] Removed u1, u2, and c1 because they were already in unitData and conversionData --- .../test/web/readingsCompareMeterQuantity.js | 37 +------------------ 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/src/server/test/web/readingsCompareMeterQuantity.js b/src/server/test/web/readingsCompareMeterQuantity.js index 1266a3098..6d573331b 100644 --- a/src/server/test/web/readingsCompareMeterQuantity.js +++ b/src/server/test/web/readingsCompareMeterQuantity.js @@ -160,31 +160,7 @@ mocha.describe('readings API', () => { mocha.it('C11: 1 day shift end 2022-10-31 17:00:00 for 15 minute reading intervals and quantity units & kWh as BTU reverse conversion', async () => { const unitData = unitDatakWh.concat([ - // adding units u1, u2, u3, u16 - { - //u1 - name: 'kWh', - identifier: '', - unitRepresent: Unit.unitRepresentType.QUANTITY, - secInRate: 3600, - typeOfUnit: Unit.unitType.UNIT, - suffix: '', - displayable: Unit.displayableType.ALL, - preferredDisplay: true, - 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' - }, + // adding units u3, u16 { // u3 name: 'MJ', @@ -207,16 +183,7 @@ mocha.describe('readings API', () => { }, ]); const conversionData = conversionDatakWh.concat([ - // adding conversions c1, c6, c3 - { - // c1 - sourceName: 'Electric_Utility', - destinationName: 'kWh', - bidirectional: false, - slope: 1, - intercept: 0, - note: 'Electric_Utility → kWh' - }, + // adding conversions c6, c3 { // c6 sourceName: 'MJ', From 829727228901aba5a5d195a36299d9908859eae4 Mon Sep 17 00:00:00 2001 From: Steven Huss-Lederman Date: Sun, 23 Feb 2025 08:02:31 -0600 Subject: [PATCH 09/16] make conversion reversed I accidentally forgot to use the reversed conversion in the design doc. This fixes the test case to do that. This is not the doing of the developers. --- src/server/test/web/readingsCompareMeterQuantity.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/server/test/web/readingsCompareMeterQuantity.js b/src/server/test/web/readingsCompareMeterQuantity.js index b63910fc9..be694634b 100644 --- a/src/server/test/web/readingsCompareMeterQuantity.js +++ b/src/server/test/web/readingsCompareMeterQuantity.js @@ -172,12 +172,12 @@ mocha.describe('readings API', () => { // add c2 to existing conversionData const conversionData = conversionDatakWh.concat([ { - sourceName: 'kWh', - destinationName: 'MJ', + sourceName: 'MJ', + destinationName: 'kWh', bidirectional: true, - slope: 3.6, + slope: 1 / 3.6, intercept: 0, - note: 'kWh → MJ' + note: 'MJ → kWh' } ]); await prepareTest(unitData, conversionData, meterDatakWh); From fb0dac78275c54ac08102fab297799711cc2cb5a Mon Sep 17 00:00:00 2001 From: ahmetsahiner <119397720+albertfast@users.noreply.github.com> Date: Mon, 24 Feb 2025 16:58:05 +0000 Subject: [PATCH 10/16] Updated test cases for B17 Co-authored-by: Aizen Baidya Co-authored-by: Khang Nguyen --- src/server/test/web/readingsBarMeterFlow.js | 74 +++++++++++++++++++-- 1 file changed, 70 insertions(+), 4 deletions(-) diff --git a/src/server/test/web/readingsBarMeterFlow.js b/src/server/test/web/readingsBarMeterFlow.js index 626c1d48f..8584c83d0 100644 --- a/src/server/test/web/readingsBarMeterFlow.js +++ b/src/server/test/web/readingsBarMeterFlow.js @@ -162,9 +162,76 @@ mocha.describe('readings API', () => { }); // Check that the API reading is equal to what it is expected to equal expectReadingToEqualExpected(res, expected); + }); - // Add B17 here - + mocha.it('B17: should have daily points for 15 minute reading intervals and flow units with +-inf start/end time & kW as kW for Electric meter', async () => { + const unitData = [ + { + // u4 + name: 'kW', + identifier: '', + unitRepresent: Unit.unitRepresentType.FLOW, + secInRate: 3600, + typeOfUnit: Unit.unitType.UNIT, + suffix: '', + displayable: Unit.displayableType.ALL, + preferredDisplay: true, + note: 'kilowatts' + }, + { + // u5 + name: 'Electric', + identifier: '', + unitRepresent: Unit.unitRepresentType.FLOW, + secInRate: 3600, + typeOfUnit: Unit.unitType.METER, + suffix: '', + displayable: Unit.displayableType.NONE, + preferredDisplay: false, + note: 'special unit' + } + ]; + const conversionData = [ + { + // c4 + sourceName: 'Electric', + destinationName: 'kW', + bidirectional: false, + slope: 1, + intercept: 0, + note: 'Electric → kW' + } + ]; + const meterData = [ + { + name: 'Electric kW', + unit: 'Electric', + defaultGraphicUnit: 'kW', + 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(unitData, conversionData, meterData); + // Get the unit ID since the DB could use any value. + const unitId = await getUnitId('kW'); + // Load the expected response data from the corresponding csv file + const expected = await parseExpectedCsv('src/server/test/web/readingsData/expected_bar_ri_15_mu_kW_gu_kW_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); + }); // Add B18 here // Add B19 here @@ -175,7 +242,6 @@ mocha.describe('readings API', () => { // Add B22 here }); - }); }); }); -}); +}); \ No newline at end of file From 930cefefa58bff3a424412a064f6d5dd9e03b669 Mon Sep 17 00:00:00 2001 From: ahmetsahiner <119397720+albertfast@users.noreply.github.com> Date: Mon, 24 Feb 2025 09:51:34 -0800 Subject: [PATCH 11/16] Added CSV file I added the missing CSV file from DesignDocs/testing/readingsData/expected_bar_ri_15_mu_kW_gu_kW_st_-inf_et_inf_bd_1.csv --- ..._ri_15_mu_kW_gu_kW_st_-inf_et_inf_bd_1.csv | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/server/test/web/readingsData/expected_bar_ri_15_mu_kW_gu_kW_st_-inf_et_inf_bd_1.csv diff --git a/src/server/test/web/readingsData/expected_bar_ri_15_mu_kW_gu_kW_st_-inf_et_inf_bd_1.csv b/src/server/test/web/readingsData/expected_bar_ri_15_mu_kW_gu_kW_st_-inf_et_inf_bd_1.csv new file mode 100644 index 000000000..cbf8834e3 --- /dev/null +++ b/src/server/test/web/readingsData/expected_bar_ri_15_mu_kW_gu_kW_st_-inf_et_inf_bd_1.csv @@ -0,0 +1,76 @@ +reading,start time,end time +1244.4732821245,2022-08-18 00:00:00,2022-08-19 00:00:00 +988.315804920483,2022-08-19 00:00:00,2022-08-20 00:00:00 +1229.16913704567,2022-08-20 00:00:00,2022-08-21 00:00:00 +1214.90679769041,2022-08-21 00:00:00,2022-08-22 00:00:00 +1141.42617179595,2022-08-22 00:00:00,2022-08-23 00:00:00 +1173.22097628136,2022-08-23 00:00:00,2022-08-24 00:00:00 +1172.76622813581,2022-08-24 00:00:00,2022-08-25 00:00:00 +1217.29080157992,2022-08-25 00:00:00,2022-08-26 00:00:00 +1078.14650822547,2022-08-26 00:00:00,2022-08-27 00:00:00 +1195.102845216,2022-08-27 00:00:00,2022-08-28 00:00:00 +1156.49973049494,2022-08-28 00:00:00,2022-08-29 00:00:00 +1112.47501131559,2022-08-29 00:00:00,2022-08-30 00:00:00 +1192.86644903414,2022-08-30 00:00:00,2022-08-31 00:00:00 +1161.02765232201,2022-08-31 00:00:00,2022-09-01 00:00:00 +1152.18197026441,2022-09-01 00:00:00,2022-09-02 00:00:00 +1272.45260726068,2022-09-02 00:00:00,2022-09-03 00:00:00 +1217.82966175226,2022-09-03 00:00:00,2022-09-04 00:00:00 +1176.84658742283,2022-09-04 00:00:00,2022-09-05 00:00:00 +1125.57284174782,2022-09-05 00:00:00,2022-09-06 00:00:00 +1194.22329876519,2022-09-06 00:00:00,2022-09-07 00:00:00 +1171.71190809283,2022-09-07 00:00:00,2022-09-08 00:00:00 +1130.54158593037,2022-09-08 00:00:00,2022-09-09 00:00:00 +1236.92056317258,2022-09-09 00:00:00,2022-09-10 00:00:00 +1142.10449794792,2022-09-10 00:00:00,2022-09-11 00:00:00 +1340.16170552738,2022-09-11 00:00:00,2022-09-12 00:00:00 +1182.05404123472,2022-09-12 00:00:00,2022-09-13 00:00:00 +1248.84451712363,2022-09-13 00:00:00,2022-09-14 00:00:00 +1137.33538285512,2022-09-14 00:00:00,2022-09-15 00:00:00 +1221.31552272137,2022-09-15 00:00:00,2022-09-16 00:00:00 +1143.33626142129,2022-09-16 00:00:00,2022-09-17 00:00:00 +1225.3967032627,2022-09-17 00:00:00,2022-09-18 00:00:00 +1286.93091007234,2022-09-18 00:00:00,2022-09-19 00:00:00 +1110.56503545471,2022-09-19 00:00:00,2022-09-20 00:00:00 +1340.33530846461,2022-09-20 00:00:00,2022-09-21 00:00:00 +1123.21972183704,2022-09-21 00:00:00,2022-09-22 00:00:00 +1249.65113803395,2022-09-22 00:00:00,2022-09-23 00:00:00 +1131.23559326555,2022-09-23 00:00:00,2022-09-24 00:00:00 +1142.76238111977,2022-09-24 00:00:00,2022-09-25 00:00:00 +1210.92514071449,2022-09-25 00:00:00,2022-09-26 00:00:00 +1150.76698467275,2022-09-26 00:00:00,2022-09-27 00:00:00 +1152.78225650689,2022-09-27 00:00:00,2022-09-28 00:00:00 +1215.20127016486,2022-09-28 00:00:00,2022-09-29 00:00:00 +1273.79854318597,2022-09-29 00:00:00,2022-09-30 00:00:00 +1198.53270778934,2022-09-30 00:00:00,2022-10-01 00:00:00 +1165.80837300627,2022-10-01 00:00:00,2022-10-02 00:00:00 +1180.22585254585,2022-10-02 00:00:00,2022-10-03 00:00:00 +1112.62184179863,2022-10-03 00:00:00,2022-10-04 00:00:00 +1217.71687161273,2022-10-04 00:00:00,2022-10-05 00:00:00 +1199.38826568772,2022-10-05 00:00:00,2022-10-06 00:00:00 +1160.1762157385,2022-10-06 00:00:00,2022-10-07 00:00:00 +1269.25906753997,2022-10-07 00:00:00,2022-10-08 00:00:00 +1167.40579266569,2022-10-08 00:00:00,2022-10-09 00:00:00 +1058.18319043406,2022-10-09 00:00:00,2022-10-10 00:00:00 +1211.93520880573,2022-10-10 00:00:00,2022-10-11 00:00:00 +1152.7344011911,2022-10-11 00:00:00,2022-10-12 00:00:00 +1259.0249731428,2022-10-12 00:00:00,2022-10-13 00:00:00 +1192.12826970549,2022-10-13 00:00:00,2022-10-14 00:00:00 +1208.21671287911,2022-10-14 00:00:00,2022-10-15 00:00:00 +1155.22102759493,2022-10-15 00:00:00,2022-10-16 00:00:00 +1178.49984441914,2022-10-16 00:00:00,2022-10-17 00:00:00 +1221.29509976931,2022-10-17 00:00:00,2022-10-18 00:00:00 +1162.54298706786,2022-10-18 00:00:00,2022-10-19 00:00:00 +1128.36869126957,2022-10-19 00:00:00,2022-10-20 00:00:00 +1162.34721422175,2022-10-20 00:00:00,2022-10-21 00:00:00 +1243.61079923689,2022-10-21 00:00:00,2022-10-22 00:00:00 +1187.32006552077,2022-10-22 00:00:00,2022-10-23 00:00:00 +1203.7441556701,2022-10-23 00:00:00,2022-10-24 00:00:00 +1223.62767515703,2022-10-24 00:00:00,2022-10-25 00:00:00 +1347.85241257491,2022-10-25 00:00:00,2022-10-26 00:00:00 +1135.57752734976,2022-10-26 00:00:00,2022-10-27 00:00:00 +1091.91787954098,2022-10-27 00:00:00,2022-10-28 00:00:00 +1203.63545481652,2022-10-28 00:00:00,2022-10-29 00:00:00 +1349.13987250313,2022-10-29 00:00:00,2022-10-30 00:00:00 +1210.55315436926,2022-10-30 00:00:00,2022-10-31 00:00:00 +1072.65000056083,2022-10-31 00:00:00,2022-11-01 00:00:00 From 77e2b6b2fae1b9ca16fa30406ccacfc7aa45c5e5 Mon Sep 17 00:00:00 2001 From: ahmetsahiner <119397720+albertfast@users.noreply.github.com> Date: Thu, 27 Feb 2025 17:48:20 +0000 Subject: [PATCH 12/16] Updated test cases for B17 with true Description Co-authored-by: Aizen Baidya Co-authored-by: Khang Nguyen --- src/server/test/web/readingsBarMeterFlow.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/test/web/readingsBarMeterFlow.js b/src/server/test/web/readingsBarMeterFlow.js index 8584c83d0..b78ef2a97 100644 --- a/src/server/test/web/readingsBarMeterFlow.js +++ b/src/server/test/web/readingsBarMeterFlow.js @@ -164,7 +164,7 @@ mocha.describe('readings API', () => { expectReadingToEqualExpected(res, expected); }); - mocha.it('B17: should have daily points for 15 minute reading intervals and flow units with +-inf start/end time & kW as kW for Electric meter', async () => { + mocha.it('B17: 1 day bars for 15 minute reading intervals and flow units with +-inf start/end time & kW as kW', async () => { const unitData = [ { // u4 From 9e53d677a7d70eec60298638c962ea58c312b713 Mon Sep 17 00:00:00 2001 From: butenkite Date: Thu, 27 Feb 2025 11:30:44 -0800 Subject: [PATCH 13/16] initial implement of test B22 --- src/server/test/web/readingsBarMeterFlow.js | 73 ++++++++++++++++++- ...%07#25#35_et_2022-10-28%13#18#28_bd_13.csv | 6 ++ 2 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 src/server/test/web/readingsData/expected_bar_ri_15_mu_kW_gu_kW_st_2022-08-20%07#25#35_et_2022-10-28%13#18#28_bd_13.csv diff --git a/src/server/test/web/readingsBarMeterFlow.js b/src/server/test/web/readingsBarMeterFlow.js index 626c1d48f..94fce9f59 100644 --- a/src/server/test/web/readingsBarMeterFlow.js +++ b/src/server/test/web/readingsBarMeterFlow.js @@ -163,6 +163,7 @@ mocha.describe('readings API', () => { // Check that the API reading is equal to what it is expected to equal expectReadingToEqualExpected(res, expected); + }); // Add B17 here // Add B18 here @@ -174,7 +175,77 @@ mocha.describe('readings API', () => { // Add B21 here // Add B22 here - }); + + + mocha.it('B22:13 day bars for 15 minute reading intervals and quantity units with reduced, partial days & kWh as kWh', async () => { + const unitData = [ + { + // u4 + name: 'kW', + identifier: '', + unitRepresent: Unit.unitRepresentType.FLOW, + secInRate: 3600, + typeOfUnit: Unit.unitType.UNIT, + suffix: '', + displayable: Unit.displayableType.ALL, + preferredDisplay: true, + note: 'kilowatts' + }, + { + // u5 + name: 'Electric', + identifier: '', + unitRepresent: Unit.unitRepresentType.FLOW, + secInRate: 3600, + typeOfUnit: Unit.unitType.METER, + suffix: '', + displayable: Unit.displayableType.NONE, + preferredDisplay: false, + note: 'special unit' + } + ]; + const conversionData = [ + { + // c4 + sourceName: 'Electric', + destinationName: 'kW', + bidirectional: false, + slope: 1, + intercept: 0, + note: 'Electric → kW' + } + ]; + const meterData = [ + { + name: 'Electric kW', + unit: 'Electric', + defaultGraphicUnit: 'kW', + 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(unitData, conversionData, meterData); + // Get the unit ID since the DB could use any value. + const unitId = await getUnitId('kW'); + // Load the expected response data from the corresponding csv file + const expected = await parseExpectedCsv('src/server/test/web/readingsData/expected_bar_ri_15_mu_kW_gu_kW_st_2022-08-20%07#25#35_et_2022-10-28%13#18#28_bd_13.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: 13, + graphicUnitId: unitId + }); + // Check that the API reading is equal to what it is expected to equal + expectReadingToEqualExpected(res, expected); + }); + }); }); }); diff --git a/src/server/test/web/readingsData/expected_bar_ri_15_mu_kW_gu_kW_st_2022-08-20%07#25#35_et_2022-10-28%13#18#28_bd_13.csv b/src/server/test/web/readingsData/expected_bar_ri_15_mu_kW_gu_kW_st_2022-08-20%07#25#35_et_2022-10-28%13#18#28_bd_13.csv new file mode 100644 index 000000000..9659118af --- /dev/null +++ b/src/server/test/web/readingsData/expected_bar_ri_15_mu_kW_gu_kW_st_2022-08-20%07#25#35_et_2022-10-28%13#18#28_bd_13.csv @@ -0,0 +1,6 @@ +reading,start time,end time +15231.0588947719,2022-08-24 00:00:00,2022-09-06 00:00:00 +15660.8768981274,2022-09-06 00:00:00,2022-09-19 00:00:00 +15465.5844542162,2022-09-19 00:00:00,2022-10-02 00:00:00 +15389.0166637474,2022-10-02 00:00:00,2022-10-15 00:00:00 +15441.925379393,2022-10-15 00:00:00,2022-10-28 00:00:00 From c112e0577add966150db41a62505bd72e6984b40 Mon Sep 17 00:00:00 2001 From: butenkite Date: Thu, 27 Feb 2025 12:30:55 -0800 Subject: [PATCH 14/16] Test B22 passing. --- src/server/test/web/readingsBarMeterFlow.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/server/test/web/readingsBarMeterFlow.js b/src/server/test/web/readingsBarMeterFlow.js index 94fce9f59..f9dd6857b 100644 --- a/src/server/test/web/readingsBarMeterFlow.js +++ b/src/server/test/web/readingsBarMeterFlow.js @@ -11,7 +11,7 @@ const { chai, mocha, app } = require('../common'); const Unit = require('../../models/Unit'); const { prepareTest, parseExpectedCsv, - //createTimeString, + createTimeString, expectReadingToEqualExpected, getUnitId, ETERNITY, @@ -177,7 +177,7 @@ mocha.describe('readings API', () => { // Add B22 here - mocha.it('B22:13 day bars for 15 minute reading intervals and quantity units with reduced, partial days & kWh as kWh', async () => { + mocha.it('B22: 13 day bars for 15 minute reading intervals and quantity units with reduced, partial days & kWh as kWh', async () => { const unitData = [ { // u4 @@ -238,10 +238,11 @@ mocha.describe('readings API', () => { // 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(), + timeInterval: createTimeString('2022-08-20', '07:25:35', '2022-10-28', '13:18:28'), barWidthDays: 13, graphicUnitId: unitId }); + // Check that the API reading is equal to what it is expected to equal expectReadingToEqualExpected(res, expected); }); From 4f8bb98cf892277603617a3d2cd95158e2603ae1 Mon Sep 17 00:00:00 2001 From: Butenkite <174657090+Butenkite@users.noreply.github.com> Date: Fri, 28 Feb 2025 12:19:07 -0800 Subject: [PATCH 15/16] Fixed Styling for test B22 --- src/server/test/web/readingsBarMeterFlow.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/server/test/web/readingsBarMeterFlow.js b/src/server/test/web/readingsBarMeterFlow.js index f9dd6857b..79d9e9b26 100644 --- a/src/server/test/web/readingsBarMeterFlow.js +++ b/src/server/test/web/readingsBarMeterFlow.js @@ -173,9 +173,6 @@ mocha.describe('readings API', () => { // Add B20 here // Add B21 here - - // Add B22 here - mocha.it('B22: 13 day bars for 15 minute reading intervals and quantity units with reduced, partial days & kWh as kWh', async () => { const unitData = [ From f6b0c62dc0b98c20a054018b7a342d76cf980433 Mon Sep 17 00:00:00 2001 From: Helen Ton <147019752+heleeon@users.noreply.github.com> Date: Sat, 1 Mar 2025 15:54:33 -0800 Subject: [PATCH 16/16] Update readingsCompareMeterQuantity.js to resolve comments --- .../test/web/readingsCompareMeterQuantity.js | 46 ++++--------------- 1 file changed, 10 insertions(+), 36 deletions(-) diff --git a/src/server/test/web/readingsCompareMeterQuantity.js b/src/server/test/web/readingsCompareMeterQuantity.js index f9a4226d9..71eeb59c0 100644 --- a/src/server/test/web/readingsCompareMeterQuantity.js +++ b/src/server/test/web/readingsCompareMeterQuantity.js @@ -159,30 +159,9 @@ mocha.describe('readings API', () => { 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 + //adding u3, u16 + { + // u3 name: 'MJ', identifier: 'megaJoules', unitRepresent: Unit.unitRepresentType.QUANTITY, @@ -193,7 +172,8 @@ mocha.describe('readings API', () => { preferredDisplay: false, note: 'MJ' }, - { // u16 + { + // u16 name: 'BTU', identifier: '', unitRepresent: Unit.unitRepresentType.QUANTITY, @@ -206,16 +186,9 @@ mocha.describe('readings API', () => { } ]); 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 + // adding c2, c3 + { + // c2 sourceName: 'kWh', destinationName: 'MJ', bidirectional: true, @@ -223,7 +196,8 @@ mocha.describe('readings API', () => { intercept: 0, note: 'MJ → BTU' }, - { //c3 + { + // c3 sourceName: 'MJ', destinationName: 'BTU', bidirectional: true,