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 BG9 test case #1365

Merged
merged 1 commit into from
Oct 22, 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
64 changes: 64 additions & 0 deletions src/server/test/web/readingsBarGroupQuantity.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,70 @@ mocha.describe('readings API', () => {
// Add BG8 here

// Add BG9 here
mocha.it('BG9: 1 day bars for 15 + 20 minute reading intervals and quantity units with +-inf start/end time & kWh as MJ reverse conversion', async () => {

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: true,
note: 'MJ'
}
]);

const conversionData = conversionDatakWh.concat([

{
// c6
sourceName: 'MJ',
destinationName: 'kWh',
bidirectional: true,
slope: 1 / 3.6,
intercept: 0,
note: 'MJ → KWh'
}
]);
const meterData = [
{
name: 'Electric_Utility MJ Reverse',
unit: 'Electric_Utility',
displayable: true,
gps: undefined,
defaultGraphicUnit: 'MJ',
note: 'special meter',
file: 'test/web/readingsData/readings_ri_15_days_75.csv',
deleteFile: false,
readingFrequency: '15 minutes',
id: METER_ID
}
];

// Load data into the database
await prepareTest(unitData, conversionData, meterDatakWhGroups, groupDatakWh, meterData);

// Get unit ID for MJ
const unitId = await getUnitId('MJ');

// 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_MJ_st_-inf_et_inf_bd_1.csv');

// Create a request to the API for unbounded reading times and save the response
const result = await chai.request(app).get(`/api/unitReadings/bar/groups/${GROUP_ID}`)
.query({
timeInterval: ETERNITY.toString(),
barWidthDays: '1',
graphicUnitId: unitId
});

// Check that the API reading matches the expected data from the CSV
expectReadingToEqualExpected(result, expected, GROUP_ID);
});

mocha.it('BG10: 1 day bars for 15 + 20 minute reading intervals and quantity units with +-inf start/end time & kWh as BTU', async () =>{
const unitData = unitDatakWh.concat([
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
reading,start time,end time
30817.8866959629,2022-08-18 00:00:00,2022-08-19 00:00:00
27216.2795352205,2022-08-19 00:00:00,2022-08-20 00:00:00
31157.7135681879,2022-08-20 00:00:00,2022-08-21 00:00:00
30568.581861333,2022-08-21 00:00:00,2022-08-22 00:00:00
29575.6116661567,2022-08-22 00:00:00,2022-08-23 00:00:00
30388.4098280852,2022-08-23 00:00:00,2022-08-24 00:00:00
30691.5828101395,2022-08-24 00:00:00,2022-08-25 00:00:00
30135.8459331621,2022-08-25 00:00:00,2022-08-26 00:00:00
28108.9861569378,2022-08-26 00:00:00,2022-08-27 00:00:00
30312.9442137157,2022-08-27 00:00:00,2022-08-28 00:00:00
29942.1517043697,2022-08-28 00:00:00,2022-08-29 00:00:00
28300.4292227127,2022-08-29 00:00:00,2022-08-30 00:00:00
30916.4087686023,2022-08-30 00:00:00,2022-08-31 00:00:00
29705.9834372675,2022-08-31 00:00:00,2022-09-01 00:00:00
29025.4895226682,2022-09-01 00:00:00,2022-09-02 00:00:00
31330.0511119235,2022-09-02 00:00:00,2022-09-03 00:00:00
31413.2022123668,2022-09-03 00:00:00,2022-09-04 00:00:00
30040.4253167968,2022-09-04 00:00:00,2022-09-05 00:00:00
28014.3439691755,2022-09-05 00:00:00,2022-09-06 00:00:00
30541.4889252978,2022-09-06 00:00:00,2022-09-07 00:00:00
30663.7302727792,2022-09-07 00:00:00,2022-09-08 00:00:00
29469.6455383996,2022-09-08 00:00:00,2022-09-09 00:00:00
30366.1602816623,2022-09-09 00:00:00,2022-09-10 00:00:00
29926.2038181591,2022-09-10 00:00:00,2022-09-11 00:00:00
32386.8176914799,2022-09-11 00:00:00,2022-09-12 00:00:00
30041.8861204499,2022-09-12 00:00:00,2022-09-13 00:00:00
30895.9120681303,2022-09-13 00:00:00,2022-09-14 00:00:00
29088.6389711719,2022-09-14 00:00:00,2022-09-15 00:00:00
30622.2449790716,2022-09-15 00:00:00,2022-09-16 00:00:00
29386.8085134059,2022-09-16 00:00:00,2022-09-17 00:00:00
31030.9045073439,2022-09-17 00:00:00,2022-09-18 00:00:00
31235.472448271,2022-09-18 00:00:00,2022-09-19 00:00:00
29705.0628227968,2022-09-19 00:00:00,2022-09-20 00:00:00
32869.5506698522,2022-09-20 00:00:00,2022-09-21 00:00:00
29190.1912703132,2022-09-21 00:00:00,2022-09-22 00:00:00
31436.5512934701,2022-09-22 00:00:00,2022-09-23 00:00:00
28867.1410243115,2022-09-23 00:00:00,2022-09-24 00:00:00
28815.1884314228,2022-09-24 00:00:00,2022-09-25 00:00:00
30697.990159691,2022-09-25 00:00:00,2022-09-26 00:00:00
29253.8339402533,2022-09-26 00:00:00,2022-09-27 00:00:00
29023.8673884521,2022-09-27 00:00:00,2022-09-28 00:00:00
30233.7723297489,2022-09-28 00:00:00,2022-09-29 00:00:00
31217.9908103772,2022-09-29 00:00:00,2022-09-30 00:00:00
30320.8982744576,2022-09-30 00:00:00,2022-10-01 00:00:00
29672.8886945499,2022-10-01 00:00:00,2022-10-02 00:00:00
30349.3397982802,2022-10-02 00:00:00,2022-10-03 00:00:00
29149.4140758592,2022-10-03 00:00:00,2022-10-04 00:00:00
30318.0437318923,2022-10-04 00:00:00,2022-10-05 00:00:00
29843.2521707734,2022-10-05 00:00:00,2022-10-06 00:00:00
30523.1430940008,2022-10-06 00:00:00,2022-10-07 00:00:00
31229.1666199283,2022-10-07 00:00:00,2022-10-08 00:00:00
29671.5970547924,2022-10-08 00:00:00,2022-10-09 00:00:00
27938.3077213399,2022-10-09 00:00:00,2022-10-10 00:00:00
29916.8642404992,2022-10-10 00:00:00,2022-10-11 00:00:00
29569.8931038239,2022-10-11 00:00:00,2022-10-12 00:00:00
31253.3014934979,2022-10-12 00:00:00,2022-10-13 00:00:00
30612.9604315923,2022-10-13 00:00:00,2022-10-14 00:00:00
30114.1095789324,2022-10-14 00:00:00,2022-10-15 00:00:00
29120.9930812555,2022-10-15 00:00:00,2022-10-16 00:00:00
29747.0084787769,2022-10-16 00:00:00,2022-10-17 00:00:00
30447.4074377573,2022-10-17 00:00:00,2022-10-18 00:00:00
29703.723469721,2022-10-18 00:00:00,2022-10-19 00:00:00
28682.1202903002,2022-10-19 00:00:00,2022-10-20 00:00:00
30336.273481258,2022-10-20 00:00:00,2022-10-21 00:00:00
30911.7367290069,2022-10-21 00:00:00,2022-10-22 00:00:00
29283.5664567702,2022-10-22 00:00:00,2022-10-23 00:00:00
30325.5942432048,2022-10-23 00:00:00,2022-10-24 00:00:00
31869.1400946656,2022-10-24 00:00:00,2022-10-25 00:00:00
32899.0774658049,2022-10-25 00:00:00,2022-10-26 00:00:00
28788.8063074713,2022-10-26 00:00:00,2022-10-27 00:00:00
29032.7967437751,2022-10-27 00:00:00,2022-10-28 00:00:00
30415.8633806953,2022-10-28 00:00:00,2022-10-29 00:00:00
32393.5955780059,2022-10-29 00:00:00,2022-10-30 00:00:00
30064.0722161361,2022-10-30 00:00:00,2022-10-31 00:00:00
28153.5093841239,2022-10-31 00:00:00,2022-11-01 00:00:00
Loading