class TestChamomile(unittest.TestCase): def setUp(self): self.f1 = Chamomile(26, 50) self.f2 = Chamomile(25, 50) def test_loves_me(self): self.assertFalse(self.f1.lovesMe()) self.assertTrue(self.f2.lovesMe())
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 test_flower(): print('Testing flower class') fl = Tulip('green', 14, 100) assert (fl.getColor() == 'green') assert (fl.getPetalNum() == 14) assert (fl.getPrice() == 100) f2 = Tulip('red', 14, 100) f3 = Tulip("green", 14, 100) assert (f2 != f3) assert (fl == f3) assert (isinstance(f2, Flower)) assert (f2.getType() == 'Tulip') f4 = Chamomile(17, 160) f5 = Chamomile(18, 160) assert (f4.lovesMe() == True) assert (f5.lovesMe() == False) assert (f4.getColor() == 'white') f_set = FlowerSet([fl, f2, f3, f4, f5]) assert (f_set.getPrice() == 620) assert (f_set.getColors() == {'white', 'green', 'red'}) f_set1 = FlowerSet([fl, f2]) bckt = Bucket([f_set, f_set1]) assert (bckt.getPrice() == 820) print('done')
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 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()
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])
def setUp(self): self.f1 = Chamomile(26, 50) self.f2 = Chamomile(25, 50)