Exemple #1
0
    def test_birth_adds_to_num_carn_on_loc(self, mocker):
        """Test to show that birth method adds new pop to carn_pop list
        when birth occurs
        """
        mocker.patch('random.random', return_value=0)
        loc = (2, 7)
        i_sim = Island()
        a_sim_1 = Carnivore(i_sim, loc, weight=100)
        a_sim_2 = Carnivore(i_sim, loc, weight=100)

        a_sim_1.birth()

        assert i_sim.get_num_carn_on_loc(loc) == 3
    def test_get_num_animals_on_loc(self):
        """Tests if the get animals on location method can return the number
           of animals placed out on the map.
           """
        i = Island()
        num_herb = 4
        num_carn = 3
        loc = (2, 7)
        for _ in range(num_herb):
            Herbivore(i, loc)
        for _ in range(num_carn):
            Carnivore(i, loc)

        assert i.get_num_herb_on_loc(loc) == num_herb
        assert i.get_num_carn_on_loc(loc) == num_carn