24 / 65 · 15 SQL & Database Testing · Data Manipulation← prev⊞ allnext →☰ Read as one page
3.8Practical Exercise
- Write INSERT statements to create a user with 3 orders and 2 line items per order
- Write a cleanup script that deletes all test data in the correct dependency order
- Create a pytest fixture that wraps tests in transactions with rollback
- Write a test that creates data via API and verifies it in the database, then verify the rollback cleaned it up
- Write a bulk data generation script that creates 500 users with random roles