From 1e712e0aa3c71e80e86de67727a0db3b75a12fc2 Mon Sep 17 00:00:00 2001 From: Diana Date: Tue, 26 Nov 2024 13:32:04 -0800 Subject: [PATCH 1/8] Wrote C8 Test Case --- .../test/web/readingsCompareMeterQuantity.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/server/test/web/readingsCompareMeterQuantity.js b/src/server/test/web/readingsCompareMeterQuantity.js index e278afc55..ceced1188 100644 --- a/src/server/test/web/readingsCompareMeterQuantity.js +++ b/src/server/test/web/readingsCompareMeterQuantity.js @@ -74,7 +74,21 @@ mocha.describe('readings API', () => { // Add C6 here - // Add C8 here + mocha.it('C8: 1 day shift end 2022-10-31 17:00:00 for 15 minute reading intervals and quantity units & kWh as MJ', async() => { + await prepareTest(unitDatakWh, conversionDatakWh, meterDatakWh); + // Get the unit ID since the DB could use any value. + 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({ + curr_start: '2022-10-31 00:00:00', + curr_end: '2022-10-31 17:00:00', + shift: 'P1D', + graphicUnitId: unitId + }); + expectCompareToEqualExpected(res, expected); + }); // Add C9 here From c8ab76fbf100976a5a4916239d6cecf8ad609c99 Mon Sep 17 00:00:00 2001 From: Madeleine Chance Date: Tue, 26 Nov 2024 14:20:10 -0800 Subject: [PATCH 2/8] unit data types added --- .../test/web/readingsCompareMeterQuantity.js | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/server/test/web/readingsCompareMeterQuantity.js b/src/server/test/web/readingsCompareMeterQuantity.js index ceced1188..165277b6a 100644 --- a/src/server/test/web/readingsCompareMeterQuantity.js +++ b/src/server/test/web/readingsCompareMeterQuantity.js @@ -75,6 +75,46 @@ mocha.describe('readings API', () => { // Add C6 here mocha.it('C8: 1 day shift end 2022-10-31 17:00:00 for 15 minute reading intervals and quantity units & kWh as MJ', async() => { + // adding u1, u2, u3 + const unitData = [ + { + //u1 + name: 'kWh', + identifier: '', + unitRepresent: Unit.unitRepresentType.QUANTITY, + secInRate: 3600, + typeOfUnit: Unit.unitType.UNIT, + suffix: '', + displayable: Unit.displayableType.ALL, + prefferedDisplay: 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, + prefferedDisplay: false, + note: 'special unit' + }, + { + //u3 + name: 'MJ', + identifier: 'megaJoules', + unitRepresent: Unit.unitRepresentType.QUANTITY, + secInRate: 3600, + typeOfUnit: Unit.unitType.UNIT, + suffix: '', + displayable: Unit.displayableType.ALL, + prefferedDisplay: false, + note: 'MJ' + } + + ] await prepareTest(unitDatakWh, conversionDatakWh, meterDatakWh); // Get the unit ID since the DB could use any value. const unitId = await getUnitId('MJ'); From 3fa08dd72a01435ba92f8cdcc5e67a2c1c637ea6 Mon Sep 17 00:00:00 2001 From: Madeleine Chance Date: Tue, 26 Nov 2024 14:24:56 -0800 Subject: [PATCH 3/8] added conversion units --- .../test/web/readingsCompareMeterQuantity.js | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/server/test/web/readingsCompareMeterQuantity.js b/src/server/test/web/readingsCompareMeterQuantity.js index 165277b6a..6b09b58bb 100644 --- a/src/server/test/web/readingsCompareMeterQuantity.js +++ b/src/server/test/web/readingsCompareMeterQuantity.js @@ -113,9 +113,29 @@ mocha.describe('readings API', () => { prefferedDisplay: false, note: 'MJ' } + ]; + const conversionData = [ + { + //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' + } ] - await prepareTest(unitDatakWh, conversionDatakWh, meterDatakWh); + await prepareTest(unitData, conversionData, meterData); // Get the unit ID since the DB could use any value. const unitId = await getUnitId('MJ'); const expected = [11232.0660730344, 12123.0051081528]; From 2f5024f59815da35515a83b8086b569ba8063944 Mon Sep 17 00:00:00 2001 From: Madeleine Chance Date: Tue, 26 Nov 2024 14:27:35 -0800 Subject: [PATCH 4/8] fixed comments --- src/server/test/web/readingsCompareMeterQuantity.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/server/test/web/readingsCompareMeterQuantity.js b/src/server/test/web/readingsCompareMeterQuantity.js index 6b09b58bb..a53d1ee64 100644 --- a/src/server/test/web/readingsCompareMeterQuantity.js +++ b/src/server/test/web/readingsCompareMeterQuantity.js @@ -75,10 +75,10 @@ mocha.describe('readings API', () => { // Add C6 here mocha.it('C8: 1 day shift end 2022-10-31 17:00:00 for 15 minute reading intervals and quantity units & kWh as MJ', async() => { - // adding u1, u2, u3 + // adding units u1, u2, u3 const unitData = [ { - //u1 + // u1 name: 'kWh', identifier: '', unitRepresent: Unit.unitRepresentType.QUANTITY, @@ -90,7 +90,7 @@ mocha.describe('readings API', () => { note: 'OED created standard unit' }, { - //u2 + // u2 name: 'Electric_Utility', identifier: '', unitRepresent: Unit.unitRepresentType.QUANTITY, @@ -102,7 +102,7 @@ mocha.describe('readings API', () => { note: 'special unit' }, { - //u3 + // u3 name: 'MJ', identifier: 'megaJoules', unitRepresent: Unit.unitRepresentType.QUANTITY, @@ -114,10 +114,10 @@ mocha.describe('readings API', () => { note: 'MJ' } ]; - const conversionData = [ + // adding conversions c1, c2 { - //c1 + // c1 sourceName: 'Electric_Utility', destinationName: 'kWh', bidirectional: false, From d2021cbb4ee4f02fa14be261c3fb112d463796b9 Mon Sep 17 00:00:00 2001 From: TavSingh Date: Tue, 26 Nov 2024 14:36:19 -0800 Subject: [PATCH 5/8] Adding meterData object --- .../test/web/readingsCompareMeterQuantity.js | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/src/server/test/web/readingsCompareMeterQuantity.js b/src/server/test/web/readingsCompareMeterQuantity.js index a53d1ee64..a23a8c6fa 100644 --- a/src/server/test/web/readingsCompareMeterQuantity.js +++ b/src/server/test/web/readingsCompareMeterQuantity.js @@ -74,7 +74,7 @@ mocha.describe('readings API', () => { // Add C6 here - mocha.it('C8: 1 day shift end 2022-10-31 17:00:00 for 15 minute reading intervals and quantity units & kWh as MJ', async() => { + mocha.it('C8: 1 day shift end 2022-10-31 17:00:00 for 15 minute reading intervals and quantity units & kWh as MJ', async () => { // adding units u1, u2, u3 const unitData = [ { @@ -134,19 +134,33 @@ mocha.describe('readings API', () => { intercept: 0, note: 'kWh → MJ' } - ] + ]; + const meterData = [ + // adding meterData for MJ Unit + { + name: 'Electric_Utility MJ', + unit: 'Electric_Utility', + displayable: true, + gps: undefined, + note: 'special meter', + file: 'readings_ri_15_days_75.csv', + deleteFile: false, + readingFrequency: '15 minutes', + id: METER_ID + } + ]; await prepareTest(unitData, conversionData, meterData); // Get the unit ID since the DB could use any value. - const unitId = await getUnitId('MJ'); - const expected = [11232.0660730344, 12123.0051081528]; + 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({ - curr_start: '2022-10-31 00:00:00', - curr_end: '2022-10-31 17:00:00', - shift: 'P1D', - graphicUnitId: unitId - }); + .query({ + curr_start: '2022-10-31 00:00:00', + curr_end: '2022-10-31 17:00:00', + shift: 'P1D', + graphicUnitId: unitId + }); expectCompareToEqualExpected(res, expected); }); From 77c94ff137ca530a3453f46f889601bff5f98fd4 Mon Sep 17 00:00:00 2001 From: Madeleine Chance Date: Tue, 26 Nov 2024 14:41:03 -0800 Subject: [PATCH 6/8] fixed typo --- src/server/test/web/readingsCompareMeterQuantity.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/server/test/web/readingsCompareMeterQuantity.js b/src/server/test/web/readingsCompareMeterQuantity.js index a23a8c6fa..ab758028a 100644 --- a/src/server/test/web/readingsCompareMeterQuantity.js +++ b/src/server/test/web/readingsCompareMeterQuantity.js @@ -86,7 +86,7 @@ mocha.describe('readings API', () => { typeOfUnit: Unit.unitType.UNIT, suffix: '', displayable: Unit.displayableType.ALL, - prefferedDisplay: true, + preferredDisplay: true, note: 'OED created standard unit' }, { @@ -98,7 +98,7 @@ mocha.describe('readings API', () => { typeOfUnit: Unit.unitType.METER, suffix: '', displayable: Unit.displayableType.NONE, - prefferedDisplay: false, + preferredDisplay: false, note: 'special unit' }, { @@ -110,7 +110,7 @@ mocha.describe('readings API', () => { typeOfUnit: Unit.unitType.UNIT, suffix: '', displayable: Unit.displayableType.ALL, - prefferedDisplay: false, + preferredDisplay: false, note: 'MJ' } ]; From 7a3171655b51406766b4ed54315fb5678fb04f92 Mon Sep 17 00:00:00 2001 From: Madeleine Chance Date: Tue, 26 Nov 2024 14:44:32 -0800 Subject: [PATCH 7/8] fixed file path in meterData --- src/server/test/web/readingsCompareMeterQuantity.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/test/web/readingsCompareMeterQuantity.js b/src/server/test/web/readingsCompareMeterQuantity.js index ab758028a..8d17e75df 100644 --- a/src/server/test/web/readingsCompareMeterQuantity.js +++ b/src/server/test/web/readingsCompareMeterQuantity.js @@ -143,7 +143,7 @@ mocha.describe('readings API', () => { displayable: true, gps: undefined, note: 'special meter', - file: 'readings_ri_15_days_75.csv', + file: 'test/web/readingsData/readings_ri_15_days_75.csv', deleteFile: false, readingFrequency: '15 minutes', id: METER_ID From 6e8fea15c805e5ccd55155e7e6e1e7327b2011d3 Mon Sep 17 00:00:00 2001 From: AlexanderORuban Date: Fri, 29 Nov 2024 02:19:56 +0000 Subject: [PATCH 8/8] Edited test case to match comment on pull request. --- .../test/web/readingsCompareMeterQuantity.js | 63 +++---------------- 1 file changed, 7 insertions(+), 56 deletions(-) diff --git a/src/server/test/web/readingsCompareMeterQuantity.js b/src/server/test/web/readingsCompareMeterQuantity.js index 8d17e75df..1d933f8d8 100644 --- a/src/server/test/web/readingsCompareMeterQuantity.js +++ b/src/server/test/web/readingsCompareMeterQuantity.js @@ -75,34 +75,9 @@ mocha.describe('readings API', () => { // Add C6 here mocha.it('C8: 1 day shift end 2022-10-31 17:00:00 for 15 minute reading intervals and quantity units & kWh as MJ', async () => { - // adding units u1, u2, u3 - const unitData = [ - { - // 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' - }, + // Use predefined unit and conversion data + const unitData = unitDatakWh.concat([ { - // 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, @@ -113,20 +88,9 @@ mocha.describe('readings API', () => { preferredDisplay: false, note: 'MJ' } - ]; - const conversionData = [ - // adding conversions c1, c2 + ]); + const conversionData = conversionDatakWh.concat([ { - // c1 - sourceName: 'Electric_Utility', - destinationName: 'kWh', - bidirectional: false, - slope: 1, - intercept: 0, - note: 'Electric_Utility → kWh' - }, - { - // c2 sourceName: 'kWh', destinationName: 'MJ', bidirectional: true, @@ -134,22 +98,9 @@ mocha.describe('readings API', () => { intercept: 0, note: 'kWh → MJ' } - ]; - const meterData = [ - // adding meterData for MJ Unit - { - name: 'Electric_Utility MJ', - 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 - } - ]; - await prepareTest(unitData, conversionData, meterData); + ]); + // Prepare test with the standard data + await prepareTest(unitData, conversionData, meterDatakWh); // Get the unit ID since the DB could use any value. const unitId = await getUnitId('MJ'); const expected = [11232.0660730344, 12123.0051081528];