from src.gameplay.bbot import handleBBotAutomation, handleBBotKeepAlive


def test_keep_alive_steps_after_ten_idle_minutes(mocker):
    mocker.patch('src.gameplay.bbot.monotonic', side_effect=[100, 701])
    press = mocker.patch('src.gameplay.bbot.press')
    context = {
        'ng_bbot': {'runtime': {}, 'autoDropFlasks': {}},
        'ng_radar': {'coordinate': (32338, 31788, 7)},
    }

    handleBBotAutomation(context)
    handleBBotAutomation(context)

    press.assert_called_once_with('right')


def test_keep_alive_works_without_radar_coordinate(mocker):
    mocker.patch('src.gameplay.bbot.monotonic', side_effect=[100, 701])
    press = mocker.patch('src.gameplay.bbot.press')
    context = {
        'ng_bbot': {'runtime': {}},
        'ng_radar': {'coordinate': None},
    }

    handleBBotKeepAlive(context)
    handleBBotKeepAlive(context)

    press.assert_called_once_with('right')
