コード例 #1
0
 def test_find_correct_coordinates(self):
     """
     Implements seeding to assert that find_new_coordinates returns
     correct location for the animal to move to.
     """
     numpy.random.seed(1)
     test_population_for_coords = [{
         "species": "Herbivore",
         "age": 1,
         "weight": 10.0
     }]
     test_properties_for_coords = {
         "species": "Herbivore",
         "age": 1,
         "weight": 10
     }
     neighbours_for_coords = {
         (1, 2): Jungle(test_population_for_coords),
         (2, 1): Jungle(test_population_for_coords),
         (2, 3): Jungle(test_population_for_coords),
         (3, 2): Jungle(test_population_for_coords)
     }
     for jungle in neighbours_for_coords.values():
         jungle.regrowth()
     herbivore = Herbivore(test_properties_for_coords)
     assert herbivore.find_new_coordinates(neighbours_for_coords) == (2, 1)
コード例 #2
0
 def test_animal_will_move_to_tuple_coordinates(self, example_population,
                                                example_properties):
     """
     Asserts that the where_will_animal_move method returns a tuple.
     """
     neighbours_for_tuple = {
         (1, 2): Jungle(example_population),
         (2, 1): Jungle(example_population),
         (2, 3): Jungle(example_population),
         (3, 2): Jungle(example_population)
     }
     for jungle in neighbours_for_tuple.values():
         jungle.regrowth()
     herbivore = Herbivore(example_properties)
     assert type(
         herbivore.find_new_coordinates(neighbours_for_tuple)) is tuple