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_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_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_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)