Created
June 1, 2024 08:06
-
-
Save emilybache/1d256d1b624382ef6ab2689965a0e29f to your computer and use it in GitHub Desktop.
Sample test code for python using approvals with all combinations to cover the Gilded Rose functionality
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import unittest | |
from approvaltests import combination_approvals | |
from gilded_rose import Item, GildedRose | |
class GildedRoseTest(unittest.TestCase): | |
def test_update_quality(self): | |
combination_approvals.verify_all_combinations( | |
do_update_quality, | |
[ | |
["foo", "Aged Brie", "Backstage passes to a TAFKAL80ETC concert", "Sulfuras, Hand of Ragnaros"], | |
[-1, 0, 5, 6, 10, 11], # sell_in | |
[0, 1, 2, 49, 50] # quality | |
] | |
) | |
def do_update_quality(name, sell_in, quality): | |
items = [Item(name, sell_in, quality)] | |
gilded_rose = GildedRose(items) | |
gilded_rose.update_quality() | |
return item_printer(items[0]) | |
def item_printer(item): | |
return f"{item.name} sellIn: {item.sell_in} quality: {item.quality}" | |
if __name__ == '__main__': | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment