def test_set_steps():
        destination = Destination(1,
                                  2,
                                  0,
                                  name="test_destination",
                                  exact_location=False)

        destination.set_steps([(1, 2, 0), (2, 3, 0), (3, 4, 0)])

        assert destination.get_step_count() == 3
    def test_set_steps():
        destination = Destination(1, 2, 0, name="test_destination", exact_location=False)

        destination.set_steps([
            (1, 2, 0),
            (2, 3, 0),
            (3, 4, 0)
        ])

        assert destination.get_step_count() == 3
Esempio n. 3
0
    def test_step():
        config = create_core_test_config({
            "movement": {
                "walk_speed": 5,
                "path_finder": "direct",
                "distance_unit": "m"
            }
        })
        api_wrapper = create_mock_api_wrapper(config)
        path_finder = DirectPathFinder(config)
        logger = Mock()
        logger.log = Mock(return_value=None)
        stepper = Stepper(config, api_wrapper, path_finder, logger)
        stepper.start(51.50451, -0.07607, 10)

        destination = Destination(51.506000,
                                  -0.075049,
                                  11,
                                  name="Test Destination",
                                  exact_location=False)
        steps = [(51.504778, -0.075838, 10), (51.505092, -0.075650, 11),
                 (51.505436, -0.075446, 11)]
        destination.set_steps(steps)

        pgo = api_wrapper.get_api()

        # This route is being walked: http://www.darrinward.com/lat-long/?id=2163411
        # pre-calculated distance is 17.8 meters
        pointer = 0
        for _ in stepper.step(destination):
            target_lat, target_lng, target_alt = steps[pointer]
            assert stepper.current_lat == target_lat
            assert stepper.current_lng == target_lng
            assert stepper.current_alt == target_alt

            bot_lat, bot_lng, bot_alt = pgo.get_position()
            assert bot_lat == target_lat
            assert bot_lng == target_lng
            assert bot_alt == target_alt

            pointer += 1

        assert pointer == 3

        bot_lat, bot_lng, bot_alt = pgo.get_position()
        assert bot_lat == 51.505436
        assert bot_lng == -0.075446
        assert bot_alt == 11
        assert stepper.current_lat == 51.505436
        assert stepper.current_lng == -0.075446
        assert stepper.current_alt == 11
Esempio n. 4
0
    def test_step():
        config = create_core_test_config({
            "movement": {
                "walk_speed": 5,
                "path_finder": "direct",
                "distance_unit": "m"
            }
        })
        api_wrapper = create_mock_api_wrapper(config)
        path_finder = DirectPathFinder(config)
        logger = Mock()
        logger.log = Mock(return_value=None)
        stepper = Stepper(config, api_wrapper, path_finder, logger)
        stepper.start(51.50451, -0.07607, 10)

        destination = Destination(51.506000, -0.075049, 11, name="Test Destination", exact_location=False)
        steps = [
            (51.504778, -0.075838, 10),
            (51.505092, -0.075650, 11),
            (51.505436, -0.075446, 11)
        ]
        destination.set_steps(steps)

        pgo = api_wrapper.get_api()

        # This route is being walked: http://www.darrinward.com/lat-long/?id=2163411
        # pre-calculated distance is 17.8 meters
        pointer = 0
        for _ in stepper.step(destination):
            target_lat, target_lng, target_alt = steps[pointer]
            assert stepper.current_lat == target_lat
            assert stepper.current_lng == target_lng
            assert stepper.current_alt == target_alt

            bot_lat, bot_lng, bot_alt = pgo.get_position()
            assert bot_lat == target_lat
            assert bot_lng == target_lng
            assert bot_alt == target_alt

            pointer += 1

        assert pointer == 3

        bot_lat, bot_lng, bot_alt = pgo.get_position()
        assert bot_lat == 51.505436
        assert bot_lng == -0.075446
        assert bot_alt == 11
        assert stepper.current_lat == 51.505436
        assert stepper.current_lng == -0.075446
        assert stepper.current_alt == 11
Esempio n. 5
0
    def test_step():
        calls = []
        bot = create_mock_bot({
            "walk": 5,
            "path_finder": "direct",
            "distance_unit": "m"
        })
        bot.position = (51.50451, -0.07607, 10)
        bot.fire = Mock(return_value=None)
        bot.heartbeat = Mock(return_value=None)

        destination = Destination(51.506000, -0.075049, 11, name="Test Destination", exact_location=False)
        steps = [
            (51.504778, -0.075838, 10),
            (51.505092, -0.075650, 11),
            (51.505436, -0.075446, 11)
        ]
        destination.set_steps(steps)

        stepper = Stepper(bot)
        stepper.start()

        pgo = bot.api_wrapper._api  # pylint: disable=protected-access

        # This route is being walked: http://www.darrinward.com/lat-long/?id=2163411
        calls.append(call("walking_started", coords=(51.506000, -0.075049, 11)))
        pointer = 0
        for step in stepper.step(destination):
            calls.append(call("position_updated", coordinates=step))

            target_lat, target_lng, target_alt = steps[pointer]
            assert stepper.current_lat == target_lat
            assert stepper.current_lng == target_lng
            assert stepper.current_alt == target_alt

            bot_lat, bot_lng, bot_alt = pgo.get_position()
            assert bot_lat == target_lat
            assert bot_lng == target_lng
            assert bot_alt == target_alt

            pointer += 1

        calls.append(call("walking_finished", coords=(51.506000, -0.075049, 11)))

        assert bot.fire.call_count == 5
        bot.fire.assert_has_calls(calls, any_order=False)

        assert bot.heartbeat.call_count == 3
Esempio n. 6
0
    def test_step():
        calls = []
        bot = create_mock_bot({
            "walk": 5,
            "path_finder": "direct",
            "distance_unit": "m"
        })
        bot.position = (51.50451, -0.07607, 10)
        bot.fire = Mock(return_value=None)
        bot.heartbeat = Mock(return_value=None)

        destination = Destination(51.50436, -0.07616, 11, name="Test Destination", exact_location=False)
        steps = [
            (51.50442, -0.07612, 10),
            (51.50448, -0.07609, 11),
            (51.50436, -0.07616, 11)
        ]
        destination.set_steps(steps)

        stepper = Stepper(bot)
        stepper.start()

        pgo = bot.api_wrapper._api  # pylint: disable=protected-access

        calls.append(call("walking_started", coords=(51.50436, -0.07616, 11)))
        # pre-calculated distance is 17.8 meters
        pointer = 0
        for step in stepper.step(destination):
            calls.append(call("position_updated", coordinates=step))

            target_lat, target_lng, target_alt = steps[pointer]
            assert stepper.current_lat == target_lat
            assert stepper.current_lng == target_lng
            assert stepper.current_alt == target_alt

            bot_lat, bot_lng, bot_alt = pgo.get_position()
            assert bot_lat == target_lat
            assert bot_lng == target_lng
            assert bot_alt == target_alt

            pointer += 1

        calls.append(call("walking_finished", coords=(51.50436, -0.07616, 11)))

        assert bot.fire.call_count == 5
        bot.fire.assert_has_calls(calls, any_order=False)

        assert bot.heartbeat.call_count == 3
    def test_step():
        destination = Destination(1, 2, 0, name="test_destination", exact_location=False)

        steps = [
            (1, 2, 0),
            (2, 3, 0),
            (3, 4, 0)
        ]
        destination.set_steps(steps)

        step_values = []
        for step in destination.step():
            assert step in steps
            step_values.append(step)

        assert len(step_values) == 3
    def test_step():
        destination = Destination(1,
                                  2,
                                  0,
                                  name="test_destination",
                                  exact_location=False)

        steps = [(1, 2, 0), (2, 3, 0), (3, 4, 0)]
        destination.set_steps(steps)

        step_values = []
        for step in destination.step():
            assert step in steps
            step_values.append(step)

        assert len(step_values) == 3
Esempio n. 9
0
    def test_step_already_near_fort():
        calls = []
        bot = create_mock_bot({
            "walk": 5,
            "path_finder": "direct",
            "distance_unit": "m"
        })
        bot.position = (51.50451, -0.07607, 10)
        bot.fire = Mock(return_value=None)
        bot.heartbeat = Mock(return_value=None)

        destination = Destination(51.50436, -0.07616, 11, name="Test Destination", exact_location=False)
        steps = [
            (51.50442, -0.07612, 10),
            (51.50448, -0.07609, 11),
            (51.50436, -0.07616, 11)
        ]
        destination.set_steps(steps)

        stepper = Stepper(bot)
        stepper.start()

        pgo = bot.api_wrapper._api  # pylint: disable=protected-access

        # This route is being walked: http://www.darrinward.com/lat-long/?id=2163408
        calls.append(call("walking_started", coords=(51.50436, -0.07616, 11)))
        pointer = 0
        for _ in stepper.step(destination):
            pointer += 1

        assert pointer == 0

        bot_lat, bot_lng, bot_alt = pgo.get_position()
        assert bot_lat == 51.50451
        assert bot_lng == -0.07607
        assert bot_alt == 10
        assert stepper.current_lat == 51.50451
        assert stepper.current_lng == -0.07607
        assert stepper.current_alt == 10

        calls.append(call("walking_finished", coords=(51.50436, -0.07616, 11)))

        assert bot.fire.call_count == 2
        bot.fire.assert_has_calls(calls, any_order=False)

        assert bot.heartbeat.call_count == 0
Esempio n. 10
0
    def test_step_exact():
        destination = Destination(4, 5, 6, name="test_destination", exact_location=True)

        steps = [
            (1, 2, 0),
            (2, 3, 0),
            (3, 4, 0)
        ]
        destination.set_steps(steps)

        step_values = []
        for step in destination.step():
            if len(step_values) < 3:
                assert step in steps
            else:
                assert step == (4, 5, 6)
            step_values.append(step)

        assert len(step_values) == 4
Esempio n. 11
0
    def test_step_exact():
        destination = Destination(4,
                                  5,
                                  6,
                                  name="test_destination",
                                  exact_location=True)

        steps = [(1, 2, 0), (2, 3, 0), (3, 4, 0)]
        destination.set_steps(steps)

        step_values = []
        for step in destination.step():
            if len(step_values) < 3:
                assert step in steps
            else:
                assert step == (4, 5, 6)
            step_values.append(step)

        assert len(step_values) == 4
Esempio n. 12
0
    def test_step_already_near_fort():
        calls = []
        config = create_core_test_config({
            "movement": {
                "walk_speed": 5,
                "path_finder": "direct",
                "distance_unit": "m"
            }
        })
        api_wrapper = create_mock_api_wrapper(config)
        path_finder = DirectPathFinder(config)

        destination = Destination(51.50436,
                                  -0.07616,
                                  11,
                                  name="Test Destination",
                                  exact_location=False)
        steps = [(51.50442, -0.07612, 10), (51.50448, -0.07609, 11),
                 (51.50436, -0.07616, 11)]
        destination.set_steps(steps)

        logger = Mock()
        logger.log = Mock(return_value=None)
        stepper = Stepper(config, api_wrapper, path_finder, logger)
        stepper.start(51.50451, -0.07607, 10)

        pgo = api_wrapper.get_api()

        # This route is being walked: http://www.darrinward.com/lat-long/?id=2163408
        calls.append(call("walking_started", coords=(51.50436, -0.07616, 11)))
        pointer = 0
        for _ in stepper.step(destination):
            pointer += 1

        assert pointer == 0

        bot_lat, bot_lng, bot_alt = pgo.get_position()
        assert bot_lat == 51.50451
        assert bot_lng == -0.07607
        assert bot_alt == 10
        assert stepper.current_lat == 51.50451
        assert stepper.current_lng == -0.07607
        assert stepper.current_alt == 10
Esempio n. 13
0
    def test_step_already_near_fort():
        calls = []
        config = create_core_test_config({
            "movement": {
                "walk_speed": 5,
                "path_finder": "direct",
                "distance_unit": "m"
            }
        })
        api_wrapper = create_mock_api_wrapper(config)
        path_finder = DirectPathFinder(config)

        destination = Destination(51.50436, -0.07616, 11, name="Test Destination", exact_location=False)
        steps = [
            (51.50442, -0.07612, 10),
            (51.50448, -0.07609, 11),
            (51.50436, -0.07616, 11)
        ]
        destination.set_steps(steps)

        logger = Mock()
        logger.log = Mock(return_value=None)
        stepper = Stepper(config, api_wrapper, path_finder, logger)
        stepper.start(51.50451, -0.07607, 10)

        pgo = api_wrapper.get_api()

        # This route is being walked: http://www.darrinward.com/lat-long/?id=2163408
        calls.append(call("walking_started", coords=(51.50436, -0.07616, 11)))
        pointer = 0
        for _ in stepper.step(destination):
            pointer += 1

        assert pointer == 0

        bot_lat, bot_lng, bot_alt = pgo.get_position()
        assert bot_lat == 51.50451
        assert bot_lng == -0.07607
        assert bot_alt == 10
        assert stepper.current_lat == 51.50451
        assert stepper.current_lng == -0.07607
        assert stepper.current_alt == 10