Skip to content

Commit

Permalink
Merge pull request #1134 from stephanienguyen2020/LG20PR
Browse files Browse the repository at this point in the history
Added LG20 test
  • Loading branch information
huss authored Mar 3, 2024
2 parents 397f40c + 45bef44 commit df360c9
Show file tree
Hide file tree
Showing 2 changed files with 235 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
reading,start time,end time
0.000556362727643089,2022-08-18 00:00:00,2022-08-19 00:00:00
0.000491342046516631,2022-08-19 00:00:00,2022-08-20 00:00:00
0.000562497703977541,2022-08-20 00:00:00,2022-08-21 00:00:00
0.000551861967445685,2022-08-21 00:00:00,2022-08-22 00:00:00
0.000533935637463787,2022-08-22 00:00:00,2022-08-23 00:00:00
0.000548609278354713,2022-08-23 00:00:00,2022-08-24 00:00:00
0.00055408253318583,2022-08-24 00:00:00,2022-08-25 00:00:00
0.000544049681557249,2022-08-25 00:00:00,2022-08-26 00:00:00
0.000507458294069347,2022-08-26 00:00:00,2022-08-27 00:00:00
0.000547246879450853,2022-08-27 00:00:00,2022-08-28 00:00:00
0.000540552873014767,2022-08-28 00:00:00,2022-08-29 00:00:00
0.000510914461823927,2022-08-29 00:00:00,2022-08-30 00:00:00
0.000558141370338726,2022-08-30 00:00:00,2022-08-31 00:00:00
0.000536289270433448,2022-08-31 00:00:00,2022-09-01 00:00:00
0.000524004149970578,2022-09-01 00:00:00,2022-09-02 00:00:00
0.000565608955143266,2022-09-02 00:00:00,2022-09-03 00:00:00
0.000567110101977427,2022-09-03 00:00:00,2022-09-04 00:00:00
0.000542327030198377,2022-09-04 00:00:00,2022-09-05 00:00:00
0.000505749695869444,2022-09-05 00:00:00,2022-09-06 00:00:00
0.000551372852149068,2022-09-06 00:00:00,2022-09-07 00:00:00
0.000553579704623622,2022-09-07 00:00:00,2022-09-08 00:00:00
0.000532022605449024,2022-09-08 00:00:00,2022-09-09 00:00:00
0.000548207601936769,2022-09-09 00:00:00,2022-09-10 00:00:00
0.000540264961985702,2022-09-10 00:00:00,2022-09-11 00:00:00
0.000584687016610767,2022-09-11 00:00:00,2022-09-12 00:00:00
0.0005423534024384,2022-09-12 00:00:00,2022-09-13 00:00:00
0.000557771338470713,2022-09-13 00:00:00,2022-09-14 00:00:00
0.00052514420216706,2022-09-14 00:00:00,2022-09-15 00:00:00
0.00055283076062912,2022-09-15 00:00:00,2022-09-16 00:00:00
0.000530527128694567,2022-09-16 00:00:00,2022-09-17 00:00:00
0.000560208389474017,2022-09-17 00:00:00,2022-09-18 00:00:00
0.00056390150375941,2022-09-18 00:00:00,2022-09-19 00:00:00
0.000536272650358778,2022-09-19 00:00:00,2022-09-20 00:00:00
0.000593401911282818,2022-09-20 00:00:00,2022-09-21 00:00:00
0.000526977550271233,2022-09-21 00:00:00,2022-09-22 00:00:00
0.000567531628559661,2022-09-22 00:00:00,2022-09-23 00:00:00
0.00052114544640881,2022-09-23 00:00:00,2022-09-24 00:00:00
0.000520207533742283,2022-09-24 00:00:00,2022-09-25 00:00:00
0.000554198206609792,2022-09-25 00:00:00,2022-09-26 00:00:00
0.000528126506713045,2022-09-26 00:00:00,2022-09-27 00:00:00
0.00052397486519106,2022-09-27 00:00:00,2022-09-28 00:00:00
0.000545817570369703,2022-09-28 00:00:00,2022-09-29 00:00:00
0.000563585903541971,2022-09-29 00:00:00,2022-09-30 00:00:00
0.000547390476024294,2022-09-30 00:00:00,2022-10-01 00:00:00
0.000535691803075914,2022-10-01 00:00:00,2022-10-02 00:00:00
0.000547903937700896,2022-10-02 00:00:00,2022-10-03 00:00:00
0.000526241389763022,2022-10-03 00:00:00,2022-10-04 00:00:00
0.000547338942280157,2022-10-04 00:00:00,2022-10-05 00:00:00
0.000538767415925606,2022-10-05 00:00:00,2022-10-06 00:00:00
0.000551041650440075,2022-10-06 00:00:00,2022-10-07 00:00:00
0.000563787663122271,2022-10-07 00:00:00,2022-10-08 00:00:00
0.000535668484792421,2022-10-08 00:00:00,2022-10-09 00:00:00
0.000504376995182244,2022-10-09 00:00:00,2022-10-10 00:00:00
0.000540096352341789,2022-10-10 00:00:00,2022-10-11 00:00:00
0.000533832398881302,2022-10-11 00:00:00,2022-10-12 00:00:00
0.000564223375805071,2022-10-12 00:00:00,2022-10-13 00:00:00
0.000552663144458307,2022-10-13 00:00:00,2022-10-14 00:00:00
0.000543657269921513,2022-10-14 00:00:00,2022-10-15 00:00:00
0.000525728298705351,2022-10-15 00:00:00,2022-10-16 00:00:00
0.000537029905384215,2022-10-16 00:00:00,2022-10-17 00:00:00
0.000549674376405252,2022-10-17 00:00:00,2022-10-18 00:00:00
0.000536248470695263,2022-10-18 00:00:00,2022-10-19 00:00:00
0.000517805222555674,2022-10-19 00:00:00,2022-10-20 00:00:00
0.0005476680483341,2022-10-20 00:00:00,2022-10-21 00:00:00
0.000558057024883159,2022-10-21 00:00:00,2022-10-22 00:00:00
0.000528663274991553,2022-10-22 00:00:00,2022-10-23 00:00:00
0.000547475253478598,2022-10-23 00:00:00,2022-10-24 00:00:00
0.000575341258329391,2022-10-24 00:00:00,2022-10-25 00:00:00
0.000593934965638454,2022-10-25 00:00:00,2022-10-26 00:00:00
0.000519731250907335,2022-10-26 00:00:00,2022-10-27 00:00:00
0.000524136068992365,2022-10-27 00:00:00,2022-10-28 00:00:00
0.000549104903949172,2022-10-28 00:00:00,2022-10-29 00:00:00
0.000584809379427935,2022-10-29 00:00:00,2022-10-30 00:00:00
0.00054275393336492,2022-10-30 00:00:00,2022-10-31 00:00:00
0.000508262082608293,2022-10-31 00:00:00,2022-11-01 00:00:00
159 changes: 159 additions & 0 deletions src/server/test/web/readingsLineGroupQuantity.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,165 @@ mocha.describe('readings API', () => {
});

// Add LG20 here
mocha.it('LG20: should have daily points for 15 + 20 minute reading intervals and quantity units with +-inf start/end time & kWh as lbs of CO2 & chained & reversed', async () => {
const unitData = [
//Add units u2, u10, u11, u12, u13
{
// u2
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 = [
//Add conversions c11, c12, c13, c14
{
// 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' }
];

// Redefine the meterData as the unit is different
const meterData = [
{
name: 'Electric Utility pound of CO₂',
unit: 'Electric_Utility',
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
}
];

const meterDataOther = [
{
name: 'Electric Utility Other',
unit: 'Electric_Utility',
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)
}
];

// Concat the meterData and meterDataOther to meterDataGroups
const meterDataGroups = meterData.concat(meterDataOther);

// Define the groupData for the test, as we use pound of CO₂ as unit
const groupData = [
{
id: GROUP_ID,
name: 'Electric Utility pound of CO₂ + Other',
displayable: true,
note: 'special group',
childMeters: ['Electric Utility pound of CO₂', 'Electric Utility Other'],
childGroups: [],
}
];

// Load the data into the database
await prepareTest(unitData, conversionData, meterDataGroups, groupData);
// Get the unit ID since the DB could use any value.
const unitId = await getUnitId('pound of CO₂');
// Load the expected response data from the corresponding csv file
const expected = await parseExpectedCsv('src/server/test/web/readingsData/expected_line_group_ri_15-20_mu_kWh_gu_lbsCO2_st_-inf_et_inf.csv');
// Create a request to the API for unbounded reading times and save the response
const res = await chai.request(app).get(`/api/unitReadings/line/groups/${GROUP_ID}`)
.query({ timeInterval: ETERNITY.toString(), graphicUnitId: unitId });
// Check that the API reading is equal to what it is expected to equal
expectReadingToEqualExpected(res, expected, GROUP_ID);
});

// Add LG21 here

Expand Down

0 comments on commit df360c9

Please sign in to comment.