當前位置: 首頁>>代碼示例>>Python>>正文


Python gilded_rose.GildedRose類代碼示例

本文整理匯總了Python中gilded_rose.GildedRose的典型用法代碼示例。如果您正苦於以下問題:Python GildedRose類的具體用法?Python GildedRose怎麽用?Python GildedRose使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了GildedRose類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_foo

 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,代碼行數:7,代碼來源:test_gilded_rose.py

示例2: test_quality_is_never_negative

 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,代碼行數:7,代碼來源:test_gilded_rose.py

示例3: test_QualityMax

	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,代碼行數:32,代碼來源:test_gilded_rose.py

示例4: Item

    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,代碼行數:7,代碼來源:test_gilded_rose.py

示例5: test_quality_zero_for_backstage_passes_and_brie_when_we_have_passed_the_sell_in_date

    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,代碼行數:7,代碼來源:test_gilded_rose.py

示例6: test_backstage

 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,代碼行數:32,代碼來源:test_gilded_rose.py

示例7: test_QualityBrie

	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,代碼行數:9,代碼來源:test_gilded_rose.py

示例8: test_modified

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,代碼行數:9,代碼來源:test_gilded_rose.py

示例9: test_decreses_by_one_the_quality_and_sell_in_for_regular_items

    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,代碼行數:10,代碼來源:test_gilded_rose.py

示例10: test_decreases_the_quality_of_the_rpoducts_twice_as_fast_when_we_have_passed_the_sell_in_date

    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,代碼行數:10,代碼來源:test_gilded_rose.py

示例11: test_Sulfuras

	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,代碼行數:10,代碼來源:test_gilded_rose.py

示例12: test_increases_quality_by_one_for_products_that_get_better_as_they_age

    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,代碼行數:10,代碼來源:test_gilded_rose.py

示例13: test_past_date

 def test_past_date(self):
     items = [
         Item("Regular thing", 0, 4),
         Item("Other thing", 1, 2),
         Item("Widget 33", 1, 5)
         ]
     gilded_rose = GildedRose(items)
     gilded_rose.update_quality()
     self.assertEqual(2, gilded_rose.items[0].quality)
     self.assertEqual(1, gilded_rose.items[1].quality)
     self.assertEqual(4, gilded_rose.items[2].quality)
     gilded_rose.update_quality()
     self.assertEqual(0, gilded_rose.items[0].quality)
     self.assertEqual(0, gilded_rose.items[1].quality)
     self.assertEqual(2, gilded_rose.items[2].quality)
開發者ID:SamNazar,項目名稱:gilded-rose-refactoring,代碼行數:15,代碼來源:test_gilded_rose.py

示例14: test_brie

 def test_brie(self):
     items = [Item("Aged Brie", 2, 46)]
     gilded_rose = GildedRose(items)
     gilded_rose.update_quality()
     self.assertEqual("Aged Brie", gilded_rose.items[0].name)
     self.assertEqual(47, gilded_rose.items[0].quality)
     gilded_rose.update_quality()
     self.assertEqual(48, gilded_rose.items[0].quality)
     gilded_rose.update_quality() #increase by 2 now
     self.assertEqual(50, gilded_rose.items[0].quality)
     gilded_rose.update_quality()
     self.assertEqual(50, gilded_rose.items[0].quality)
開發者ID:SamNazar,項目名稱:gilded-rose-refactoring,代碼行數:12,代碼來源:test_gilded_rose.py

示例15: test_QualityConjured

	def test_QualityConjured(self):
		items = [Item(name="Conjured Mana Cake", sell_in=10, quality=6),
				Item(name="Conjured Mana Cake", sell_in=-10, quality=6)]
		gilded_rose = GildedRose(items)
		qualities_pre = gilded_rose.Qualities()
		gilded_rose.update_quality()
		qualities_post = gilded_rose.Qualities()
		
		#Sell-In >=0
		default_conj_dec = 2 * gilded_rose.default_qual_dec
		self.assertEqual(qualities_pre[0] - qualities_post[0], default_conj_dec, \
							"Invalid Conjured item default decrement")

		#Sell-In < 0
		overdue_conj_dec = 4 * gilded_rose.default_qual_dec
		self.assertEqual(qualities_pre[1] - qualities_post[1], overdue_conj_dec, \
							"Invalid Conjured item overdue decrement")
開發者ID:mattphillipsphd,項目名稱:GildedRose-Refactoring-Kata,代碼行數:17,代碼來源:test_gilded_rose.py


注:本文中的gilded_rose.GildedRose類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。