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

Completed test case C15 #1375

Merged
merged 6 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/server/test/web/readingsCompareGroupFlow.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ mocha.describe('readings API', () => {
await prepareTest(unitDatakW, conversionDatakW, meterDatakWGroups, groupDatakW);
//get unit ID since the DB could use any value.
const unitId = await getUnitId('kW');
const expected = [14017.4841100155, 14605.4957015091];
const expected = [4008.97545574702, 4182.62793481036];
//for compare, need the unitID, currentStart, currentEnd, shift
const res = await chai.request(app).get(`/api/compareReadings/groups/${GROUP_ID}`)
.query({
Expand Down
75 changes: 72 additions & 3 deletions src/server/test/web/readingsCompareMeterFlow.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,89 @@
See: https://github.com/OpenEnergyDashboard/DesignDocs/blob/main/testing/testing.md for information.
*/
const { chai, mocha, app } = require('../common');
const { prepareTest,
const {
prepareTest,
expectCompareToEqualExpected,
getUnitId,
METER_ID,
unitDatakWh,
conversionDatakWh,
meterDatakWh } = require('../../util/readingsUtils');
meterDatakWh
} = require('../../util/readingsUtils');
const Unit = require('../../models/Unit');

mocha.describe('readings API', () => {
mocha.describe('readings test, test if data returned by API is as expected', () => {
mocha.describe('for compare charts', () => {
mocha.describe('for meters', () => {
// Add C15 here

mocha.it('C15: 7 day shift end 2022-10-31 17:00:00 for 15 minute reading intervals and flow units & 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
}
];
await prepareTest(unitData, conversionData, meterData);
const unitId = await getUnitId('kW');
const expected = [1990.55774277443, 2057.611897078];

const res = await chai.request(app)
.get(`/api/compareReadings/meters/${METER_ID}`)
.query({
curr_start: '2022-10-30 00:00:00',
curr_end: '2022-10-31 17:00:00',
shift: 'P7D',
graphicUnitId: unitId
});

expectCompareToEqualExpected(res, expected);
});
// Add C16 here
});
});
Expand Down
Loading