Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Testing the last 8 bags on a purchase order with SQLite

A café orders 24 five-pound bags at $33 each. The first shipment arrives with a supplier invoice for 16 bags. That bill comes to $528. Now try to enter a second bill for 9 bags. A check against the original 24 will happily accept it, leaving the café billed for 25. The interesting pair of inputs is 8 and 9 , both tried from exactly the same starting point. Eight should create a $264 bill and…

A café ordered 24 five-pound bags of coffee beans at $33 each. The supplier sent an invoice for 16 bags, totaling $528. When attempting to add a second bill for 9 bags, SQLite mistakenly accepted it, leaving the café billed for 25 bags instead of the expected 25. Interestingly, both 8 and 9 bags were tested from the same starting point.

An 8-bag bill should have generated a $264 bill and left zero bags on order. Conversely, a 9-bag bill should have failed, keeping the first bill and the remaining bags intact. Running the eight-bag case first and then reusing the database for the nine-bag case would only test the scenario of a completely filled order. This Python script, named test_partial_bill.py, uses SQLite's standard library and an in-memory database.

It involves one line of order data, whole bags, and no tax, freight, or cancellations. All amounts are given in cents. The code first updates the order line to add the requested bags, then attempts to insert a bill line based on the new bag count. The test checks if the expected number of bags and bill amounts are in place after each operation. If the number of bags exceeds the remaining quantity, a ValueError is raised.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

HFE measures whether the model correctly performs easy tasks every time.

This article begins with a Google DeepMind blog post dated November 24, 2026, which introduced a benchmark named Humanity's First Exam or HFE on Kaggle to measure how consistently language models can…

  • HFE benchmark evaluates simple QA models' consistency.
  • 544 prompts and images in 136 datasets with 4 prompts each.
  • Only 7.6-80.1% of models consistently pass reliability test.

Black Friday 2026: stolen sessions and card testing hit small storefronts

On 24 November 2026, Fortinet's FortiGuard Labs published its holiday season threat report. It counted more than 24,000 newly registered holiday shopping domains and classified more than 4,400 of them…

  • 24,000+ malicious domains registered for holiday shopping in 2026
  • Over 1.72 million infostealer entries target major e-commerce platforms
  • Stolen sessions, credential stuffing, and card testing identified as top threats

More from Friday 27 November →