Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

To move one surcharge without changing quote results, first capture three outputs from the unchanged public pricing function, verify that a focused test reproduces them, then extract only residential_surcharge_cents(weight_g) and rerun that same test. The sample outputs are 920, 1,310, and 2,970 cents; they are tutorial fixtures, not real shipping prices. This is a narrow characterization-test gate: it helps detect behavior changes during a refactor, but it does not establish that the existing prices or business rules are correct.

What does a three-row characterization test protect?

A characterization test records what a program does now and treats that observed behavior as the contract for a specific change. For a quote function, the contract is not just an amount: each test case needs the input conditions that produce the amount, including zone, weight, residential status, and weekend status.

This is useful when a function combines several rules and you want to isolate one of them. Before moving code, a passing test shows that the recorded cases match the current implementation. Afterward, the same test can flag an unintended change to those cases. It does not prove every branch is covered, that a quote is commercially correct, or that a known defect should be preserved forever.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The central constraint is scope. The refactor moves the residential surcharge calculation into residential_surcharge_cents(weight_g); zone lookup, fuel calculation, weekend handling, and the remaining AS_OF clock read stay where they are. Keeping the change that small makes a failing test easier to interpret and a diff easier to review.

Popular on Amazon
Silkland 40Gbps USB C 90 Degree Right Angle Adapter 2 Pack, 240W USB4 | Male to Female Extender, 8K@60Hz, Thunderbolt 4/3, Steam Deck, ROG Ally, MacBook, Switch 2, iPhone 18/17/16/15, Quest 3 VR
  • 【90 Degree Full Function USB C Adapter】Supports the latest USB4 standard for up to 40Gbps of bandwidth, 8K video support, and up to 240W Fast charging; Support USB PD 3.1 Extended Power Range (EPR) including 140W, 180W and 240W. Your productivity is easily doubled. *Warm Tip: For the best fit, please make sure the USB-C port is fully exposed; thick or bulky cases may affect compatibility.
  • 【Reliable Quality】Made from high-quality, scratch-resistant aluminum alloy, delicate metal frame. get excellent wear resistance and heat dissipation. Non-Slip Design for easier insertion and removal.
  • 【Small and portable】Ultra thin size, ultra compact design, a petite physique that matches the minimalist design of your modern laptops. Coming with a slim figure that won't block the port next to the one it's plugged into.
  • 【Compatibility】Widely work with most usb c, thunderbolt 4/3 devices. Compatibilit for ROG Ally, Steam Deck, Switch, MacBook Pro, Quest 3 VR headset, Surface Book 2, iPhone 18/17/16/15, Samsung Galaxy S23/S22/S21, Note 20/10, Google Pixel, ChromeBook, etc.
  • 【Excellence Customer Support】If you experience any issues or cable failure, simply reach out to our dedicated customer service team. We provide a prompt response within 18 hours, providing you with the necessary technical support to resolve any concerns.

Which three quote rows should you freeze?

Record the values returned by the unchanged function, along with the inputs that distinguish each case. The tutorial’s sample contract is:

Case Zone Weight Residential Weekend Returned cents
q1 2 400 g No No 920
q2 2 400 g Yes No 1,310
q3 5 1,200 g Yes Yes 2,970

These are sample-function results in the DEV Community tutorial’s 2026 context. They are not carrier rates, a market comparison, or a recommendation for what a customer should be charged. The useful signal is the relationship between the inputs and the observed output: q1 and q2 hold zone and weight constant while changing residential status; q3 exercises a different zone and includes both residential and weekend conditions.

Capture, do not manufacture, the expected values

Run each case against the existing function before editing and record its actual return value. Do not calculate what you think the quote ought to be and use that as the expected value. A fixture guessed in advance can fail before any refactoring begins, while an adjusted fixture can conceal a change introduced by the edit.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If a baseline case does not reproduce its recorded result, stop. Check that the fixture inputs, types, call shape, and environment match the existing function. A red result at this stage is evidence that the test does not yet describe the current behavior; it is not a reason to rewrite the pricing module.

Also popular on Amazon
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

How do you write the test around the public quote function?

Put the cases in a focused test that calls the same public function callers use, rather than testing only the new helper. The public-function test captures the combined behavior at the boundary that matters: the quote returned for the supplied zone, weight, and flags.

  1. Identify the public call. Use the project’s existing quote function and its real argument names and types. Keep the test at that interface so it exercises the existing zone, fuel, residential, and weekend logic together.
  2. Represent q1, q2, and q3 as explicit cases. Each case should make its inputs and expected integer-cent result easy to review. Do not hide a flag or weight behind a default that makes the intended scenario unclear.
  3. Assert the returned cents. Compare the function’s result with the recorded integer value. The expected amount should remain fixed for this behavior-preserving change, not be recomputed using the helper under test.
  4. Run the focused test before editing. The example command is python -m pytest tests/test_quote_rows.py -q. The path assumes the test file is located there; use the project’s actual test path if it differs.

The exact public function name and signature are project-specific, so the test must use those from the codebase rather than a made-up interface. The important design choice is to assert the three observed public outputs independently of the extracted helper’s implementation.

How do you extract only the residential surcharge helper?

After the baseline test passes, move only the residential surcharge calculation into residential_surcharge_cents(weight_g). Keep the helper focused on the weight-based residential amount; do not use the extraction as an opportunity to restructure the quote calculation or modify adjacent rules.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Locate the existing residential branch and identify the exact calculation it performs.
  2. Move that calculation into the helper, preserving its existing weight thresholds and integer-cent behavior.
  3. Replace the branch’s inline calculation with a call to the helper, passing the weight in grams.
  4. Leave zone mapping, fuel percentage or calculation, weekend handling, and the remaining AS_OF clock read untouched.
  5. Review the diff for unrelated edits before running the focused test again.

The purpose is not to make the module more elegant in one pass. A one-helper diff narrows the possible causes if a quote changes and makes it clearer whether the extraction itself preserved behavior.

Also popular on Amazon
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

What should happen when you rerun the same test?

Run the same q1, q2, and q3 test after the extraction, using the same inputs and expected cents. A green result means those three observed outputs are unchanged for those three cases; it is a useful gate for this refactor, not a certificate for the whole pricing system.

If the test fails, compare the current diff with the intended one-helper move. Check whether the helper was given the same weight used by the old branch, whether a threshold or integer conversion changed, and whether other quote logic moved or was edited. Do not make the test green by changing the expected cents unless a separate, approved price change is intended.

Failure signatures to investigate

  • All three cases fail before the edit: verify the baseline fixture and public function call. The test must first agree with the unchanged implementation.
  • Only residential cases fail after the move: inspect the helper’s weight input, the original branch’s thresholds, and how the returned surcharge is combined with the base amount.
  • q1 changes even though it has no residential add-on: check for edits outside the residential branch, including shared arithmetic or the quote function’s call flow.
  • q3 changes while q1 and q2 pass: look for collateral changes to zone 5 handling, weekend handling, or other logic that was meant to remain in place.
  • The test passes but the diff includes rate or mapping edits: do not treat the green result as approval for those edits. Revert unrelated changes or get the product-price change reviewed separately.

These symptoms are diagnostic prompts, not proof of a particular bug. The actual cause depends on the implementation and the diff.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When are three rows not enough?

Three rows are deliberately a small characterization gate, not full branch coverage. The tutorial specifically identifies zone 9, zero weight, negative flags, and unexercised weight thresholds as gaps. A green result cannot establish how the function behaves for those inputs or for every possible branch.

Also popular on Amazon
BENFEI USB C Hub 5-in-1 with 4K HDMI(Certified), 100W Power Delivery, 3 USB-A, Silicone Cable, Aluminum Case Compatible with MacBook Pro/Air, iPad Pro, iMac, iPhone 15 Pro/Pro Max, XPS, Thinkpad
  • Portable and powerful USB-C HUB: BENFEI USB Type-C HUB, with super-soft and knot-free silicone woven design cable, meets most mobile office needs. Compact, lightweight, stylish, and powerful portable USB C Hub equipped with 1 x HDMI port, 1 x 100W charging, and 3 x USB ports. 18-month warranty, 24-hour response, to ensure you feel at ease when using our product.
  • Design centered on comfort and reliability: Thanks to BENFEI's end-to-end in-house cable production capability, in-house PCBA and assembly capability, using the industry's most advanced silicone woven design and process, 20cm cable in length, no knots, super-soft, the HUB is easy to use in all scenarios: laptop, tablet, stand etc. Super-soft, 25000+ life cycles, to meet your daily carrying and office needs.
  • 100W Charging: Support up to 90W USB C pass-through charging via Type-C port to keep your laptop powered. 10W is reserved for other interface operations. No data and video function on the Type-C port.
  • 4K HDMI Display: The HDMI port supports media display at resolutions up to 4K 30Hz, keeping every incredible moment detailed and ultra vivid. Please note that the C port of the Host device needs to support video output.
  • Transfer Files in Seconds: Transfer files and from your laptop at speeds up to 10 Gbps with USB A 3.2 port. Extra 2 USB A 2.0 ports are perfectly for your keyboards and mouse.

Expand the test matrix when the goal requires broader confidence: for example, when validating all zone mappings, weight boundaries, flag combinations, or exceptional inputs. Those additional cases should be designed around the intended contract and risk, rather than added merely to make this narrow extraction appear comprehensive.

There is another limit: characterization tests preserve behavior, including known bugs. If an existing surcharge or quote is wrong, freezing its output makes that behavior visible and stable during this refactor; it does not turn the behavior into an approved business rule. Correcting it should be a separately reviewed product change with deliberately updated expectations.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When should you use a different approach?

Do not use this three-row gate as the entire plan when the work changes what customers are charged, depends on live rating calls, or involves fixtures nobody can review. Each requires a different kind of evidence and approval.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Intentional price change: define the new expected behavior and obtain the relevant product approval. Keep that change distinct from a behavior-preserving helper extraction so reviewers can see exactly why cents changed.
  • Live-network rating: a frozen local test does not validate a carrier’s live response, availability, or rate-card changes. Treat those as separate integration concerns.
  • Unreviewable fixture: if nobody can explain where the inputs or expected cents came from, do not treat them as a trustworthy contract. Reproduce them from the unchanged function and make the case understandable.
  • Broader correctness audit: add coverage for the relevant branches and validate the business rules independently; the three rows alone do not establish taxes, duties, address correctness, or carrier-rate accuracy.

The workflow’s claim is intentionally narrow: three frozen quotes can gate one surcharge move. It cannot approve a rate card or prove that the quote is correct outside the recorded cases.

Also popular on Amazon
𝟒𝐏𝐚𝐜𝐤 𝐔𝐩𝐠𝐫𝐚𝐝𝐞𝐝 USB to USB C Adapter,Type-C Female to A Male Charger Converter for iPhone 18 Charger,iWatch Ultra SE 9 10,iPhone 17 Pro Max 16 15 14,Samsung S25,AirPods,iPad,Car,Xbox
  • 【Read before You Buy】 Note: This adapter is USB 2.0 version and cannot transmit HDM, VGA, or other video signals. Nevertheless, they are fully capable of charging devices,duplicating files, and can be seamlessly integrated with USB-C earphones, wireless network adapters, and SD card adapters.
  • 【Easy to Use and Safe】Thanks to modern manufacturing techniques, we've made these adapters sufficiently compact so that they can remain inserted in your device without noticeable protrusion or inconvenience. This means you don't have to constantly plug and unplug them, reducing the likelihood of wear and misalignment, and making them more convenient to carry around.
  • 【Reliable Quality】Engineered for enhanced durability, durable aluminum alloy shell material,get excellent wear resistance and heat dissipation,the male USB C and female USB connectors & the male USB and female USB C connectors are designed to be plugged and unplugged up to 20000 times. Provides data transfer, device charging, memory space expansion, and additional computer peripherals.
  • 【Think more for you】Do you need to connect a USB-C-enabled device to an odd device that only has USB-A ports? Then these USB-A male to USB-C female adapters are made for you.Simply insert the adapter into the USB-A port on the device, and you can instantly connect your USB-C device to the device that originally didn't have the correct connection port.
  • 【Trusted xiwxi Quality and Service】As a responsible brand seller, you will receive xiwxi's 12-month Quality assurance and lifetime friendly customer service, you're not just buying a product,you're investing in peace of mind with all-round quality and exceptional customer service.

Frequently Asked Questions

Should these quote fixtures include the date as well as the inputs?

If a date or clock value can affect the public function’s result, make the time dependency explicit or controlled in the test setup. Otherwise a test may vary for reasons unrelated to the surcharge extraction; the sample’s leftover AS_OF read is a reminder to inspect time-dependent inputs.

Can I test the new surcharge helper directly too?

A focused helper test can clarify its weight-threshold behavior, especially when those boundaries matter. It complements rather than replaces the public-function cases, which check the final quote after the helper is integrated.

Should the fixture use decimal dollars or integer cents?

Use the same representation the public function returns and the quote contract specifies. In this example, the outputs are integer cents, so assertions should not silently convert them to rounded decimal currency.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply. Prices as of November 8, 2026 12:27 am GMT.