예제 #1
0
 def test_zoo_tend_animal_no_budget(self):
     z = Zoo("Zoo", 250, 2, 2)
     z.add_animal(Lion("John", "m", 2), 100)
     z.add_animal(Tiger("Bill", "f", 4), 100)
     res = z.tend_animals()
     self.assertEqual(
         res, "You have no budget to tend the animals. They are unhappy.")
예제 #2
0
 def test_zoo_tend_animal_success(self):
     z = Zoo("Zoo", 500, 2, 2)
     z.add_animal(Lion("John", "m", 2), 100)
     z.add_animal(Tiger("Bill", "f", 4), 100)
     res = z.tend_animals()
     self.assertEqual(z._Zoo__budget, 205)
     self.assertEqual(
         res,
         "You tended all the animals. They are happy. Budget left: 205")
예제 #3
0
 def test_animal_status(self):
     z = Zoo("My Zoo", 500, 3, 3)
     z.add_animal(Lion("Leo", "Male", 3), 100)
     z.add_animal(Tiger("Tigy", "Female", 4), 100)
     z.add_animal(Cheetah("Chi", "Female", 2), 100)
     res = z.animals_status()
     self.assertEqual(
         res,
         "You have 3 animals\n----- 1 Lions:\nName: Leo, Age: 3, Gender: Male\n----- 1 Tigers:\nName: Tigy, Age: 4, Gender: Female\n----- 1 Cheetahs:\nName: Chi, Age: 2, Gender: Female"
     )
예제 #4
0
 def test_lion_repr(self):
     l = Lion("b", "f", 2)
     res = str(l)
     self.assertEqual(res, "Name: b, Age: 2, Gender: f")
예제 #5
0
 def test_lion_get_needs(self):
     l = Lion("b", "f", 2)
     res = l.get_needs()
     self.assertEqual(res, 50)
예제 #6
0
 def test_lion_init(self):
     l = Lion("a", "m", 4)
     self.assertEqual(l.name, "a")
     self.assertEqual(l.gender, "m")
     self.assertEqual(l.age, 4)
예제 #7
0
 def test_zoo_add_animal_no_space(self):
     z = Zoo("My Zoo", 1500, 0, 10)
     res = z.add_animal(Lion("Neo", "Male", 2), 1000)
     self.assertEqual(res, "Not enough space for animal")
     self.assertEqual(len(z.animals), 0)
     self.assertEqual(z._Zoo__budget, 1500)
예제 #8
0
 def test_zoo_add_animal_no_budget(self):
     z = Zoo("My Zoo", 500, 6, 10)
     res = z.add_animal(Lion("Neo", "Male", 2), 1000)
     self.assertEqual(res, "Not enough budget")
     self.assertEqual(len(z.animals), 0)
     self.assertEqual(z._Zoo__budget, 500)
예제 #9
0
 def test_zoo_add_animal_success(self):
     z = Zoo("My Zoo", 1500, 6, 10)
     res = z.add_animal(Lion("Neo", "Male", 2), 1000)
     self.assertEqual(res, "Neo the Lion added to the zoo")
     self.assertEqual(len(z.animals), 1)
     self.assertEqual(z._Zoo__budget, 500)