-
Notifications
You must be signed in to change notification settings - Fork 202
Correctly apply offset to custom timestamp value (fixes #563) #576
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
Conversation
Line-length set to maximum 96.
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.
Do we really want to utilize the timestamp module itself to verify test results? I think the previous approach of verifying raw message bytes is more robust and explicit. You could still do the decoding and "semantic" verification after confirming that the correct data was received. But that's actually testing two parts of the module functionality, where currently you remove the actual check for the first.
I added back the direct validation of the timestamp and compare it with the bus output. Its good a good thing to do, as it verifies the value of the date based tests as well. The previous value in the test were wrong thou. The timestamp |
I'm beginning to wonder whether changing the docs would be the better way then. We have a test to catch if the behavior changes. But instead of keeping the behavior consistent, we now change the behavior and adjust the test. Not what I'd call API stability, which the test was meant to guarantee, no? I'll have to ponder this a bit more, can't really dig into this right now. |
I humbly beg to differ. Using other epochs than unix epoch is rare and somewhat an oddity. It's ok that this is epoch of choice in canopen communication is their 1984 epoch, but outside that CAN transport, its unlikely that these values are used directly in the application code. We use the canopen library to avoid dealing with how the busdata is encoded. As a consumer of a communication API, I would frown if it used a datestamp in seconds since 2000 as an example. Unix timestamp is the defacto standard and I think #563 is legitimate. |
Good arguments 👍 |
* Independent test_epoch() method. * Reduce diff for constant test vector, remove unpacking. * Avoid use of internal constants (except the OFFSET one tested above) in dynamic unpacking test vector.
Okay I think I'm getting it now. You're doing three things to these unit tests:
The rather complex calculations are only needed for the latter test vector, as that one is dynamic. We don't need it for the constant case (2), that can stay as is except for the correction. And it doesn't need to run within the context manager block. I'm a bit skeptical about re-using internal module constants for the tests. IMHO they should test the external API surface, independently from the internal implementation specifics. So at least we can replace the I'll push a commit where I've tried to untangle these three changes, please have a look whether that's clear to you. It certainly made things clearer for me ;-) |
With all due respect, aren't we putting at lot of scrutiny into this one test case now? We have more than enough to chew in the main project... Please feel free to make the adjustments you see fit. |
Sure, sorry for the noise. I just needed some thinking out loud I guess, to understand what's going on here. As unit tests are all about correctness, I wanted to understand what you're proposing and the original diff was just too much to see directly. |
Fix issue when providing a custom timestamp. Updated the test case to test provided and not provided timestamp.
Fixes #563