def test_fish_eat_snail(self):
     prey_fish = PreyFish(PreyFishPositive.FISH_NAME,
                          PreyFishPositive.MIN_WEIGHT)
     init_fish_weight = prey_fish.weight
     snail = Snail('test snail', 1.0)
     self.assertIs(prey_fish.eat(snail), None)
     self.assertNotIn(snail, prey_fish.eated)
     self.assertEqual(prey_fish.weight, init_fish_weight)
 def test_fish_eat_water_plant(self):
     prey_fish = PreyFish(PreyFishPositive.FISH_NAME,
                          PreyFishPositive.MIN_WEIGHT)
     init_fish_weight = prey_fish.weight
     plant = WaterPlant('test plant', 1.0)
     self.assertIs(prey_fish.eat(plant), plant)
     self.assertIn(plant, prey_fish.eated)
     self.assertEqual(prey_fish.weight, init_fish_weight + plant.weight)
 def test_fish_eat_fish(self):
     prey_fish = PreyFish(PreyFishPositive.FISH_NAME,
                          PreyFishPositive.MIN_WEIGHT)
     init_fish_weight = prey_fish.weight
     other_prey_fish = PreyFish('other fish', PreyFishPositive.MAX_WEIGHT)
     self.assertIs(prey_fish.eat(other_prey_fish), None)
     self.assertNotIn(other_prey_fish, prey_fish.eated)
     self.assertEqual(prey_fish.weight, init_fish_weight)
    def test_fish_eat_predator(self):
        prey_fish = PreyFish(PreyFishPositive.FISH_NAME,
                             PreyFishPositive.MIN_WEIGHT)
        init_prey_weight = prey_fish.weight
        predator_fish = PredatorFish('test predator', 10.0)
        init_predator_weight = predator_fish.weight

        self.assertIs(prey_fish.eat(predator_fish), prey_fish)
        self.assertNotIn(predator_fish, prey_fish.eated)
        self.assertEqual(prey_fish.weight, init_prey_weight)
        self.assertIn(prey_fish, predator_fish.eated)
        self.assertEqual(predator_fish.weight,
                         init_predator_weight + prey_fish.weight)
 def test_snail_eat_fish(self):
     snail = Snail(SnailPositive.SNAIL_NAME, SnailPositive.MAX_WEIGHT)
     init_snail_weight = snail.weight
     prey_fish = PreyFish('test fish', 2.0)
     self.assertIs(snail.eat(prey_fish), None)
     self.assertNotIn(prey_fish, snail.eated)
     self.assertEqual(snail.weight, init_snail_weight)
 def test_predator_eat_fish(self):
     predator = PredatorFish(PredatorFishPositive.FISH_NAME,
                             PredatorFishPositive.WEIGHT)
     init_predator_weight = predator.weight
     prey_fish = PreyFish('test fish', 2.0)
     self.assertIs(predator.eat(prey_fish), prey_fish)
     self.assertIn(prey_fish, predator.eated)
     self.assertEqual(predator.weight,
                      init_predator_weight + prey_fish.weight)
    def test_plant_do_not_eat_inhabitants(self):
        plant = WaterPlant(WaterPlantPositive.PLANT_NAME,
                           WaterPlantPositive.MIN_WEIGHT)
        init_plant_weight = plant.weight

        inhabitants = [
            WaterPlant('other plant', WaterPlantPositive.MAX_WEIGHT),
            PreyFish('test fish', 2.0),
            PredatorFish('test predator', 10.0),
            Snail('test snail', 1.0)
        ]

        [
            self.assertIs(plant.eat(inhabitant), None)
            for inhabitant in inhabitants
        ]

        self.assertEqual(plant.eated, [])
        self.assertEqual(plant.weight, init_plant_weight)
 def test_max_weight(self):
     prey_fish = PreyFish(PreyFishPositive.FISH_NAME,
                          PreyFishPositive.MAX_WEIGHT)
     self.assertEqual(prey_fish.weight, PreyFishPositive.MAX_WEIGHT)