def test_get_newest_item(): item_a = Item(age=3) item_b = Item(age=1) item_c = Item(age=2) fatimah = Vendor(inventory=[item_a, item_b, item_c]) newest_item = fatimah.get_newest_item() assert newest_item.age == pytest.approx(1.0)
def test_newest_item_with_duplicates(): item_a = Decor(year=1999) item_b = Electronics(year=1970) item_c = Clothing(year=1999) madison = Vendor(inventory=[item_a, item_b, item_c]) newest_item = madison.get_newest_item() assert newest_item.age == 22 assert newest_item.year == 1999
def test_get_newest_item(): item_a = Clothing(year=2005) item_b = Electronics(year=2002) item_c = Clothing(year=1955) item_d = Decor(year=1982) item_e = Clothing(year=2013) madison = Vendor(inventory=[item_a, item_b, item_c, item_d, item_e]) newest_item = madison.get_newest_item() assert newest_item.year == 2013 assert newest_item.age == 8 assert newest_item.category == "Clothing"
def test_get_newest_item_empty_inventory_is_none(): madison = Vendor(inventory=[]) newest_item = madison.get_newest_item() assert newest_item is None