From 79464d3a78d0e885bf0c3770b4bd0a0245d8cd4b Mon Sep 17 00:00:00 2001 From: Jacob Woodbury <166659344+JacobWoodbury@users.noreply.github.com> Date: Wed, 26 Feb 2025 15:03:35 -0800 Subject: [PATCH 1/3] B19 working --- src/server/test/web/readingsBarMeterFlow.js | 75 ++++++++++++++++++- ...ri_15_mu_kW_gu_kW_st_-inf_et_inf_bd_28.csv | 3 + 2 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 src/server/test/web/readingsData/expected_bar_ri_15_mu_kW_gu_kW_st_-inf_et_inf_bd_28.csv diff --git a/src/server/test/web/readingsBarMeterFlow.js b/src/server/test/web/readingsBarMeterFlow.js index 626c1d48f..6d0d379f6 100644 --- a/src/server/test/web/readingsBarMeterFlow.js +++ b/src/server/test/web/readingsBarMeterFlow.js @@ -27,7 +27,8 @@ mocha.describe('readings API', () => { mocha.describe('for flow meters', () => { mocha.it('B15: 13 day bars for 15 minute reading intervals and flow units with +-inf start/end time & kW as kW', async () => { - const unitData = [ + console.log("test change") + const unitData = [ { // u4 name: 'kW', @@ -162,19 +163,89 @@ 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 // Add B19 here + mocha.it('B19: 28 day bars for 15 minute reading intervals and flow units with +-inf start/end time & kW as kW', 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_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, // 28-day bars + graphicUnitId: unitId + }); + // Check that the API reading is equal to what it is expected to equal + expectReadingToEqualExpected(res, expected); + }); + // Add B20 here // Add B21 here // Add B22 here - }); + }); }); }); diff --git a/src/server/test/web/readingsData/expected_bar_ri_15_mu_kW_gu_kW_st_-inf_et_inf_bd_28.csv b/src/server/test/web/readingsData/expected_bar_ri_15_mu_kW_gu_kW_st_-inf_et_inf_bd_28.csv new file mode 100644 index 000000000..c21c6dac4 --- /dev/null +++ b/src/server/test/web/readingsData/expected_bar_ri_15_mu_kW_gu_kW_st_-inf_et_inf_bd_28.csv @@ -0,0 +1,3 @@ +reading,start time,end time +33419.3090466881,2022-09-06 00:00:00,2022-10-04 00:00:00 +33374.0728310456,2022-10-04 00:00:00,2022-11-01 00:00:00 \ No newline at end of file From d280de6c438f97b124ab1994495e5bdb4b336c43 Mon Sep 17 00:00:00 2001 From: Jacob Woodbury <166659344+JacobWoodbury@users.noreply.github.com> Date: Mon, 3 Mar 2025 08:39:00 -0800 Subject: [PATCH 2/3] removing a test console.log --- 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 6d0d379f6..7ac8d24e8 100644 --- a/src/server/test/web/readingsBarMeterFlow.js +++ b/src/server/test/web/readingsBarMeterFlow.js @@ -27,7 +27,7 @@ mocha.describe('readings API', () => { mocha.describe('for flow meters', () => { mocha.it('B15: 13 day bars for 15 minute reading intervals and flow units with +-inf start/end time & kW as kW', async () => { - console.log("test change") + const unitData = [ { // u4 From 396f9ede0cb4f51559f5ccf1b4cf59f0fee85d0d Mon Sep 17 00:00:00 2001 From: Jacob Woodbury <166659344+JacobWoodbury@users.noreply.github.com> Date: Tue, 4 Mar 2025 09:52:14 -0800 Subject: [PATCH 3/3] added test B19 to BarMeterFlow.js --- 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 7ac8d24e8..458ecd064 100644 --- a/src/server/test/web/readingsBarMeterFlow.js +++ b/src/server/test/web/readingsBarMeterFlow.js @@ -27,7 +27,6 @@ mocha.describe('readings API', () => { mocha.describe('for flow meters', () => { mocha.it('B15: 13 day bars for 15 minute reading intervals and flow units with +-inf start/end time & kW as kW', async () => { - const unitData = [ { // u4 @@ -169,7 +168,6 @@ mocha.describe('readings API', () => { // Add B18 here - // Add B19 here mocha.it('B19: 28 day bars for 15 minute reading intervals and flow units with +-inf start/end time & kW as kW', async () => { const unitData = [ { @@ -239,7 +237,6 @@ mocha.describe('readings API', () => { expectReadingToEqualExpected(res, expected); }); - // Add B20 here // Add B21 here