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 BG14 #1352

Open
wants to merge 4 commits into
base: development
Choose a base branch
from
Open
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
117 changes: 116 additions & 1 deletion src/server/test/web/readingsBarGroupQuantity.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,123 @@ mocha.describe('readings API', () => {

// Add BG13 here

// Add BG14 here
mocha.it('BG14: 1 day bars for 15 + 20 minute reading intervals and quantity units with +-inf start/end time & kWh as lbs of CO2 & chained & reversed', async () =>{
const unitData = [
{
// u2 - add by self since not want kWh
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'
},
{
// u11
name: 'metric ton',
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'
},
{
// u13
name: 'pound',
identifier: 'lb',
unitRepresent: Unit.unitRepresentType.QUANTITY,
secInRate: 3600,
typeOfUnit: Unit.unitType.UNIT,
suffix: '',
displayable: Unit.displayableType.ALL,
preferredDisplay: false,
note: 'special unit'
}
];
const conversionData = [
{
// 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'
},
{
// c13
sourceName: 'kg',
destinationName: 'metric ton',
bidirectional: true,
slope: 1e-3,
intercept: 0,
note: 'kg → Metric ton'
},
{
// c14
sourceName: 'pound',
destinationName: 'metric ton',
bidirectional: true,
slope: 454.545454,
intercept: 0,
note: 'lbs → metric tons'
}
];

//loads data into database
await prepareTest(unitDatakWh, conversionDatakWh, meterDatakWhGroups, groupDatakWh);
Copy link
Member

Choose a reason for hiding this comment

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

The issue is that the provided meters and groups have a default graphic unit of kWh but this test does not create that unit. This causes the code to fail. What needs to happen is the needed meters and groups must be created within this test. It is similar to the standard ones but modified somewhat. I created the needed code to test the solution. If you want that code or for me to commit/push the solution then let me know.

//gets unit ID
const unitId = await getUnitId('pound of CO₂');
//load data from csv file
const expected = await parseExpectedCsv('src/server/test/web/readingsData/expected_bar_group_ri_15-20_mu_kWh_gu_lbsCO2_st_-inf_et_inf_bd_1.csv');

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);
});
});
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
reading,start time,end time
0.0133527054634341,2022-08-18 00:00:00,2022-08-19 00:00:00
0.0117922091163991,2022-08-19 00:00:00,2022-08-20 00:00:00
0.013499944895461,2022-08-20 00:00:00,2022-08-21 00:00:00
0.0132446872186964,2022-08-21 00:00:00,2022-08-22 00:00:00
0.0128144552991309,2022-08-22 00:00:00,2022-08-23 00:00:00
0.0131666226805131,2022-08-23 00:00:00,2022-08-24 00:00:00
0.0132979807964599,2022-08-24 00:00:00,2022-08-25 00:00:00
0.013057192357374,2022-08-25 00:00:00,2022-08-26 00:00:00
0.0121789990576643,2022-08-26 00:00:00,2022-08-27 00:00:00
0.0131339251068205,2022-08-27 00:00:00,2022-08-28 00:00:00
0.0129732689523544,2022-08-28 00:00:00,2022-08-29 00:00:00
0.0122619470837742,2022-08-29 00:00:00,2022-08-30 00:00:00
0.0133953928881294,2022-08-30 00:00:00,2022-08-31 00:00:00
0.0128709424904027,2022-08-31 00:00:00,2022-09-01 00:00:00
0.0125760995992939,2022-09-01 00:00:00,2022-09-02 00:00:00
0.0135746149234384,2022-09-02 00:00:00,2022-09-03 00:00:00
0.0136106424474582,2022-09-03 00:00:00,2022-09-04 00:00:00
0.013015848724761,2022-09-04 00:00:00,2022-09-05 00:00:00
0.0121379927008667,2022-09-05 00:00:00,2022-09-06 00:00:00
0.0132329484515776,2022-09-06 00:00:00,2022-09-07 00:00:00
0.0132859129109669,2022-09-07 00:00:00,2022-09-08 00:00:00
0.0127685425307766,2022-09-08 00:00:00,2022-09-09 00:00:00
0.0131569824464825,2022-09-09 00:00:00,2022-09-10 00:00:00
0.0129663590876568,2022-09-10 00:00:00,2022-09-11 00:00:00
0.0140324883986584,2022-09-11 00:00:00,2022-09-12 00:00:00
0.0130164816585216,2022-09-12 00:00:00,2022-09-13 00:00:00
0.0133865121232971,2022-09-13 00:00:00,2022-09-14 00:00:00
0.0126034608520094,2022-09-14 00:00:00,2022-09-15 00:00:00
0.0132679382550989,2022-09-15 00:00:00,2022-09-16 00:00:00
0.0127326510886696,2022-09-16 00:00:00,2022-09-17 00:00:00
0.0134450013473764,2022-09-17 00:00:00,2022-09-18 00:00:00
0.0135336360902258,2022-09-18 00:00:00,2022-09-19 00:00:00
0.0128705436086107,2022-09-19 00:00:00,2022-09-20 00:00:00
0.0142416458707876,2022-09-20 00:00:00,2022-09-21 00:00:00
0.0126474612065096,2022-09-21 00:00:00,2022-09-22 00:00:00
0.0136207590854319,2022-09-22 00:00:00,2022-09-23 00:00:00
0.0125074907138114,2022-09-23 00:00:00,2022-09-24 00:00:00
0.0124849808098148,2022-09-24 00:00:00,2022-09-25 00:00:00
0.013300756958635,2022-09-25 00:00:00,2022-09-26 00:00:00
0.0126750361611131,2022-09-26 00:00:00,2022-09-27 00:00:00
0.0125753967645854,2022-09-27 00:00:00,2022-09-28 00:00:00
0.0130996216888729,2022-09-28 00:00:00,2022-09-29 00:00:00
0.0135260616850073,2022-09-29 00:00:00,2022-09-30 00:00:00
0.0131373714245831,2022-09-30 00:00:00,2022-10-01 00:00:00
0.0128566032738219,2022-10-01 00:00:00,2022-10-02 00:00:00
0.0131496945048215,2022-10-02 00:00:00,2022-10-03 00:00:00
0.0126297933543125,2022-10-03 00:00:00,2022-10-04 00:00:00
0.0131361346147238,2022-10-04 00:00:00,2022-10-05 00:00:00
0.0129304179822145,2022-10-05 00:00:00,2022-10-06 00:00:00
0.0132249996105618,2022-10-06 00:00:00,2022-10-07 00:00:00
0.0135309039149345,2022-10-07 00:00:00,2022-10-08 00:00:00
0.0128560436350181,2022-10-08 00:00:00,2022-10-09 00:00:00
0.0121050478843739,2022-10-09 00:00:00,2022-10-10 00:00:00
0.0129623124562029,2022-10-10 00:00:00,2022-10-11 00:00:00
0.0128119775731512,2022-10-11 00:00:00,2022-10-12 00:00:00
0.0135413610193217,2022-10-12 00:00:00,2022-10-13 00:00:00
0.0132639154669994,2022-10-13 00:00:00,2022-10-14 00:00:00
0.0130477744781163,2022-10-14 00:00:00,2022-10-15 00:00:00
0.0126174791689284,2022-10-15 00:00:00,2022-10-16 00:00:00
0.0128887177292212,2022-10-16 00:00:00,2022-10-17 00:00:00
0.0131921850337261,2022-10-17 00:00:00,2022-10-18 00:00:00
0.0128699632966863,2022-10-18 00:00:00,2022-10-19 00:00:00
0.0124273253413362,2022-10-19 00:00:00,2022-10-20 00:00:00
0.0131440331600184,2022-10-20 00:00:00,2022-10-21 00:00:00
0.0133933685971958,2022-10-21 00:00:00,2022-10-22 00:00:00
0.0126879185997973,2022-10-22 00:00:00,2022-10-23 00:00:00
0.0131394060834863,2022-10-23 00:00:00,2022-10-24 00:00:00
0.0138081901999054,2022-10-24 00:00:00,2022-10-25 00:00:00
0.0142544391753229,2022-10-25 00:00:00,2022-10-26 00:00:00
0.012473550021776,2022-10-26 00:00:00,2022-10-27 00:00:00
0.0125792656558168,2022-10-27 00:00:00,2022-10-28 00:00:00
0.0131785176947801,2022-10-28 00:00:00,2022-10-29 00:00:00
0.0140354251062704,2022-10-29 00:00:00,2022-10-30 00:00:00
0.0130260944007581,2022-10-30 00:00:00,2022-10-31 00:00:00
0.012198289982599,2022-10-31 00:00:00,2022-11-01 00:00:00
Loading