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 for BG13 #1421

Merged
merged 3 commits into from
Feb 8, 2025
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
83 changes: 82 additions & 1 deletion src/server/test/web/readingsBarGroupQuantity.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,88 @@ mocha.describe('readings API', () => {
expectReadingToEqualExpected(res, expected, GROUP_ID);
});

// Add BG13 here
mocha.it('BG13: 1 day bars for 15 + 20 minute reading intervals and quantity units with +-inf start/end time & kWh as metric ton of CO2 & chained', async () => {
const unitData = unitDatakWh.concat([
{
// 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'
}
]);
const conversionData = conversionDatakWh.concat([
{
//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' }
]);
//load data into database
await prepareTest(unitData, conversionData, meterDatakWhGroups, groupDatakWh);
// Get unit ID for 'metric ton CO₂'
const unitId = await getUnitId('metric ton of CO₂');
// Load 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_MTonCO2_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);
});

// Add BG14 here

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
reading,start time,end time
6.06941157428824,2022-08-18 00:00:00,2022-08-19 00:00:00
5.3600950529087,2022-08-19 00:00:00,2022-08-20 00:00:00
6.1363385888459,2022-08-20 00:00:00,2022-08-21 00:00:00
6.02031237213475,2022-08-21 00:00:00,2022-08-22 00:00:00
5.82475240869586,2022-08-22 00:00:00,2022-08-23 00:00:00
5.98482849114233,2022-08-23 00:00:00,2022-08-24 00:00:00
6.04453672566359,2022-08-24 00:00:00,2022-08-25 00:00:00
5.93508743516999,2022-08-25 00:00:00,2022-08-26 00:00:00
5.53590866257469,2022-08-26 00:00:00,2022-08-27 00:00:00
5.96996595764567,2022-08-27 00:00:00,2022-08-28 00:00:00
5.89694043288837,2022-08-28 00:00:00,2022-08-29 00:00:00
5.57361231080648,2022-08-29 00:00:00,2022-08-30 00:00:00
6.08881494914974,2022-08-30 00:00:00,2022-08-31 00:00:00
5.85042840472852,2022-08-31 00:00:00,2022-09-01 00:00:00
5.71640890876994,2022-09-01 00:00:00,2022-09-02 00:00:00
6.17027951065381,2022-09-02 00:00:00,2022-09-03 00:00:00
6.18665565793557,2022-09-03 00:00:00,2022-09-04 00:00:00
5.91629487489138,2022-09-04 00:00:00,2022-09-05 00:00:00
5.51726940948484,2022-09-05 00:00:00,2022-09-06 00:00:00
6.01497656889892,2022-09-06 00:00:00,2022-09-07 00:00:00
6.03905132316679,2022-09-07 00:00:00,2022-09-08 00:00:00
5.8038829685348,2022-09-08 00:00:00,2022-09-09 00:00:00
5.98044656658293,2022-09-09 00:00:00,2022-09-10 00:00:00
5.89379958529856,2022-09-10 00:00:00,2022-09-11 00:00:00
6.378403817572,2022-09-11 00:00:00,2022-09-12 00:00:00
5.91658257205527,2022-09-12 00:00:00,2022-09-13 00:00:00
6.08477823786232,2022-09-13 00:00:00,2022-09-14 00:00:00
5.72884584182247,2022-09-14 00:00:00,2022-09-15 00:00:00
6.03088102504494,2022-09-15 00:00:00,2022-09-16 00:00:00
5.787568676668,2022-09-16 00:00:00,2022-09-17 00:00:00
6.11136424880746,2022-09-17 00:00:00,2022-09-18 00:00:00
6.15165276828447,2022-09-18 00:00:00,2022-09-19 00:00:00
5.85024709482304,2022-09-19 00:00:00,2022-09-20 00:00:00
6.47347539581256,2022-09-20 00:00:00,2022-09-21 00:00:00
5.74884600295891,2022-09-21 00:00:00,2022-09-22 00:00:00
6.19125412974175,2022-09-22 00:00:00,2022-09-23 00:00:00
5.68522305173247,2022-09-23 00:00:00,2022-09-24 00:00:00
5.67499127718854,2022-09-24 00:00:00,2022-09-25 00:00:00
6.04579861756136,2022-09-25 00:00:00,2022-09-26 00:00:00
5.76138007323321,2022-09-26 00:00:00,2022-09-27 00:00:00
5.71608943844792,2022-09-27 00:00:00,2022-09-28 00:00:00
5.95437349494221,2022-09-28 00:00:00,2022-09-29 00:00:00
6.1482098568215,2022-09-29 00:00:00,2022-09-30 00:00:00
5.97153246571957,2022-09-30 00:00:00,2022-10-01 00:00:00
5.84391057900997,2022-10-01 00:00:00,2022-10-02 00:00:00
5.97713386582796,2022-10-02 00:00:00,2022-10-03 00:00:00
5.74081516105115,2022-10-03 00:00:00,2022-10-04 00:00:00
5.9709702794199,2022-10-04 00:00:00,2022-10-05 00:00:00
5.87746271918843,2022-10-05 00:00:00,2022-10-06 00:00:00
6.01136345934627,2022-10-06 00:00:00,2022-10-07 00:00:00
6.15041087042478,2022-10-07 00:00:00,2022-10-08 00:00:00
5.8436561977355,2022-10-08 00:00:00,2022-10-09 00:00:00
5.50229449289721,2022-10-09 00:00:00,2022-10-10 00:00:00
5.89196020736497,2022-10-10 00:00:00,2022-10-11 00:00:00
5.8236261696142,2022-10-11 00:00:00,2022-10-12 00:00:00
6.15516409969168,2022-10-12 00:00:00,2022-10-13 00:00:00
6.02905248499971,2022-10-13 00:00:00,2022-10-14 00:00:00
5.93080658096196,2022-10-14 00:00:00,2022-10-15 00:00:00
5.73521780405837,2022-10-15 00:00:00,2022-10-16 00:00:00
5.85850805873689,2022-10-16 00:00:00,2022-10-17 00:00:00
5.99644774260275,2022-10-17 00:00:00,2022-10-18 00:00:00
5.8499833166756,2022-10-18 00:00:00,2022-10-19 00:00:00
5.6487842460619,2022-10-19 00:00:00,2022-10-20 00:00:00
5.97456052728109,2022-10-20 00:00:00,2022-10-21 00:00:00
6.08789481690719,2022-10-21 00:00:00,2022-10-22 00:00:00
5.76723572718058,2022-10-22 00:00:00,2022-10-23 00:00:00
5.97245731067561,2022-10-23 00:00:00,2022-10-24 00:00:00
6.27645009086608,2022-10-24 00:00:00,2022-10-25 00:00:00
6.47929053423768,2022-10-25 00:00:00,2022-10-26 00:00:00
5.66979546444366,2022-10-26 00:00:00,2022-10-27 00:00:00
5.71784802537126,2022-10-27 00:00:00,2022-10-28 00:00:00
5.99023531580915,2022-10-28 00:00:00,2022-10-29 00:00:00
6.37973868466838,2022-10-29 00:00:00,2022-10-30 00:00:00
5.92095200034458,2022-10-30 00:00:00,2022-10-31 00:00:00
5.54467726481774,2022-10-31 00:00:00,2022-11-01 00:00:00
Loading