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

Added Test Case BG16 #1373

Merged
merged 10 commits into from
Oct 28, 2024
92 changes: 90 additions & 2 deletions src/server/test/web/readingsBarGroupFlow.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,96 @@ mocha.describe('readings API', () => {
expectReadingToEqualExpected(res, expected, GROUP_ID);
});

// Add BG16 here

mocha.it('BG16: should have daily points for 15 + 20 minute reading intervals and flow units with +-inf start/end time & thing as thing where rate is 36', async () => {
const unitDataThing = [
{
// u14
name: "Thing_36",
identifier: "",
unitRepresent: Unit.unitRepresentType.FLOW,
secInRate: 36,
typeOfUnit: Unit.unitType.METER,
suffix: "",
displayable: Unit.displayableType.NONE,
preferredDisplay: false,
note: "special unit"
},
{
// u15
name: "thing unit",
identifier: "",
unitRepresent: Unit.unitRepresentType.FLOW,
secInRate: 3600,
typeOfUnit: Unit.unitType.UNIT,
suffix: "",
displayable: Unit.displayableType.ALL,
preferredDisplay: false,
note: "special unit"
}
];
const conversionDataThing = [
{
// c15
sourceName: "Thing_36",
destinationName: "thing unit",
bidirectional: false,
slope: 1,
intercept: 0,
note: "Thing_36 → thing unit"
}
];
const meterDataThingGroups = [
{
name: 'Thing_36 thing unit',
unit: 'Thing_36',
defaultGraphicUnit: 'thing unit',
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
},
{
name: 'Thing_36 Other',
unit: 'Thing_36',
defaultGraphicUnit: 'thing unit',
displayable: true,
gps: undefined,
note: 'special meter',
file: 'test/web/readingsData/readings_ri_20_days_75.csv',
deleteFile: false,
readingFrequency: '20 minutes',
id: (METER_ID + 1)
}
];
const groupThing = [
{
id: GROUP_ID,
name: 'Thing_36 thing unit + Thing_36 Other',
displayable: true,
note: 'special group',
defaultGraphicUnit: 'thing unit',
childMeters: ['Thing_36 thing unit', 'Thing_36 Other'],
childGroups: [],
}
]
//load data into database
await prepareTest(unitDataThing, conversionDataThing, meterDataThingGroups, groupThing);
//get unit ID since the DB could use any value.
const unitId = await getUnitId('thing unit');
// Load the expected response data from the corresponding csv file
const expected = await parseExpectedCsv('src/server/test/web/readingsData/expected_bar_group_ri_15-20_mu_Thing36_gu_thing_st_-inf_et_inf_bd_13.csv');
// Create a request to the API for unbounded reading times and save the response
const res = await chai.request(app).get(`/api/unitReadings/bar/groups/${GROUP_ID}`)
.query({
timeInterval: ETERNITY.toString(),
barWidthDays: '13',
graphicUnitId: unitId });
// Check that the API reading is equal to what it is expected to equal
expectReadingToEqualExpected(res, expected, GROUP_ID);
});
});
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
reading,start time,end time
3098568.24778472,2022-08-28 00:00:00,2022-09-10 00:00:00
3158442.06007844,2022-09-10 00:00:00,2022-09-23 00:00:00
3078678.36050569,2022-09-23 00:00:00,2022-10-06 00:00:00
3096487.3496156,2022-10-06 00:00:00,2022-10-19 00:00:00
3121656.58075156,2022-10-19 00:00:00,2022-11-01 00:00:00
Loading