def test_delete_candle_removes_the_candle_from_list(): cat = Catalogue("2021 catalogue") candle1 = Candle("Beach", 54, "lavender", "square", "4 hours", "10cm by 10cm", "£100") candle2 = Candle("Beach", 2, "lavender", "square", "4 hours", "10cm by 10cm", "£100") cat.add_candle(candle1) cat.add_candle(candle2) cat.delete_candle(54) assert cat.candles_list == [candle2]
def test_delete_both_candles_gives_empty_list(): cat = Catalogue("2021 catalogue") candle1 = Candle("Beach", 54, "lavender", "square", "4 hours", "10cm by 10cm", "£100") candle2 = Candle("Beach", 2, "lavender", "square", "4 hours", "10cm by 10cm", "£100") cat.add_candle(candle1) cat.add_candle(candle2) cat.delete_candle(54) cat.delete_candle(2) assert cat.candles_list == []
def test_delete_candle_gives_error_if_candle_not_in_list(): cat = Catalogue("2021 catalogue") candle1 = Candle("Beach", 54, "lavender", "square", "4 hours", "10cm by 10cm", "£100") candle2 = Candle("Beach", 2, "lavender", "square", "4 hours", "10cm by 10cm", "£100") candle3 = Candle("Beach", 3, "lavender", "square", "4 hours", "10cm by 10cm", "£100") cat.add_candle(candle1) cat.add_candle(candle2) with pytest.raises(ValueError): cat.delete_candle(candle3) assert cat.candles_list == [candle1, candle2] with pytest.raises(ValueError) as error: cat.delete_candle(candle3) assert str(error.value) == "Item not found"