def setUp(self): self.f1 = Tulip("Pink", 14, 100) self.f2 = Rose("White", 27, 200) self.f3 = Chamomile(26, 50) self.f4 = Chamomile(25, 50) f_set1 = FlowerSet([f1, f2, f3, f4]) self.f5 = Rose("Red", 27, 200) self.f6 = Chamomile(17, 50) f_set2 = TestFlowerSet([f5, f6])
def setUp(self): '''Create test objects''' self.alyssum = Flower( 'yellow', -4, 20.5 ) #All negative integers will be change into positive and all floats will be convert into ints self.tulip = Tulip('pink', 5, 120) self.rose = Rose('black', 10, 150) self.rose2 = Rose('yellow', 5, 200, 'hulthemia') self.rose3 = Rose.create_rose(175) self.chamomile = Chamomile('white', 20, 30, True) self.flowerset1 = FlowerSet([self.alyssum, self.tulip, self.rose2]) self.flowerset2 = FlowerSet() self.bucket1 = Bucket([self.flowerset1, self.flowerset2]) self.bucket2 = Bucket()
def test_flower_set(self): """ Test FlowerSet class """ rose = Rose('red', 10, 15) flowers = FlowerSet(rose, 101) self.assertEqual(flowers.display_flowers(), (('rose', 'red'), 1515)) self.assertEqual(flowers.get_price, 1515)
def test_flowers(self): """ Test Rose Tulip and Chamomile classes """ # Test Rose class # 4th attribute is season. When season is low, # the price is twice lower then in high season # season = 'high' should be set by default rose = Rose('red', 10, 150, 'low') self.assertEqual(rose, Rose('red', 10, '75')) self.assertIsInstance(rose, Flower) # Test Tulip class tulip = Tulip('red', -10, -150, 'low') self.assertEqual(tulip, Tulip('red', 10, 75)) # Test Chamomile class chamomile = Chamomile('blue', 'ten', -150, 'high') self.assertEqual(chamomile, Chamomile('blue', None, 150))
def test_bucket(self): """ Test Bucket class """ rose = Rose('red', 10, 15) rose2 = Rose('white', 12, 12) flowers = FlowerSet(rose, 51) flowers2 = FlowerSet(rose2, 50) # Test for Bucket functionality bucket = Bucket() bucket.add_flower_set(flowers) bucket.add_flower_set(flowers2) self.assertEqual(bucket.get_price, 1365) self.assertEqual(bucket.flowers_dict, { ('rose', 'red'): 765, ('rose', 'white'): 600 })
class TestFlower(unittest.TestCase): def setUp(self): self.f1 = Tulip("Pink", 14, 100) self.f2 = Rose("White", 27, 200) self.f3 = Chamomile(26, 50) self.f4 = Chamomile(25, 50) def test_color(self): self.assertEqual(self.f1.getColor(), "Pink") self.assertEqual(self.f2.getColor(), "White") self.assertEqual(self.f3.getColor(), "White") self.assertEqual(self.f4.getColor(), "White") def test_price(self): self.assertEqual(self.f1.getPrice(), 100) self.assertEqual(self.f2.getPrice(), 200) self.assertEqual(self.f3.getPrice(), 50) self.assertEqual(self.f4.getPrice(), 50) def test_petal_num(self): self.assertEqual(self.f1.getPetals(), 14) self.assertEqual(self.f2.getPetals(), 27) self.assertEqual(self.f3.getPetals(), 26) self.assertEqual(self.f4.getPetals(), 25)
def setUp(self): self.f1 = Tulip("Pink", 14, 100) self.f2 = Rose("White", 27, 200) self.f3 = Chamomile(26, 50) self.f4 = Chamomile(25, 50)
def sutUp(self): self.f1 = Tulip("Pink", 14, 100) self.f2 = Rose("White", 27, 200) self.f3 = Chamomile(26, 50) self.f4 = Chamomile(25, 50) f_set = FlowerSet([f1, f2, f3, f4])