def test_can_birth_occur_with_1_herbivore(self): """Test to see that birth will not occur for only 1 animal """ loc = (2, 7) i_sim = Island() a_sim = Herbivore(i_sim, loc) i_sim.add_pop_on_loc(loc, a_sim) assert not a_sim.can_birth_occur()
def test_can_birth_occur_with_2_herbivores_with_0_prob(self, mocker): """Test to show that 2 herbivores will not give birth if the probability is mocked to highest possible value. """ mocker.patch('random.random', return_value=1) loc = (2, 7) i_sim = Island() a_sim = Herbivore(i_sim, loc, weight=100) for _ in range(2): i_sim.add_pop_on_loc(loc, a_sim) assert not a_sim.can_birth_occur()
def test_add_and_remove_pop_on_locs(self): """Tests if the add and remove pop on loc methods can add and remove a sample of animals in the pop lists. """ i = Island() loc_1 = (1, 8) loc_2 = (2, 7) animal_list = [Herbivore(i, loc_1), Carnivore(i, loc_1)] for animal in animal_list: new_cell = i.island_dict[loc_2] old_cell = i.island_dict[loc_1] i.add_pop_on_loc(loc_2, animal) i.remove_pop_on_loc(loc_1, animal) if animal.__class__.__name__ == "Herbivore": assert animal in new_cell.herb_pop_list assert animal not in old_cell.herb_pop_list elif animal.__class__.__name__ == "Carnivore": assert animal in new_cell.carn_pop_list assert animal not in old_cell.carn_pop_list