Closed jemrobinson closed 1 month ago
Click to see where and how coverage changed
File Statements Missing Coverage Coverage
(new stmts)Lines missing
data_safe_haven/functions
strings.py
Project Total
This report was generated by python-coverage-comment-action
next_occurrence
is supposed to give the next time that a desired local time happens in UTC. For some Azure applications the time that you pass cannot be in the past.
Previously, we took local-time-in-UTC + 1 day which is always in the future (over the lifetime of a deploy operation). However, this can break the test which assumes that the output of next_occurrence
will always be within one day of current-time-in-UTC.
Possible solutions are:
next_occurrence
must be within 2 days of nowI'm happy to switch to solution (1) if you prefer.
Hmm, some thoughts that might help,
next_occurrence
will be within one day?
Does it have to be? Will Azure reject times not within one day of now?
Could next_occurrence
simply being in the future be a better test?next_occurrence
and ensure_within_1d
?Why does the test assume
next_occurrence
will be within one day?
Just because that's the intention of the function (to generate the UTC timestamp corresponding to the next time it is e.g. 3am in Perth)
Does it have to be? Will Azure reject times not within one day of now?
No, it doesn't have to be, but some of these schedulers won't start until the time occurs, so it would bad bad if this was e.g. 10 days in the future.
Could next_occurrence simply being in the future be a better test?
Potentially, but I think there should be a maximum window on how far in the future it could be (see above)
The fudge sounds more reasonable given how the Azure API works (and operations are not instantaneous). Adding a comment to explain it would be good.
Happy to remove this fudge (esp. given your comments above)
Should this really be >1 function? next_occurrence and ensure_within_1d?
I think it only needs to be one function - the important thing is to come up with a UTC value that represents when your thing will happen in the future.
Looks like you can't mock builtin methods. I'll have a go with freezegun
.
:white_check_mark: Checklist
Enable foobar integration
rather than515 foobar
).develop
.:vertical_traffic_light: Depends on
n/a
:arrow_heading_up: Summary
Ensure that next_occurrence only adds one day when necessary, to avoid it choosing a datetime more than 1 day in the future
:closed_umbrella: Related issues
Closes #1895
:microscope: Tests
Check CI