-
Notifications
You must be signed in to change notification settings - Fork 3
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
Adding unit tests to statistics #43
base: main
Are you sure you want to change the base?
Adding unit tests to statistics #43
Conversation
e3f8d11
to
3b83bdb
Compare
expect(statistic.data[0].history.last).toEqual(data[0].forecast.last); | ||
expect(statistic.data[1].forecast).toEqual(data[1].forecast); | ||
expect(statistic.data[1].history).not.toEqual(data[1].history); | ||
// TODO: don't fully understand the intended behaviour here |
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.
See here re intended behaviour. Why 4 values? Why does last get set to 09:38?
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.
not entirely sure, but I am guessing this is trying to test a 1min interval interpolation.
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.
@chienleng yes - I wrote the test, in case that wasn't clear :D This was just related to not fully understanding the intent behind the behaviour around start/last and the number of interpolated values - and therefore harder to write a meaningful test for it. So long as you think the test actually makes sense, then 👍
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.
ah, got it. :) Understood about the confusion of those values. The Stats class will need a refactor at some point, I am mostly porting this from a previous code base from OpenNEM.
I will take a closer look at reviewing this some time this week.
thanks for your help though.
3b83bdb
to
bc0fbba
Compare
it('returns interpolated data from 30 minutes interval to 5 minutes interval', () => { | ||
const minInterval = parseInterval('5m'); | ||
const data = [ | ||
// TODO: not sure why we require this to be here for interpolation to occur? |
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.
And here - I wasn't clear why there needed to be another entry in the data array. Would be great to make the test explicit to explain further.
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.
it's because the function only performs the interpolation if it detects there is a difference in the intervals returned. Will add that comment to the interpolate-data
function.
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.
@chienleng thanks :) Given the desired minInterval is passed in, the context I think I'm missing was around the relationship of the start/end date of those StatsData objects that match the desired minInterval and the corresponding filtering - ie around https://github.com/opennem/openelectricity/pull/43/files/bc0fbba86875f99da82bcbcf2881b4f07c6e1946#diff-fc1bb786b10f9d5da7716d320830a20042c0a7e5b60670ff93f3f9798ad74beeR56-R66 - as that results in an empty data field being returned otherwise. This only stood out while trying to build test cases - I haven't yet dug into the broader usage when I'm sure this would be clear, so no need to address as such :)
Replaces #35 to solve half of #32
I made some changes from @Phuc-Hong-Tran's approach, hope this is ok @chienleng
I should also say