def test_snail_eat_snail(self):
     snail = Snail(SnailPositive.SNAIL_NAME, SnailPositive.MAX_WEIGHT)
     init_snail_weight = snail.weight
     other_snail = Snail('other snail', 1.0)
     self.assertIs(snail.eat(other_snail), None)
     self.assertNotIn(other_snail, snail.eated)
     self.assertEqual(snail.weight, init_snail_weight)
 def test_snail_eat_water_plant(self):
     snail = Snail(SnailPositive.SNAIL_NAME, SnailPositive.MIN_WEIGHT)
     init_snail_weight = snail.weight
     plant = WaterPlant('test plant', 1.0)
     self.assertIs(snail.eat(plant), plant)
     self.assertIn(plant, snail.eated)
     self.assertEqual(snail.weight, init_snail_weight + plant.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_snail_eat_predator(self):
        snail = Snail(SnailPositive.SNAIL_NAME, SnailPositive.MAX_WEIGHT)
        init_snail_weight = snail.weight
        predator = PredatorFish('test predator', 10.0)

        self.assertIs(snail.eat(predator), None)
        self.assertNotIn(predator, snail.eated)
        self.assertEqual(snail.weight, init_snail_weight)
 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_predator_eat_snail(self):
     predator = PredatorFish(PredatorFishPositive.FISH_NAME,
                             PredatorFishPositive.WEIGHT)
     init_predator_weight = predator.weight
     snail = Snail('test snail', 1.0)
     self.assertIs(predator.eat(snail), None)
     self.assertNotIn(snail, predator.eated)
     self.assertEqual(predator.weight, init_predator_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):
     snail = Snail(SnailPositive.SNAIL_NAME, SnailPositive.MAX_WEIGHT)
     self.assertEqual(snail.weight, SnailPositive.MAX_WEIGHT)
 def test_min_weight(self):
     snail = Snail(SnailPositive.SNAIL_NAME, SnailPositive.MIN_WEIGHT)
     self.assertEqual(snail.weight, WaterPlantPositive.MIN_WEIGHT)