Beispiel #1
0
    def test_work_on_cells(self):
        bot = self._create_generic_bot({})
        bot.fire = Mock()

        poke1 = Pokemon({'id': 1})
        poke2 = Pokemon({'id': 2})
        poke3 = Pokemon({'id': 3})
        poke4 = Pokemon({'id': 4})
        poke5 = Pokemon({'id': 5})
        poke6 = Pokemon({'id': 6})
        pokestop1 = PokeStop({'id': 1})
        pokestop2 = PokeStop({'id': 2})
        pokestop3 = PokeStop({'id': 3})

        cell1 = Cell({})
        cell1.catchable_pokemon = [poke1, poke2]
        cell1.wild_pokemon = [poke3, poke4]
        cell1.pokestops = [pokestop1, pokestop2]

        cell2 = Cell({})
        cell2.catchable_pokemon = [poke5]
        cell2.wild_pokemon = [poke6]
        cell2.pokestops = [pokestop3]

        bot.work_on_cells([cell1, cell2])

        assert bot.fire.call_count == 2

        bot.fire.has_calls([
            call('pokemon_found',
                 encounters=[poke1, poke2, poke3, poke4, poke5, poke6]),
            call('pokestops_found',
                 encounters=[pokestop1, pokestop2, pokestop3])
        ])
Beispiel #2
0
    def test_work_on_cells(self):
        bot = self._create_generic_bot({})
        bot.fire = Mock()

        poke1 = Pokemon({'id': 1})
        poke2 = Pokemon({'id': 2})
        poke3 = Pokemon({'id': 3})
        poke4 = Pokemon({'id': 4})
        poke5 = Pokemon({'id': 5})
        poke6 = Pokemon({'id': 6})
        pokestop1 = PokeStop({'id': 1})
        pokestop2 = PokeStop({'id': 2})
        pokestop3 = PokeStop({'id': 3})

        cell1 = Cell({})
        cell1.catchable_pokemon = [poke1, poke2]
        cell1.wild_pokemon = [poke3, poke4]
        cell1.pokestops = [pokestop1, pokestop2]

        cell2 = Cell({})
        cell2.catchable_pokemon = [poke5]
        cell2.wild_pokemon = [poke6]
        cell2.pokestops = [pokestop3]

        bot.work_on_cells([cell1, cell2])

        assert bot.fire.call_count == 2

        bot.fire.has_calls([
            call('pokemon_found', encounters=[poke1, poke2, poke3, poke4, poke5, poke6]),
            call('pokestops_found', encounters=[pokestop1, pokestop2, pokestop3])
        ])
Beispiel #3
0
    def test_run(self):
        bot = self._create_generic_bot({})
        bot.api_wrapper.set_location(51.504154, -0.076304, 10)
        bot.stepper.current_lat = 51.504154
        bot.stepper.current_lng = -0.076304
        bot.stepper.current_alt = 10

        pgo = bot.api_wrapper.get_api()
        pgo.should_login = [False, False, True]
        pgo.set_response('get_player', self._create_generic_player_response())
        pgo.set_response('get_inventory',
                         self._create_generic_inventory_response())
        pgo.set_response('DOWNLOAD_REMOTE_CONFIG_VERSION',
                         self._create_generic_remote_config)

        bot.mapper.get_cells = Mock(return_value=[Cell({}), Cell({})])

        def navigator(cells):  # pylint: disable=unused-argument
            destinations = [
                Destination(51.504601, -0.075964, 10),
                Destination(51.505356, -0.075481, 11)
            ]
            for destination in destinations:
                yield destination

        bot.navigator.navigate = navigator

        def stepper_get_route_between(position_lat, position_lng, target_lat,
                                      target_lng, target_alt):
            return [(position_lat, position_lng, 0),
                    (position_lat + (target_lat - position_lat) / 2,
                     position_lng + (target_lng - position_lng) / 2, 0),
                    (target_lat, target_lng, target_alt)]

        bot.stepper.get_route_between = stepper_get_route_between

        def stepper_step(destination):
            for step in destination.step():
                yield step
                bot.stepper.current_lat = step[0]
                bot.stepper.current_lng = step[1]
                bot.stepper.current_alt = step[2]

        bot.stepper.step = stepper_step

        bot.player_service.heartbeat = Mock(return_value=None)

        bot.run()
 def _create_map_cells(self):
     return [
         Cell({
             "s2_cell_id":
             1,
             "spawn_points": [{
                 "latitude": 0,
                 "longitude": 0
             }],
             "forts": [
                 self._create_pokestop("unknown1", 51.5043872, -0.0741802),
                 self._create_pokestop("unknown2", 51.5060435, -0.073983),
             ]
         })
     ]