def test_eat_if_eaten(mocker):
    """Test that carnivores wont eat more meat than their parameter ['F'] says."""
    mocker.patch("numpy.random.random", return_value=0)
    carn = Carnivore(5, 20)
    herbs = [Herbivore(6, 20), Herbivore(6, 20), Herbivore(6, 20)]
    carn.eat(herbs)
    assert carn.weight == 57.5
def test_eat_if_eaten_enough_deltaphimax_low(mocker):
    """Test that the carnivores wont eat more that their parameter ['F'] when the difference in
    fitness is bigger than DeltaPhiMax"""
    mocker.patch("numpy.random.random", return_value=0)
    carn = Carnivore(5, 20)
    herbs = [Herbivore(6, 20), Herbivore(6, 20), Herbivore(6, 20)]
    carn.eat(herbs)
    assert carn.weight == 57.5
def test_eat_if_deltaphimax_low(mocker):
    """Test that if DeltaPhiMax parameter is lower than the difference in fitness, the carnivore
     eats"""
    mocker.patch("numpy.random.random", return_value=0)
    carn = Carnivore(5, 20)
    herb = [Herbivore(6, 20)]
    carn.set_params({"DeltaPhiMax": 0.0001})
    carn.eat(herb)
    assert carn.weight != 20
    assert carn.weight == 35
def test_fitness_herb_more_than_carn():
    """Test that the carnivore won't eat if the herbivore fitness is higher that the carnivores."""
    carn = Carnivore(2, 5)
    carn_weight = carn.weight
    herb = [Herbivore(6, 25), Herbivore(6, 25), Herbivore(6, 25)]

    assert carn.eat(herb)
    assert carn_weight == carn.weight
def test_eaten_enough():
    """Test that a carnivore won't eat if its parameter ['F'] is 0."""
    carn = Carnivore(5, 20)
    carn_weight = carn.weight
    herbs = [Herbivore(6, 20), Herbivore(6, 20), Herbivore(6, 20)]
    carn.set_params({"F": 0})

    assert carn.eat(herbs)
    assert carn.weight == carn_weight
def test_weight_gain_eating_carnivore(mocker):
    """Test that carnivores eat the right amount of meat and that dead herbivores get removed from
    from the list of alive herbivores."""
    mocker.patch("numpy.random.random", return_value=0)
    carn = Carnivore(5, 20)
    herb = [Herbivore(6, 20)]
    herb = carn.eat(herb)
    assert carn.weight != 20
    assert carn.weight == 35

    assert herb == []
 def test_eat(self):
     carnivore = Carnivore()
     carnivore.weight = 30
     carnivore.eat(1000, 0)
     assert carnivore.weight == 30 + carnivore.F * carnivore.beta
     carnivore.weight = 30
     carnivore.eat(10, 0)
     assert carnivore.weight == 30 + 10 * carnivore.beta
     carnivore.weight = 30
     carnivore.eat(1000, 45)
     assert carnivore.weight == 30 + 5 * carnivore.beta