Skip to content

VIN Discrepancies Problem


You run a car dealership . The inventory is tracked in two places: a database and a text file, each of which contain a set of Vehicle Identification Numbers (VINs).

They should have the same set of VINs (not necessarily in the same order).

Write a test that checks for discrepancies in the VINs. If differences exist, provide a useful message to the user for fixing them.

Directory Structure

vins/
  vins.txt
  vins.py
  test_vins.py

Files

WP0AA2991YS620631
1G4GJ11Y9HP422546
4T1BG22K8VU176482
JH4KA3151KC019450
1FTYR14U2XPC03940
JH4DC4340RS000837
JH4DA9340MS002938
JH4DB1660LS017594
1GCDC14K2LE198114
JH4NA1260MT001906
2FMDA5146TBC22506
def fetch_vins_from_db():
    """Pretend to fetch VINs from a database.."""

    vins = [
        "WP0AA2991YS620631",
        "JH4NA1150RT000268",
        "4T1BG22K8VU176482",
        "JH4KA3151KC019450",
        "1FTYR14U2XPC03940",
        "5GAEV23718J129013",
        "JH4DA9340MS002938",
        "JH4DB1660LS017594",
        "1GCDC14K2LE198114",
        "JH4NA1260MT001906",
        "JH4DA3441JS029234",
        "5TFUW5F13CX228552",
    ]

    return vins
from vins import fetch_vins_from_db

def test_vin_discrepancies():
    """Check for discrepancies in VINs between vins.txt and the database"""

    # your code here

See the solution