Exemplo n.º 1
0
    def test_from_location(self):
        ref_point = Point(50.08746, 14.42125)

        with self.subTest("existing location"):
            with self.recorder.use_cassette('geo_location_existing'):
                self.assertLess(great_circle(Point.from_location(self.gc, "Prague"), ref_point).miles, 10)
                self.assertLess(great_circle(Point.from_location(self.gc, "Praha"), ref_point).miles, 10)
                self.assertLess(great_circle(Point.from_location(self.gc, "praha"), ref_point).miles, 10)

        with self.subTest("non-existing location"):
            with self.recorder.use_cassette('geo_location_nonexisting'):
                with self.assertRaises(GeocodeError):
                    Point.from_location(self.gc, "qwertzuiop")

        with self.subTest("empty request"):
            with self.recorder.use_cassette('geo_location_empty'):
                with self.assertRaises(GeocodeError):
                    Point.from_location(self.gc, "")
Exemplo n.º 2
0
    def test_from_location(self):
        ref_point = Point(50.08746, 14.42125)

        with self.subTest("existing location"):
            with self.recorder.use_cassette('geo_location_existing'):
                self.assertLess(great_circle(Point.from_location(self.gc, "Prague"), ref_point).miles, 10)
                self.assertLess(great_circle(Point.from_location(self.gc, "Praha"), ref_point).miles, 10)
                self.assertLess(great_circle(Point.from_location(self.gc, "praha"), ref_point).miles, 10)

        with self.subTest("non-existing location"):
            with self.recorder.use_cassette('geo_location_nonexisting'):
                with self.assertRaises(GeocodeError):
                    Point.from_location(self.gc, "qwertzuiop")

        with self.subTest("empty request"):
            with self.recorder.use_cassette('geo_location_empty'):
                with self.assertRaises(GeocodeError):
                    Point.from_location(self.gc, "")
Exemplo n.º 3
0
    def test_from_location(self):
        gc = Geocaching()
        gc.login(_username, _password)

        ref_point = Point(49.74774, 13.37752)

        with self.subTest("existing location"):
            self.assertLess(great_circle(Point.from_location(gc, "Pilsen"), ref_point).miles, 10)
            self.assertLess(great_circle(Point.from_location(gc, "Plzeň"), ref_point).miles, 10)
            self.assertLess(great_circle(Point.from_location(gc, "plzen"), ref_point).miles, 10)

        with self.subTest("non-existing location"):
            with self.assertRaises(GeocodeError):
                Point.from_location(gc, "qwertzuiop")

        with self.subTest("empty request"):
            with self.assertRaises(GeocodeError):
                Point.from_location(gc, "")
Exemplo n.º 4
0
    def test_from_location(self):
        gc = Geocaching()
        gc.login(_username, _password)

        ref_point = Point(49.74774, 13.37752)

        with self.subTest("existing location"):
            self.assertLess(
                great_circle(Point.from_location(gc, "Pilsen"),
                             ref_point).miles, 10)
            self.assertLess(
                great_circle(Point.from_location(gc, "Plzeň"),
                             ref_point).miles, 10)
            self.assertLess(
                great_circle(Point.from_location(gc, "plzen"),
                             ref_point).miles, 10)

        with self.subTest("non-existing location"):
            with self.assertRaises(GeocodeError):
                Point.from_location(gc, "qwertzuiop")

        with self.subTest("empty request"):
            with self.assertRaises(GeocodeError):
                Point.from_location(gc, "")
Exemplo n.º 5
0
    def geocode(self, location):
        """Return a :class:`.Point` object from geocoded location.

        :param str location: Location to geocode.
        """
        return Point.from_location(self, location)
Exemplo n.º 6
0
    def geocode(self, location):
        """Return a :class:`.Point` object from geocoded location.

        :param str location: Location to geocode.
        """
        return Point.from_location(self, location)