You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A lot of the acceptance tests are date-sensitive and have issues with breaking depending on date. It's probably time I look into a better way to fix these. It's a bit complicated to use freezegun since the acceptance tests run a live flask server, but there's probably some way to fix this... even if it means hacking some test helpers into the main code itself... like doing all date lookups from one function that can be overridden by a magic environment variable.
If this is done, we'd probably need to audit the DB code for any SQL that uses DB-side current date operations (other than an INSERT). SQLAlchemy's before_cursor_execute Event should let us capture all SQL that's sent to the DB. If running in pytest, we could register a handler for that event (it'd need to be in the code for the flask app as well, so either in the settings file or via some awful "include this code during tests" trigger) that looks for any of MySQL's current-date functions in the SQL, and raises an exception if one is found.
We'll need something to ensure that Python's built-in date methods aren't called during tests. Not sure what the best way to do this is... perhaps we could use pytest-profiling data? Or should we just assume that over time, we'll find any uses of it because the tests will fail?
There's pytest-freezegun. Might just be able to set that up as an autouse fixture for the unit tests. Then I'd just need to figure out how to do it in the LiveServer, which probably means the above (some hack-y "use this one method for all calls to get date or time, and have that method do something special during tests").
The text was updated successfully, but these errors were encountered:
A lot of the acceptance tests are date-sensitive and have issues with breaking depending on date. It's probably time I look into a better way to fix these. It's a bit complicated to use freezegun since the acceptance tests run a live flask server, but there's probably some way to fix this... even if it means hacking some test helpers into the main code itself... like doing all date lookups from one function that can be overridden by a magic environment variable.
There's pytest-freezegun. Might just be able to set that up as an autouse fixture for the unit tests. Then I'd just need to figure out how to do it in the LiveServer, which probably means the above (some hack-y "use this one method for all calls to get date or time, and have that method do something special during tests").
The text was updated successfully, but these errors were encountered: