当前位置: 首页>>代码示例>>Python>>正文


Python GildedRose.update_quality方法代码示例

本文整理汇总了Python中gilded_rose.GildedRose.update_quality方法的典型用法代码示例。如果您正苦于以下问题:Python GildedRose.update_quality方法的具体用法?Python GildedRose.update_quality怎么用?Python GildedRose.update_quality使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gilded_rose.GildedRose的用法示例。


在下文中一共展示了GildedRose.update_quality方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Item

# 需要导入模块: from gilded_rose import GildedRose [as 别名]
# 或者: from gilded_rose.GildedRose import update_quality [as 别名]
    def test_increases_the_quality_by_three_of_the_products_that_get_better_as_they_age_when_there_are_5_days_or_less_left(self):
        item = Item("Backstage passes to a TAFKAL80ETC concert", 5, 15)

        gilded_rose = GildedRose([item])
        gilded_rose.update_quality()

        self._assert_quality_and_sell_in(item, sell_in=4, quality=18)
开发者ID:eferro,项目名称:python_gilded_rose_kata,代码行数:9,代码来源:test_gilded_rose.py

示例2: test_foo

# 需要导入模块: from gilded_rose import GildedRose [as 别名]
# 或者: from gilded_rose.GildedRose import update_quality [as 别名]
 def test_foo(self):
     items = [Item("foo", 0, 0)]
     gilded_rose = GildedRose(items)
     gilded_rose.update_quality()
     self.assertEquals("foo", items[0].name)
     self.assertEqual(0, items[0].quality)
     self.assertEqual(-1, items[0].sell_in)
开发者ID:claremacrae,项目名称:GildedRose-Refactoring-Kata,代码行数:9,代码来源:test_gilded_rose.py

示例3: test_QualityMax

# 需要导入模块: from gilded_rose import GildedRose [as 别名]
# 或者: from gilded_rose.GildedRose import update_quality [as 别名]
	def test_QualityMax(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="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)

		#We test by running update on the input items until either 
		#	1) quality has stabilized (success)
		#	2) quality of any item exceeds 50 (failure)
		#	3) 100 iterations have taken place (failure)
		is_stable = False
		num_iterations = 0
		max_num_iters = 100
		qualities_prev = gilded_rose.Qualities()
		while not is_stable:			
			num_iterations += 1
			self.assertLessEqual(num_iterations, max_num_iters, \
									"Quality not stabilized after " + str(max_num_iters) + " iterations")
			
			gilded_rose.update_quality()
			qualities = gilded_rose.Qualities()
			is_stable = True
			for q, qp in zip(qualities, qualities_prev):
				self.assertLessEqual(q, gilded_rose.quality_max, "Quality exceeds max allowed")
				if q != qp:
					is_stable = False;
			qualities_prev = qualities
开发者ID:mattphillipsphd,项目名称:GildedRose-Refactoring-Kata,代码行数:34,代码来源:test_gilded_rose.py

示例4: test_quality_zero_for_backstage_passes_and_brie_when_we_have_passed_the_sell_in_date

# 需要导入模块: from gilded_rose import GildedRose [as 别名]
# 或者: from gilded_rose.GildedRose import update_quality [as 别名]
    def test_quality_zero_for_backstage_passes_and_brie_when_we_have_passed_the_sell_in_date(self):
        item = Item("Backstage passes to a TAFKAL80ETC concert", 0, 20)

        gilded_rose = GildedRose([item])
        gilded_rose.update_quality()

        self._assert_quality_and_sell_in(item, sell_in=-1, quality=0)
开发者ID:eferro,项目名称:python_gilded_rose_kata,代码行数:9,代码来源:test_gilded_rose.py

示例5: test_backstage

# 需要导入模块: from gilded_rose import GildedRose [as 别名]
# 或者: from gilded_rose.GildedRose import update_quality [as 别名]
 def test_backstage(self):
     items = [
         Item("Backstage passes to a TAFKAL80ETC concert", 11, 30),
         Item("Backstage passes to a TAFKAL80ETC concert", 10, 30),
         Item("Backstage passes to a TAFKAL80ETC concert", 6, 30),
         Item("Backstage passes to a TAFKAL80ETC concert", 5, 30),
         Item("Backstage passes to a TAFKAL80ETC concert", -1, 30)
         ]
     gilded_rose = GildedRose(items)
     gilded_rose.update_quality()
     self.assertEqual(31, gilded_rose.items[0].quality)
     self.assertEqual(32, gilded_rose.items[1].quality)
     self.assertEqual(32, gilded_rose.items[2].quality)
     self.assertEqual(33, gilded_rose.items[3].quality)
     self.assertEqual(0, gilded_rose.items[4].quality)
     self.assertEqual(10, gilded_rose.items[0].sell_in)
     self.assertEqual(9, gilded_rose.items[1].sell_in)
     self.assertEqual(5, gilded_rose.items[2].sell_in)
     self.assertEqual(4, gilded_rose.items[3].sell_in)
     self.assertEqual(-2, gilded_rose.items[4].sell_in)
     # one more day
     gilded_rose.update_quality()
     self.assertEqual(33, gilded_rose.items[0].quality)
     self.assertEqual(34, gilded_rose.items[1].quality)
     self.assertEqual(35, gilded_rose.items[2].quality)
     self.assertEqual(36, gilded_rose.items[3].quality)
     self.assertEqual(0, gilded_rose.items[4].quality)
     self.assertEqual(9, gilded_rose.items[0].sell_in)
     self.assertEqual(8, gilded_rose.items[1].sell_in)
     self.assertEqual(4, gilded_rose.items[2].sell_in)
     self.assertEqual(3, gilded_rose.items[3].sell_in)
     self.assertEqual(-3, gilded_rose.items[4].sell_in)
开发者ID:SamNazar,项目名称:gilded-rose-refactoring,代码行数:34,代码来源:test_gilded_rose.py

示例6: test_quality_is_never_negative

# 需要导入模块: from gilded_rose import GildedRose [as 别名]
# 或者: from gilded_rose.GildedRose import update_quality [as 别名]
 def test_quality_is_never_negative(self):
     items = [ItemFactory("foo", 3, 1)]
     gilded_rose = GildedRose(items)
     gilded_rose.update_quality()
     self.assertTrue(items[0].quality == 0)
     gilded_rose.update_quality()
     self.assertTrue(items[0].quality == 0)
开发者ID:Nikolao,项目名称:kata,代码行数:9,代码来源:test_gilded_rose.py

示例7: test_quality_decreases_faster_after_date_passed

# 需要导入模块: from gilded_rose import GildedRose [as 别名]
# 或者: from gilded_rose.GildedRose import update_quality [as 别名]
 def test_quality_decreases_faster_after_date_passed(self):
     items = [ItemFactory("foo", 2, 4)]
     gilded_rose = GildedRose(items)
     gilded_rose.update_quality()
     self.assertEquals(3, items[0].quality)
     gilded_rose = GildedRose(items)
     gilded_rose.update_quality()
     self.assertEquals(1, items[0].quality)
开发者ID:Nikolao,项目名称:kata,代码行数:10,代码来源:test_gilded_rose.py

示例8: test_modified

# 需要导入模块: from gilded_rose import GildedRose [as 别名]
# 或者: from gilded_rose.GildedRose import update_quality [as 别名]
def test_modified(item, tstexpect):
    gr = GildedRose(list([item]))
    print(gr.items)

    for expected in tstexpect:
        gr.update_quality()
        ref = gr.items[0]
        print(expected, ref.sell_in, ref.quality)
        assert expected == [ref.sell_in, ref.quality]
开发者ID:meantheory,项目名称:gildedrose,代码行数:11,代码来源:test_gilded_rose.py

示例9: test_QualityBrie

# 需要导入模块: from gilded_rose import GildedRose [as 别名]
# 或者: from gilded_rose.GildedRose import update_quality [as 别名]
	def test_QualityBrie(self):
		items = [Item(name="Aged Brie", sell_in=10, quality=0),
				Item(name="Aged Brie", sell_in=10, quality=0),
				]
		gilded_rose = GildedRose(items)
		gilded_rose.update_quality()
		qualities = gilded_rose.Qualities()
		for q in qualities:
			self.assertGreater(q, 0, "Brie quality did not increase")
开发者ID:mattphillipsphd,项目名称:GildedRose-Refactoring-Kata,代码行数:11,代码来源:test_gilded_rose.py

示例10: test_quality_never_negative

# 需要导入模块: from gilded_rose import GildedRose [as 别名]
# 或者: from gilded_rose.GildedRose import update_quality [as 别名]
 def test_quality_never_negative(self):
 	item1 = Item("food", 0, 1)
 	item2 = Item("food", 1, 0)
 	gilded_rose1 = GildedRose(item1)
 	gilded_rose2 = GildedRose(item2)
 	gilded_rose1.update_quality()
 	gilded_rose2.update_quality()
 	self.assertEqual(gilded_rose1.item.quality, 0)
 	self.assertEqual(gilded_rose2.item.quality, 0)
开发者ID:anishpdalal,项目名称:katas,代码行数:11,代码来源:test_gilded_rose.py

示例11: test_quality_fifty_threshold

# 需要导入模块: from gilded_rose import GildedRose [as 别名]
# 或者: from gilded_rose.GildedRose import update_quality [as 别名]
 def test_quality_fifty_threshold(self):
 	item1 = Item("Aged Brie", -2, 49.5)
 	item2 = Item("Aged Brie", -2, 49)
 	gilded_rose1 = GildedRose(item1)
 	gilded_rose2 = GildedRose(item2)
 	gilded_rose1.update_quality()
 	gilded_rose2.update_quality()
 	self.assertEqual(gilded_rose1.item.quality, 50)
 	self.assertEqual(gilded_rose2.item.quality, 50)
开发者ID:anishpdalal,项目名称:katas,代码行数:11,代码来源:test_gilded_rose.py

示例12: test_increases_quality_by_one_for_products_that_get_better_as_they_age

# 需要导入模块: from gilded_rose import GildedRose [as 别名]
# 或者: from gilded_rose.GildedRose import update_quality [as 别名]
    def test_increases_quality_by_one_for_products_that_get_better_as_they_age(self):
        items = [
                Item("Aged Brie", 20, 30),
                Item("Backstage passes to a TAFKAL80ETC concert", 20, 30)
        ]
        gilded_rose = GildedRose(items)
        gilded_rose.update_quality()

        self._assert_quality_and_sell_in(items[0], sell_in=19, quality=31)
        self._assert_quality_and_sell_in(items[1], sell_in=19, quality=31)
开发者ID:eferro,项目名称:python_gilded_rose_kata,代码行数:12,代码来源:test_gilded_rose.py

示例13: test_decreses_by_one_the_quality_and_sell_in_for_regular_items

# 需要导入模块: from gilded_rose import GildedRose [as 别名]
# 或者: from gilded_rose.GildedRose import update_quality [as 别名]
    def test_decreses_by_one_the_quality_and_sell_in_for_regular_items(self):
        items = [
                Item("+5 Dexterity Vest", 10, 20),
                Item("Conjured Mana Cake", 3,6)
        ]
        gilded_rose = GildedRose(items)
        gilded_rose.update_quality()

        self._assert_quality_and_sell_in(items[0], sell_in=9, quality=19)
        self._assert_quality_and_sell_in(items[1], sell_in=2, quality=5)
开发者ID:eferro,项目名称:python_gilded_rose_kata,代码行数:12,代码来源:test_gilded_rose.py

示例14: test_decreases_the_quality_of_the_rpoducts_twice_as_fast_when_we_have_passed_the_sell_in_date

# 需要导入模块: from gilded_rose import GildedRose [as 别名]
# 或者: from gilded_rose.GildedRose import update_quality [as 别名]
    def test_decreases_the_quality_of_the_rpoducts_twice_as_fast_when_we_have_passed_the_sell_in_date(self):
        items = [
                Item("+5 Dexterity Vest", 0, 20),
                Item("Conjured Mana Cake", 0, 6)
        ]
        gilded_rose = GildedRose(items)
        gilded_rose.update_quality()

        self._assert_quality_and_sell_in(items[0], sell_in=-1, quality=18)
        self._assert_quality_and_sell_in(items[1], sell_in=-1, quality=4)
开发者ID:eferro,项目名称:python_gilded_rose_kata,代码行数:12,代码来源:test_gilded_rose.py

示例15: test_Sulfuras

# 需要导入模块: from gilded_rose import GildedRose [as 别名]
# 或者: from gilded_rose.GildedRose import update_quality [as 别名]
	def test_Sulfuras(self):
		items = [Item(name="Sulfuras, Hand of Ragnaros", sell_in=0, quality=80)]
		gilded_rose = GildedRose(items)
		quality_pre = gilded_rose.Qualities()[0]
		sell_in_pre = gilded_rose.SellIns()[0]
		gilded_rose.update_quality()
		quality_post = gilded_rose.Qualities()[0]
		sell_in_post = gilded_rose.SellIns()[0]
		self.assertEqual(quality_pre, quality_post, "Sulfuras quality has changed")
		self.assertEqual(sell_in_pre, sell_in_post, "Sulfuras sell-in value changed")
开发者ID:mattphillipsphd,项目名称:GildedRose-Refactoring-Kata,代码行数:12,代码来源:test_gilded_rose.py


注:本文中的gilded_rose.GildedRose.update_quality方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。