def test_multiple_items(self):
     items = [Item(Goods.AGED_BRIE.value, 5, 10), Item("Item", 5, 10)]
     gilded_rose = GildedRose(items)
     gilded_rose.update_quality()
     self.assertEqual(11, items[0].quality)
     self.assertEqual(4, items[0].sell_in)
     self.assertEqual(9, items[1].quality)
     self.assertEqual(4, items[1].sell_in)
 def test_backstage_pass_quality_normal_increase(self):
     """
     Verify the increase of the backstage pass when
     no special conditions apply.
     """
     items = [Item(Goods.BACKSTAGE_PASS.value, 11, 20)]
     gilded_rose = GildedRose(items)
     gilded_rose.update_quality()
     self.assertEqual(21, items[0].quality)
    def test_update_items(self):
        items = [
            Item(name="+5 Dexterity Vest", sell_in=10, quality=20),
            Item(name="Aged Brie", sell_in=2, quality=0),
            Item(name="Elixir of the Mongoose", sell_in=5, quality=7),
            Item(name="Sulfuras, Hand of Ragnaros", sell_in=0, quality=80),
            Item(name="Sulfuras, Hand of Ragnaros", sell_in=-1, quality=80),
            Item(name="Backstage passes to a TAFKAL80ETC concert",
                 sell_in=15,
                 quality=20),
            Item(name="Backstage passes to a TAFKAL80ETC concert",
                 sell_in=10,
                 quality=49),
            Item(name="Backstage passes to a TAFKAL80ETC concert",
                 sell_in=5,
                 quality=49),
            Item(name="Conjured Mana Cake", sell_in=3, quality=6),
        ]

        gilded_rose = GildedRose(items)

        gilded_rose.update_quality()
        self.assertEqual(
            str(gilded_rose.items),
            "[+5 Dexterity Vest, 9, 19, Aged Brie, 1, 1, Elixir of the Mongoose, 4, 6, Sulfuras, Hand of Ragnaros, 0, "
            "80, Sulfuras, Hand of Ragnaros, -1, 80, Backstage passes to a TAFKAL80ETC concert, 14, 21, "
            "Backstage passes to a TAFKAL80ETC concert, 9, 50, Backstage passes to a TAFKAL80ETC concert, 4, 50, "
            "Conjured Mana Cake, 2, 4]")

        for _ in range(10):
            gilded_rose.update_quality()

        self.assertEqual(
            str(gilded_rose.items),
            "[+5 Dexterity Vest, -1, 8, Aged Brie, -9, 20, Elixir of the Mongoose, -6, 0, Sulfuras, "
            "Hand of Ragnaros, 0, 80, Sulfuras, Hand of Ragnaros, -1, 80, Backstage passes to a "
            "TAFKAL80ETC concert, 4, 38, Backstage passes to a TAFKAL80ETC concert, -1, 0, "
            "Backstage passes to a TAFKAL80ETC concert, -6, 0, Conjured Mana Cake, -8, 0]"
        )
 def test_item_sell_in_decrease(self):
     items = [Item("Item", 5, 20)]
     gilded_rose = GildedRose(items)
     gilded_rose.update_quality()
     self.assertEqual(4, items[0].sell_in)
 def test_backstage_pass_quality_drops_to_zero_after_sell_in(self):
     items = [Item(Goods.BACKSTAGE_PASS.value, 0, 20)]
     gilded_rose = GildedRose(items)
     gilded_rose.update_quality()
     self.assertEqual(0, items[0].quality)
 def test_backstage_pass_quality_increase_by_three_five_days_or_less(self):
     items = [Item(Goods.BACKSTAGE_PASS.value, 5, 20)]
     gilded_rose = GildedRose(items)
     gilded_rose.update_quality()
     self.assertEqual(23, items[0].quality)
 def test_aged_brie_quality_increases_twice_after_sell_in(self):
     items = [Item(Goods.AGED_BRIE.value, 0, 20)]
     gilded_rose = GildedRose(items)
     gilded_rose.update_quality()
     self.assertEqual(22, items[0].quality)
 def test_conjured_quality_decrease_twice(self):
     items = [Item(Goods.CONJURED.value, 11, 20)]
     gilded_rose = GildedRose(items)
     gilded_rose.update_quality()
     self.assertEqual(18, items[0].quality)
Esempio n. 9
0
 def test_zero(self):
     items = []
     rose = GildedRose(items)
     rose.update_quality()
     expect(rose.items).to(equal(items))
 def test_sulfuras_never_sell_in(self):
     items = [Item(Goods.SULFURAS.value, 5, 80)]
     gilded_rose = GildedRose(items)
     gilded_rose.update_quality()
     self.assertEqual(5, items[0].sell_in)
 def test_maximum_quality(self):
     items = [Item(Goods.AGED_BRIE.value, 0, 50)]
     gilded_rose = GildedRose(items)
     gilded_rose.update_quality()
     self.assertEqual(50, items[0].quality)
 def test_quality_degrades_twice_after_sell_in(self):
     items = [Item("Item", 0, 10)]
     gilded_rose = GildedRose(items)
     gilded_rose.update_quality()
     self.assertEqual(8, items[0].quality)
 def test_quality_never_negative(self):
     items = [Item("Item", 5, 0)]
     gilded_rose = GildedRose(items)
     gilded_rose.update_quality()
     self.assertEqual(0, items[0].quality)
 def test_conjured_quality_never_negative(self):
     items = [Item(Goods.CONJURED.value, 0, 0)]
     gilded_rose = GildedRose(items)
     gilded_rose.update_quality()
     self.assertEqual(0, items[0].quality)
 def test_conjured_quality_decrease_by_four_after_sell_in(self):
     items = [Item(Goods.CONJURED.value, 0, 20)]
     gilded_rose = GildedRose(items)
     gilded_rose.update_quality()
     self.assertEqual(16, items[0].quality)
 def test_sulfuras_quality_never_degrades(self):
     items = [Item(Goods.SULFURAS.value, 5, 80)]
     gilded_rose = GildedRose(items)
     gilded_rose.update_quality()
     self.assertEqual(80, items[0].quality)
 def test_aged_brie_quality_increase(self):
     items = [Item(Goods.AGED_BRIE.value, 5, 20)]
     gilded_rose = GildedRose(items)
     gilded_rose.update_quality()
     self.assertEqual(21, items[0].quality)
Esempio n. 18
0
    print("OMGHAI!")
    items = [
        Item(name="+5 Dexterity Vest", sell_in=10, quality=20),
        Item(name="Aged Brie", sell_in=2, quality=0),
        Item(name="Elixir of the Mongoose", sell_in=5, quality=7),
        Item(name="Sulfuras, Hand of Ragnaros", sell_in=0, quality=80),
        Item(name="Sulfuras, Hand of Ragnaros", sell_in=-1, quality=80),
        Item(name="Backstage passes to a TAFKAL80ETC concert",
             sell_in=15,
             quality=20),
        Item(name="Backstage passes to a TAFKAL80ETC concert",
             sell_in=10,
             quality=49),
        Item(name="Backstage passes to a TAFKAL80ETC concert",
             sell_in=5,
             quality=49),
        Item(name="Conjured Mana Cake", sell_in=3, quality=6),  # <-- :O
    ]

    days = 2
    import sys
    if len(sys.argv) > 1:
        days = int(sys.argv[1]) + 1
    for day in range(days):
        print("-------- day %s --------" % day)
        print("name, sellIn, quality")
        for item in items:
            print(item)
        print("")
        GildedRose(items).update_quality()
Esempio n. 19
0
from mamba import description, it
from expects import expect, equal

from gilded_rose.gilded_rose import GildedRose

with description('GildedRose') as self:
    with it('should do nothing if it has no items'):
        items = []
        rose = GildedRose(items)
        rose.update_quality()
        expect(rose.items).to(equal(items))