def test_best_by_category_no_matches_is_none(): item_a = Decor(condition=2.0) item_b = Decor(condition=2.0) item_c = Decor(condition=4.0) tai = Vendor(inventory=[item_a, item_b, item_c]) best_item = tai.get_best_by_category("Electronics") assert best_item is None
def test_best_by_category_with_duplicates(): item_a = Clothing(condition=2.0) item_b = Clothing(condition=4.0) item_c = Clothing(condition=4.0) tai = Vendor(inventory=[item_a, item_b, item_c]) best_item = tai.get_best_by_category("Clothing") assert best_item.category == "Clothing" assert best_item.condition == pytest.approx(4.0)
def test_best_by_category(): item_a = Clothing(condition=2.0) item_b = Decor(condition=2.0) item_c = Clothing(condition=4.0) item_d = Decor(condition=5.0) item_e = Clothing(condition=3.0) tai = Vendor(inventory=[item_a, item_b, item_c, item_d, item_e]) best_item = tai.get_best_by_category("Clothing") assert best_item.category == "Clothing" assert best_item.condition == pytest.approx(4.0)