I have a Flask app that's part of a task scheduling system. The business logic in many of the routes relies on the current time.
@app.route("/do_stuff")
def do_stuff():
now = datetime.datetime.now()
call_func(request.args.get("some_arg"), now)
I need to bring these functions under test. The tests will need to spoof timestamps, so that I can verify that the app responds properly depending on when various commands arrive.
Are there standard patterns for writing these kinds of tests in Flask? I can think of a bunch of clunky, non-DRY ways to do it. Wondering if there are any more elegant patterns/tools...?