import sqlite3 from checkout import place_order, subtotal def test_subtotal(): assert subtotal([{"price": 250, "quantity": 2}, {"price": 99, "quantity": 1}]) == 599 def test_place_order(): db = sqlite3.connect(":memory:") db.execute("CREATE TABLE orders (id INTEGER PRIMARY KEY, customer_id INTEGER, total INTEGER)") order = place_order(db, 7, [{"price": 500, "quantity": 1}]) assert db.execute("SELECT total FROM orders WHERE id = ?", (order,)).fetchone() == (500,)