Skip to content

Commit

Permalink
Merge pull request #1359 from aravindb24/development
Browse files Browse the repository at this point in the history
Test BG11
  • Loading branch information
huss authored Oct 22, 2024
2 parents fc9def3 + f364a72 commit edd58ae
Showing 1 changed file with 63 additions and 5 deletions.
68 changes: 63 additions & 5 deletions src/server/test/web/readingsBarGroupQuantity.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ mocha.describe('readings API', () => {
mocha.describe('readings test, test if data returned by API is as expected', () => {
mocha.describe('for bar charts', () => {
mocha.describe('for quantity groups', () => {

mocha.it('BG1: 1 day bars for 15 + 20 minute reading intervals and quantity units with +-inf start/end time & kWh as kWh', async () =>{
//loads data into database
await prepareTest(unitDatakWh, conversionDatakWh, meterDatakWhGroups, groupDatakWh)
Expand Down Expand Up @@ -112,7 +111,7 @@ mocha.describe('readings API', () => {
graphicUnitId: unitId });
// Check that the API reading is equal to what it is expected to equal
expectReadingToEqualExpected(res, expected, GROUP_ID);
});
});

mocha.it('BG6: 76 day bars (no values) for 15 + 20 minute reading intervals and quantity units with +-inf start/end time & kWh as kWh', async () =>{
//load data into database
Expand Down Expand Up @@ -201,8 +200,68 @@ mocha.describe('readings API', () => {
expectReadingToEqualExpected(res, expected, GROUP_ID);
});

// Add BG11 here

mocha.it('BG11: 1 day bars for 15 + 20 minute reading intervals and quantity units with +-inf start/end time & kWh as BTU reverse conversion', async () => {
//load data into database
const unitData = unitDatakWh.concat([
{
// 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([
{
// c6
sourceName: 'MJ',
destinationName: 'kWh',
bidirectional: true,
slope: 1 / 3.6,
intercept: 0,
note: 'MJ → kWh'
},
{
// c3
sourceName: 'MJ',
destinationName: 'BTU',
bidirectional: true,
slope: 947.8,
intercept: 0,
note: 'MJ → BTU'
}
]);
await prepareTest(unitData, conversionData, meterDatakWhGroups, groupDatakWh);
//get unit ID since the DB could use any value.
const unitId = await getUnitId('BTU');
//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_kWh_gu_BTU_st_-inf_et_inf_bd_1.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: '1',
graphicUnitId: unitId });
// Check that the API reading is equal to what it is expected to equal
expectReadingToEqualExpected(res, expected, GROUP_ID);
});
mocha.it('BG12: 1 day bars for 15 + 20 minute reading intervals and quantity units with +-inf start/end time & kWh as kg of CO2', async () =>{
const unitData = unitDatakWh.concat([
{
Expand Down Expand Up @@ -275,4 +334,3 @@ mocha.describe('readings API', () => {
});
});
});

0 comments on commit edd58ae

Please sign in to comment.