Requests should be handled if they fall +/- within a preset tolerance. Requests with (what should have been) a negative delta within the preset tolerance were raising an exception.
timedelta.seconds is always a positive integer. For x - y, if x is smaller (earlier) than y, you get "the number of seconds in a day minus the delta" instead of "a negative delta".
from datetime import datetime, timedelta
first = datetime.now()
second = datetime.now()
print((first - second).seconds) # ~ 86397
print((first - second.total_seconds()) # ~ -2.497155
What was intended was most likely timedelta.total_seconds(), which returns a true (negative-possible float) delta.
Motivation and Context
If the server's datetime is fractionally faster than the requests datetime, it'll raise a ValidationException. Unlikely, but possible (happened to me during testing for the first time last week).
Testing
See above code, and new test.
Screenshots (if appropriate)
Types of changes
[x] Bug fix (non-breaking change which fixes an issue)
[ ] New feature (non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to change)
Checklist
[x] My code follows the code style of this project
[ ] My change requires a change to the documentation
[ ] I have updated the documentation accordingly
[x] I have read the README document
[x] I have added tests to cover my changes
[x] All new and existing tests passed
License
[x] I confirm that this pull request can be released under the Apache 2 license
I'm not sure how these errors could be related to my changes.
Is there anything else you guys need from me to get this merged, or are we just waiting for another reviewer?
Description
Requests should be handled if they fall +/- within a preset tolerance. Requests with (what should have been) a negative delta within the preset tolerance were raising an exception.
timedelta.seconds
is always a positive integer. Forx - y
, ifx
is smaller (earlier) thany
, you get "the number of seconds in a day minus the delta" instead of "a negative delta".What was intended was most likely
timedelta.total_seconds()
, which returns a true (negative-possible float) delta.Motivation and Context
If the server's datetime is fractionally faster than the requests datetime, it'll raise a
ValidationException
. Unlikely, but possible (happened to me during testing for the first time last week).Testing
See above code, and new test.
Screenshots (if appropriate)
Types of changes
Checklist
License