Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final test C10 #1431

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

u1 & u2 are defined in unitDataKWh and should not be redefined here. u3 & u16 should be concat here to define. The test case is failing on my machine and this is the reason why.

{ //u1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OED prefers not to have comments at the end of the line. Could you move these (this one will be removed but for later ones) to the next line above the code being described.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As with units, c1 is already defined and should not be added here.

{ // 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