Ejemplo n.º 1
0
    def test_distance_uk_driving_imperial(self):
        googlemaps = GoogleMaps(None)

        distance = googlemaps.get_distance_between_addresses("Edinburgh", "London", country="UK", mode="driving", units="imperial")
        self.assertIsNotNone(distance)
        self.assertIsInstance(distance, GoogleDistance)
        self.assertEqual("409 mi", distance._distance_text)
Ejemplo n.º 2
0
    def test_distance_uk_driving_imperial(self):
        googlemaps = GoogleMaps(None)

        distance = googlemaps.get_distance_between_addresses("Edinburgh", "London", country="UK", mode="driving", units="imperial")
        self.assertIsNotNone(distance)
        self.assertIsInstance(distance, GoogleDistance)
        self.assertEquals("409 mi", distance._distance_text)
Ejemplo n.º 3
0
    def test_distance_uk_driving_imperial(self):
        googlemaps = GoogleMaps(None)

        filename = os.path.dirname(__file__) + "/distance.json"
        # If this line fails, you need to generate test data using programy.utils.geo.google_geo.GoogleMaps static methods
        self.assertTrue(os.path.isfile(filename))

        googlemaps.set_response_file_for_get_distance_between_addresses(filename)

        distance = googlemaps.get_distance_between_addresses("Edinburgh", "London", country="UK", mode="driving", units="imperial")
        self.assertIsNotNone(distance)
        self.assertIsInstance(distance, GoogleDistance)
        self.assertEquals("25.1 mi", distance._distance_text)
Ejemplo n.º 4
0
    def execute(self, bot, clientid, data):
        logging.debug("GoogleMaps [%s]" % (data))

        splits = data.split(" ")
        command = splits[0]
        from_place = splits[1]
        to_place = splits[2]

        googlemaps = GoogleMaps()

        if command == "DISTANCE":
            distance = googlemaps.get_distance_between_addresses(
                from_place, to_place)
            return self._format_distance_for_programy(distance)
        elif command == "DIRECTIONS":
            directions = googlemaps.get_directions_between_addresses(
                from_place, to_place)
            return self._format_directions_for_programy(directions)
        else:
            return None

        return "OK"
Ejemplo n.º 5
0
    def execute(self, bot, clientid, data):
        if logging.getLogger().isEnabledFor(logging.DEBUG):
            logging.debug("GoogleMaps [%s]", data)

        splits = data.split(" ")
        command = splits[0]
        from_place = splits[1]
        to_place = splits[2]

        googlemaps = GoogleMaps(bot.license_keys)

        if command == "DISTANCE":
            distance = googlemaps.get_distance_between_addresses(
                from_place, to_place)
            return self._format_distance_for_programy(distance)
        elif command == "DIRECTIONS":
            directions = googlemaps.get_directions_between_addresses(
                from_place, to_place)
            return self._format_directions_for_programy(directions)
        else:
            if logging.getLogger().isEnabledFor(logging.ERROR):
                logging.error("Unknown Google Maps Extension command [%s]",
                              command)
            return None