Exemple #1
0
async def test_on_timer_update(current_status: GameConnectionStatus,
                               skip_qtbot, mocker):
    # Setup
    inventory = {}
    game_connection = MagicMock()
    game_connection.pretty_current_status = "Pretty Status"

    mock_create_tracker: MagicMock = mocker.patch(
        "randovania.gui.auto_tracker_window.AutoTrackerWindow.create_tracker")

    window = AutoTrackerWindow(game_connection, MagicMock())
    window._update_tracker_from_hook = MagicMock()
    mock_create_tracker.reset_mock()

    game_connection.get_current_inventory.return_value = inventory
    game_connection.current_status = current_status

    # Run
    await window._on_timer_update()

    # Assert
    if current_status != GameConnectionStatus.Disconnected:
        mock_create_tracker.assert_called_once_with(
            game_connection.backend.patches.game)
        window._update_tracker_from_hook.assert_called_once_with(inventory)
    else:
        mock_create_tracker.assert_not_called()
        window._update_tracker_from_hook.assert_not_called()
async def test_on_timer_update(current_status: GameConnectionStatus,
                               correct_game, skip_qtbot, mocker):
    # Setup
    inventory = {}
    game_connection = MagicMock()
    game_connection.pretty_current_status = "Pretty Status"

    window = AutoTrackerWindow(game_connection, MagicMock())
    skip_qtbot.addWidget(window)
    window._update_timer = MagicMock()
    window._update_tracker_from_hook = MagicMock()

    game_connection.get_current_inventory.return_value = inventory
    game_connection.current_status = current_status

    if correct_game:
        window._current_tracker_game = game_connection.connector.game_enum

    # Run
    await window._on_timer_update_raw()

    # Assert
    if current_status != GameConnectionStatus.Disconnected and correct_game:
        window._update_tracker_from_hook.assert_called_once_with(inventory)
    else:
        window._update_tracker_from_hook.assert_not_called()
    window._update_timer.start.assert_called_once_with()
Exemple #3
0
async def show_tracker(app: QtWidgets.QApplication):
    from randovania.gui.auto_tracker_window import AutoTrackerWindow
    options = await _load_options()
    if options is None:
        app.exit(1)
        return

    app.tracker = AutoTrackerWindow(app.game_connection, options)
    logger.info("Displaying auto tracker")
    app.tracker.show()
Exemple #4
0
async def test_on_timer_update(current_status: GameConnectionStatus, window):
    # Setup
    inventory = {}
    game_connection = MagicMock()
    game_connection.pretty_current_status = "Pretty Status"

    window = AutoTrackerWindow(game_connection, MagicMock())
    window._update_tracker_from_hook = MagicMock()

    game_connection.get_current_inventory.return_value = inventory
    game_connection.current_status = current_status

    # Run
    await window._on_timer_update()

    # Assert
    if current_status != GameConnectionStatus.Disconnected:
        window._update_tracker_from_hook.assert_called_once_with(inventory)
    else:
        window._update_tracker_from_hook.assert_not_called()
async def test_on_timer_update(is_in_game: bool,
                               window):
    # Setup
    inventory = {}
    game_connection = MagicMock()

    window = AutoTrackerWindow(game_connection)
    window._update_tracker_from_hook = MagicMock()

    game_connection.get_inventory = AsyncMock(return_value=inventory)
    game_connection.current_status = ConnectionStatus.InGame if is_in_game else ConnectionStatus.Disconnected

    # Run
    await window._on_timer_update()

    # Assert
    if is_in_game:
        window._update_tracker_from_hook.assert_called_once_with(inventory)
    else:
        window._update_tracker_from_hook.assert_not_called()
Exemple #6
0
def show_tracker(app: QtWidgets.QApplication):
    from randovania.gui.auto_tracker_window import AutoTrackerWindow

    app.tracker = AutoTrackerWindow(app.game_connection, _load_options())
    logger.info("Displaying auto tracker")
    app.tracker.show()
 def _open_auto_tracker(self):
     from randovania.gui.auto_tracker_window import AutoTrackerWindow
     self.auto_tracker_window = AutoTrackerWindow(
         common_qt_lib.get_game_connection(), self._options)
     self.auto_tracker_window.show()
Exemple #8
0
def auto_tracker_window(skip_qtbot):
    connection = MagicMock()
    connection.pretty_current_status = "Pretty"
    return AutoTrackerWindow(connection, MagicMock())
def auto_tracker_window(skip_qtbot):
    connection = MagicMock()
    connection.pretty_current_status = "Pretty"
    window = AutoTrackerWindow(connection, MagicMock())
    skip_qtbot.addWidget(window)
    return window
def auto_tracker_window(skip_qtbot):
    return AutoTrackerWindow(MagicMock())
Exemple #11
0
def show_tracker(app: QApplication):
    from randovania.gui.auto_tracker_window import AutoTrackerWindow

    app.tracker = AutoTrackerWindow(app.game_connection)
    app.tracker.show()