polyline_walker_test.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:PokemonGo-Bot 作者: PokemonGoF 项目源码 文件源码
def setUp(self):
        self.patcherSleep = patch('pokemongo_bot.walkers.step_walker.sleep')
        self.patcherSleep.start()

        self.bot = MagicMock()
        self.bot.api = MagicMock()

        # let us get back the position set by the PolylineWalker
        def api_set_position(lat, lng, alt):
            self.bot.position = [lat, lng, alt]

        def hearbeat():
            return True

        self.bot.config.gmapkey = ''
        self.bot.api.set_position = api_set_position
        self.bot.heartbeat = hearbeat

        directions_path = os.path.join(os.path.dirname(__file__), 'resources', ex_resp_directions)
        with open(directions_path, 'rb') as directions:
            ex_directions = pickle.load(directions)
        elevations_path = os.path.join(os.path.dirname(__file__), 'resources', ex_resp_elevations)
        with open(elevations_path, 'rb') as elevations:
            ex_elevations = pickle.load(elevations)
        with requests_mock.Mocker() as m:
            m.get(
                "https://maps.googleapis.com/maps/api/directions/json?mode=walking&origin={},{}&destination={},{}".format(
                    ex_orig[0], ex_orig[1], ex_dest[0], ex_dest[1]
                ), json=ex_directions, status_code=200)
            m.get("https://maps.googleapis.com/maps/api/elevation/json?path=enc:{}&samples={}".format(
                ex_enc_polyline, ex_nr_samples
            ), json=ex_elevations, status_code=200)
            self.polyline = PolylineObjectHandler.cached_polyline(ex_orig, ex_dest)

        self.bot.position = [ex_orig[0], ex_orig[1], self.polyline.get_alt(ex_orig)]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号