Integrity Tests: pytest
Explore how to implement integrity tests with pytest to maintain database accuracy. Understand using SQLAlchemy constraints, clean and unclean data fixtures, and automated tests to detect and fix data inconsistencies efficiently.
We'll cover the following...
We'll cover the following...
Integrity tests using pytest
In some cases, periodically checking for data issues is insufficient. Instead, we can clean the data using functions. These must be tested on a separate instance of a database with the unclean data purposely put in place, using separate fixtures for clean and unclean test data. We need a new function that drops the data but keeps the schema, but be sure to only run this on the test connection.
The fixture uses this to define a clean-data session.
The tests are ...