-
Notifications
You must be signed in to change notification settings - Fork 437
Test Case LR6 #1539
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
Open
tinisha-davis
wants to merge
1
commit into
OpenEnergyDashboard:development
Choose a base branch
from
tinisha-davis:test-case-lr6
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Test Case LR6 #1539
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,20 +11,22 @@ const { chai, mocha, app } = require('../common'); | |
| const Unit = require('../../models/Unit'); | ||
| const { prepareTest, | ||
| parseExpectedCsv, | ||
| expectRangeToEqualExpected, | ||
| createTimeString, | ||
| getUnitId, | ||
| ETERNITY, | ||
| METER_ID, | ||
| unitDatakWh, | ||
| conversionDatakWh, | ||
| meterDatakWh } = require('../../util/readingsUtils'); | ||
|
|
||
| mocha.describe('readings API', () => { | ||
| mocha.describe('readings test, test if data returned by API is as expected', () => { | ||
| mocha.describe('for line charts', () => { | ||
| mocha.describe('for range (min/max)', () => { | ||
| mocha.describe('for quantity meters', () => { | ||
| expectRangeToEqualExpected, | ||
| createTimeString, | ||
| getUnitId, | ||
| ETERNITY, | ||
| METER_ID, | ||
| unitDatakWh, | ||
| conversionDatakWh, | ||
| meterDatakWh } = require('../../util/readingsUtils'); | ||
| const { timeInterval } = require('d3'); | ||
| const { expect } = require('chai'); | ||
|
|
||
| mocha.describe('readings API', () => { | ||
| mocha.describe('readings test, test if data returned by API is as expected', () => { | ||
| mocha.describe('for line charts', () => { | ||
| mocha.describe('for range (min/max)', () => { | ||
| mocha.describe('for quantity meters', () => { | ||
| // Test using a date range of infinity, which should return as days | ||
| mocha.it('LR1: range should have daily points for 15 minute reading intervals and quantity units with +-inf start/end time & kWh as kWh', async () => { | ||
| // Load the data into the database | ||
|
|
@@ -90,7 +92,42 @@ mocha.describe('readings API', () => { | |
| }, | ||
| ); | ||
|
|
||
| // Add LR6 here | ||
| mocha.it( | ||
| 'LR6: Range with 14 days barely gives raw points and middle readings.', | ||
| async () => { | ||
| // Load data into database | ||
| await prepareTest(unitDatakWh, conversionDatakWh, meterDatakWh); | ||
| // Get unit ID for kWh | ||
| const unitId = await getUnitId('kWh'); | ||
| // Load expected values for LR6 date range and unit configuration | ||
| const expected = await parseExpectedCsv('src/server/test/web/readingsData/expected_line_ri_15_mu_kWh_gu_kWh_st_2022-09-21%00#00#00_et_2022-10-05%00#00#00.csv' , | ||
| ); | ||
|
|
||
| // Send API request with LR6 date range and graphic unit | ||
| const res = await chai.request(app).get(`/api/unitReadings/line/meters/${METER_ID}`).query({ | ||
| timeInterval: createTimeString('2022-09-21', '00:00:00', '2022-10-05', '00:00:00'), | ||
| graphicUnitId: unitId | ||
| }); | ||
|
|
||
| // Extract rows from API response | ||
| const rows = res.body[METER_ID] || []; | ||
| // Loop through each row if API response and compare to corresponding expected row | ||
| rows.forEach((row, i) => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of using a for loop to iterate through and verifying each value manually, please use the function expectRangeToEqualExpected(Response, Expected). |
||
| const expectedRow = expected[i]; | ||
| // Compare reading values | ||
| const actualReading = row.reading; | ||
| const expectedReading = parseFloat(expectedRow[0]) | ||
| expect(actualReading).to.be.closeTo(expectedReading, 0.0001); | ||
|
|
||
| // Compare timestamps | ||
| const expectedStart = new Date(expectedRow[1]).getTime(); | ||
| const expectedEnd = new Date(expectedRow[2]).getTime(); | ||
| expect(row.startTimestamp).to.equal(expectedStart); | ||
| expect(row.endTimestamp).to.equal(expectedEnd); | ||
| }); | ||
|
|
||
| } | ||
| ); | ||
|
|
||
| // Add LR7 here | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 14-29 were modified unnecessarily. Please revert these change or use an auto formatter