Exemplo n.º 1
0
 def test_destination_none(self):
     elena_backend_object = ElenaBackend('minimize', self.graph)
     with self.assertRaises(Exception) as context:
         elena_backend_object.find_actual_origin_and_destination(
             "Mars", None)
     self.assertTrue("Empty String or None provided as destination" in str(
         context.exception))
Exemplo n.º 2
0
 def test_wrong_criteria_compute_route(self):
     elena_backend_object = ElenaBackend('minimize', self.graph)
     origin, destination = elena_backend_object.find_actual_origin_and_destination(
         "Brandywine Amherst MA", "UMass Amherst")
     with self.assertRaises(Exception) as context:
         elena_backend_object.compute_route_by_criteria(
             origin, destination, "size")
     self.assertTrue(
         "Incorrect value of criteria provided" in str(context.exception))
Exemplo n.º 3
0
 def test_none_destination_compute_route(self):
     elena_backend_object = ElenaBackend('minimize', self.graph)
     origin, destination = elena_backend_object.find_actual_origin_and_destination(
         "Brandywine Amherst MA", "UMass Amherst")
     with self.assertRaises(Exception) as context:
         elena_backend_object.compute_route_by_criteria(
             origin, None, "length")
     self.assertTrue(
         "Empty string or None provided as destination for computing route"
         in str(context.exception))
Exemplo n.º 4
0
    def test_correct_route_compute_route_information(self):
        elena_backend_object = ElenaBackend('minimize', self.graph)
        origin, destination = elena_backend_object.find_actual_origin_and_destination(
            "Brandywine Amherst MA", "UMass Amherst")
        shortest_route_by_length = elena_backend_object.compute_route_by_criteria(
            origin, destination, criteria='length')

        self.assertIsNotNone(
            elena_backend_object.compute_route_information(
                shortest_route_by_length))
Exemplo n.º 5
0
    def test_correct_values_compute_route(self):
        elena_backend_object = ElenaBackend('minimize', self.graph)
        origin, destination = elena_backend_object.find_actual_origin_and_destination(
            "Brandywine Amherst MA", "UMass Amherst")

        self.assertIsNotNone(
            elena_backend_object.compute_route_by_criteria(
                origin, destination, "length"))
        self.assertIsNotNone(
            elena_backend_object.compute_route_by_criteria(
                origin, destination, "impedance"))
Exemplo n.º 6
0
def get_data(origin, destination, elevation_type, transportation_method):
    """Function called when front-end makes an API request.
    Args:
        origin (string): User given origin
        destination (string): User given destination
        elevation_type(string): Type of elevation (minimize, uphills, downhills)
        transportation_method (string): This is not included in this version and is left for future implementation

    Returns:
        combined_information (json): This is sent to the front-end and includes the route and all the associated
        information
        """
    elena_backend_object = ElenaBackend(elevation_type, graph)
    actual_origin, actual_destination = elena_backend_object.find_actual_origin_and_destination(origin, destination)
    shortest_route_by_length = elena_backend_object.compute_route_by_criteria(actual_origin, actual_destination,
                                                                              criteria='length')
    shortest_route_by_impedance = elena_backend_object.compute_route_by_criteria(actual_origin, actual_destination,
                                                                                 criteria='impedance')

    shortest_route_information = elena_backend_object.compute_route_information(shortest_route_by_length)
    elevation_route_information = elena_backend_object.compute_route_information(shortest_route_by_impedance)
    combined_information = {'shortest_path_route_stats': shortest_route_information,
                            'elevation_route_stats': elevation_route_information}

    return jsonify(combined_information)
Exemplo n.º 7
0
 def test_correct_origin_destination(self):
     elena_backend_object = ElenaBackend('minimize', self.graph)
     origin, destination = elena_backend_object.find_actual_origin_and_destination(
         "Brandywine Amherst MA", "UMass Amherst")
     self.assertIsNotNone(origin)
     self.assertIsNotNone(destination)
Exemplo n.º 8
0
 def test_none_compute_route_information(self):
     elena_backend_object = ElenaBackend('minimize', self.graph)
     with self.assertRaises(Exception) as context:
         elena_backend_object.compute_route_information(None)
     self.assertTrue("Route nor provided while computing route information"
                     in str(context.exception))