Skip to content

Commit

Permalink
Merge pull request #1426 from kundyzs/team_kev_kun_ye
Browse files Browse the repository at this point in the history
Issue #962 - Added Test for C12
  • Loading branch information
huss authored Feb 17, 2025
2 parents a59cfd2 + 6795797 commit 24239e9
Showing 1 changed file with 90 additions and 1 deletion.
91 changes: 90 additions & 1 deletion src/server/test/web/readingsCompareMeterQuantity.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,96 @@ mocha.describe('readings API', () => {

// Add C11 here

// Add C12 here
mocha.it('C12: 1 day shift end 2022-10-31 17:00:00 for 15 minute reading intervals and quantity units & kWh as kg of CO2', async () => {
const unitData = [
// adding units u2, u10, u12
{
//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'
},
{
// u10
name: 'kg',
identifier: '',
unitRepresent: Unit.unitRepresentType.QUANTITY,
secInRate: 3600,
typeOfUnit: Unit.unitType.UNIT,
suffix: '',
displayable: Unit.displayableType.ALL,
preferredDisplay: false,
note: 'OED created standard unit'
},
{
// u12
name: 'kg CO₂',
identifier: '',
unitRepresent: Unit.unitRepresentType.QUANTITY,
secInRate: 3600,
typeOfUnit: Unit.unitType.UNIT,
suffix: 'CO₂',
displayable: Unit.displayableType.ALL,
preferredDisplay: false,
note: 'special unit'
}
];
const conversionData = [
// adding conversions c11, c12
{
// c11
sourceName: 'Electric_Utility',
destinationName: 'kg CO₂',
bidirectional: false,
slope: 0.709,
intercept: 0,
note: 'Electric_Utility → kg CO₂'
},
{
// c12
sourceName: 'kg CO₂',
destinationName: 'kg',
bidirectional: false,
slope: 1,
intercept: 0,
note: 'CO₂ → kg'
}
];
const meterData = [
{
name: 'Electric Utility pound of CO₂',
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
}
];
// Prepare test with the standard data
await prepareTest(unitData, conversionData, meterData);
// Get the unit ID since the DB could use any value.
const unitId = await getUnitId('kg of CO₂');
const expected = [2212.09301271706, 2387.55850602232];
// 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 C13 here

Expand Down

0 comments on commit 24239e9

Please sign in to comment.