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)]
评论列表
文章目录