If you have a giant legacy code base with no unit tests, there are probably 2-3 unit tests you can write that will MASSIVELY improve delivery rate.
Example:
- owned a legacy system that deployed software to production
- there were "deployment windows" for different applications
- the "is now time to deploy app X?" logic was a giant rat's nest of if/then statements
- AND it used datetime.now() in the function
- that meant you had to wait for the window to actually hit to see if any changes worked
- changed the function to be can_deploy(current_time = datetime.now()) so you could pass in a time
- meant we could add unit tests
- changes to the logic went from taking two people 45 minutes hand tracing to <30 seconds
I tell this story whenever people say "I don't have time for unit tests!". I think they mean "I don't have time to write an entire suite of unit tests" which might be fair. But there is ALWAYS time to write a couple key tests.
You could also do this with freezegun or time-machine without changing the function signature. Although I guess your way is less off-putting for people who don't like tests.
Example:
- owned a legacy system that deployed software to production
- there were "deployment windows" for different applications
- the "is now time to deploy app X?" logic was a giant rat's nest of if/then statements
- AND it used datetime.now() in the function
- that meant you had to wait for the window to actually hit to see if any changes worked
- changed the function to be can_deploy(current_time = datetime.now()) so you could pass in a time
- meant we could add unit tests
- changes to the logic went from taking two people 45 minutes hand tracing to <30 seconds
I tell this story whenever people say "I don't have time for unit tests!". I think they mean "I don't have time to write an entire suite of unit tests" which might be fair. But there is ALWAYS time to write a couple key tests.