Skip to content

Commit

Permalink
Final test C10
Browse files Browse the repository at this point in the history
Co-authored by: Caden Carpenter <[email protected]>
Co-authored by: Anthony Theng <[email protected]>
  • Loading branch information
heleeon committed Feb 22, 2025
1 parent 5ab5b1f commit 1529c8c
Showing 1 changed file with 93 additions and 1 deletion.
94 changes: 93 additions & 1 deletion src/server/test/web/readingsCompareMeterQuantity.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 1529c8c

Please sign in to comment.