Modern QA2026Practical Exercise — tiles
Log inJoin
7 / 65 · 15 SQL & Database Testing · SELECT Queries for Verification← prev⊞ allnext →☰ Read as one page

1.7Practical Exercise

Write SQL verification queries for the following scenarios:

  1. After creating a user via API, verify the user exists in the database with correct name, email, and default role
  2. After placing an order, verify the order total matches the sum of line items
  3. After soft-deleting a user, verify the deleted_at timestamp is set and the user still exists in the table
  4. Find all users who registered in the last 24 hours (for post-deployment verification)
  5. Find any orders with negative totals (should not exist)
  6. Integrate one of these queries into a pytest test using psycopg2