Beispiel #1
0
def test_backstage_more_than_5_days_less_than_10_days_sell_date():
    item = Item(ItemEnum.BACKSTAGE, 6, 11)

    GildedRose([item]).update_quality()

    assert item.sell_in == 5
    assert item.quality == 13
Beispiel #2
0
 def test_item_conjured(self):
     items = [Item("Conjured Mana Cake", 3, 6)]
     gilded_rose = GildedRose(items)
     gilded_rose.update_quality()
     self.assertEqual("Conjured Mana Cake", items[0].name)
     self.assertEqual(2, items[0].sell_in)
     self.assertEqual(4, items[0].quality)
Beispiel #3
0
 def test_item_generic_sell_in_zero(self):
     items = [Item("+5 Dexterity Vest", 0, 20)]
     gilded_rose = GildedRose(items)
     gilded_rose.update_quality()
     self.assertEqual("+5 Dexterity Vest", items[0].name)
     self.assertEqual(-1, items[0].sell_in)
     self.assertEqual(18, items[0].quality)
Beispiel #4
0
def test_update_quality_normal_item_quality_not_negative():
    items = [Item(NORMAL, 1, 0)]
    gilded_rose = GildedRose(items)

    gilded_rose.update_quality()

    assert items[0].quality == 0
Beispiel #5
0
def test_update_quality_normal_item_quality_does_not_exceed_50():
    items = [Item(NORMAL, 1, 51)]
    gilded_rose = GildedRose(items)

    gilded_rose.update_quality()

    assert items[0].quality <= 50
Beispiel #6
0
 def test_update_expired_item_never_negative_quality(self):
     sell_in = 0
     quality = 0
     item = Item("becca", sell_in, quality)
     GildedRose([item]).update_item(item)
     self.assertEqual(item.sell_in, -1)
     self.assertEqual(item.quality, 0)
Beispiel #7
0
 def test_end_of_sellin(self):
     # decay is two times faster after sell-in date
     expected_decay = [(1, 9), (0, 8), (-1, 6), (-2, 4), (-3, 2)]
     self.assertDecayOverNDays(
         Item("foo", 2, 10),
         expected_decay
     )
Beispiel #8
0
def test_aged_brie_before_sell_date():
    item = Item(ItemEnum.BRIE, 5, 11)

    GildedRose([item]).update_quality()

    assert item.sell_in == 4
    assert item.quality == 12
Beispiel #9
0
def test_aged_brie_on_sell_date():
    item = Item(ItemEnum.BRIE, 0, 11)

    GildedRose([item]).update_quality()

    assert item.sell_in == -1
    assert item.quality == 13
Beispiel #10
0
def test_normal_item_after_sell_date():
    item = Item(ItemEnum.NORMAL, -1, 3)

    GildedRose([item]).update_quality()

    assert item.sell_in == -2
    assert item.quality == 1
Beispiel #11
0
def test_normal_item_of_maximum_quality():
    item = Item(ItemEnum.NORMAL, 5, 50)

    GildedRose([item]).update_quality()

    assert item.sell_in == 4
    assert item.quality == 49
Beispiel #12
0
def test_normal_item_on_sell_date():
    item = Item(ItemEnum.NORMAL, 0, 6)

    GildedRose([item]).update_quality()

    assert item.sell_in == -1
    assert item.quality == 4
Beispiel #13
0
def test_backstage_after_sell_date():
    item = Item(ItemEnum.BACKSTAGE, -1, 19)

    GildedRose([item]).update_quality()

    assert item.sell_in == -2
    assert item.quality == 0
Beispiel #14
0
def test_backstage_less_than_5_days_sell_date():
    item = Item(ItemEnum.BACKSTAGE, 2, 33)

    GildedRose([item]).update_quality()

    assert item.sell_in == 1
    assert item.quality == 36
Beispiel #15
0
 def test_update_item(self):
     sell_in = 5
     quality = 5
     item = Item("becca", sell_in, quality)
     GildedRose([item]).update_item(item)
     self.assertEqual(item.sell_in, 4)
     self.assertEqual(item.quality, 4)
Beispiel #16
0
def test_aged_brie_after_sell_date():
    item = Item(ItemEnum.BRIE, -1, 15)

    GildedRose([item]).update_quality()

    assert item.sell_in == -2
    assert item.quality == 17
Beispiel #17
0
 def test_update_expired_item(self):
     sell_in = 0
     quality = 3
     item = Item("becca", sell_in, quality)
     GildedRose([item]).update_item(item)
     self.assertEqual(item.sell_in, -1)
     self.assertEqual(item.quality, 1)
Beispiel #18
0
def test_aged_brie_of_maximum_quality():
    item = Item(ItemEnum.BRIE, 10, 50)

    GildedRose([item]).update_quality()

    assert item.sell_in == 9
    assert item.quality == 50
class TestSulfuras:
    """
    Test basic functionality: decrease sell_in by 1 and decrease quality by one
    GIVEN: GildedRose with one Item of type default
    WHEN: call update_quality method
    THEN: quality should be one less and sell_in should be one less
    """
    # sulfuras - always 80 quality and age doesn't decrease
    quality = 10
    sell_in = 20
    name = 'sulfuras'

    items = [Item(name, sell_in, quality)]

    @pytest.fixture(scope='class')
    def create_sulfuras(self):
        gilded_rose = GildedRose(self.items)
        gilded_rose.update_quality()

    def test_name(self, create_sulfuras):
        assert self.items[0].name == self.name

    def test_quality(self, create_sulfuras):
        assert self.items[0].quality == self.quality

    def test_sell_in(self, create_sulfuras):
        assert self.items[0].sell_in == self.sell_in
Beispiel #20
0
def test_aged_brie_of_zero_quality():
    item = Item(ItemEnum.BRIE, -1, 0)

    GildedRose([item]).update_quality()

    assert item.sell_in == -2
    assert item.quality == 2
Beispiel #21
0
def test_update_quality_normal_item_past_sell_in_quality_degrades_2x():
    items = [Item(NORMAL, 0, 2)]
    gilded_rose = GildedRose(items)

    gilded_rose.update_quality()

    assert items[0].quality == 0
Beispiel #22
0
def test_update_quality_name_is_found():
    items = [Item(NORMAL, 1, 2)]
    gilded_rose = GildedRose(items)

    gilded_rose.update_quality()

    assert items[0].name == NORMAL
Beispiel #23
0
def test_update_quality_normal_item_sell_in_decrements():
    items = [Item(NORMAL, 1, 2)]
    gilded_rose = GildedRose(items)

    gilded_rose.update_quality()

    assert items[0].sell_in == 0
Beispiel #24
0
 def test_backstage_pass(self):
     items = [Item("Backstage passes to a TAFKAL80ETC concert",11,39),
         Item("Backstage passes to a TAFKAL80ETC concert",10,39),
         Item("Backstage passes to a TAFKAL80ETC concert",5,39),
         Item("Backstage passes to a TAFKAL80ETC concert",0,39)
     ]
     gilded_rose = GildedRose(items)
     gilded_rose.update_quality()
     self.assertEquals(10, items[0].sell_in)
     self.assertEquals(40, items[0].quality)
     self.assertEquals(9, items[1].sell_in)
     self.assertEquals(41, items[1].quality)
     self.assertEquals(4, items[2].sell_in)
     self.assertEquals(42, items[2].quality)
     self.assertEquals(-1, items[3].sell_in)
     self.assertEquals(0, items[3].quality)
    def test_xxx(self):
        items = [Item("Book", 10, 5)]
        app = GildedRose(items)

        app.update_quality()

        self.assertEqual("Book", app.items[0].name)
def test_update_quality_brie_quality_does_not_exceed_50():
    items = [Item(BRIE, 1, 50)]
    gilded_rose = GildedRose(items)

    gilded_rose.update_quality()

    assert items[0].quality <= 50
Beispiel #27
0
 def test_item_conjured_sell_in_zero(self):
     items = [Item("Conjured +5 Dexterity Vest", 0, 6)]
     gilded_rose = GildedRose(items)
     gilded_rose.update_quality()
     self.assertEqual("Conjured +5 Dexterity Vest", items[0].name)
     self.assertEqual(-1, items[0].sell_in)
     self.assertEqual(2, items[0].quality)
def test_update_quality_brie_sell_in_decrements():
    items = [Item(BRIE, 1, 2)]
    gilded_rose = GildedRose(items)

    gilded_rose.update_quality()

    assert items[0].sell_in == 0
Beispiel #29
0
 def test_item_aged(self):
     items = [Item("Aged Brie", 2, 0)]
     gilded_rose = GildedRose(items)
     gilded_rose.update_quality()
     self.assertEqual("Aged Brie", items[0].name)
     self.assertEqual(1, items[0].sell_in)
     self.assertEqual(1, items[0].quality)
Beispiel #30
0
def test_backstage_10_days_sell_date():
    item = Item(ItemEnum.BACKSTAGE, 10, 22)

    GildedRose([item]).update_quality()

    assert item.sell_in == 9
    assert item.quality == 24