Example #1
0
def test_load_from_disk_first_failure(tmp_path, mocker):
    persisted_result = MagicMock()
    mocker.patch(
        "randovania.interface_common.persisted_options.find_config_files",
        autospec=True,
        return_value=[
            "[1]",
            "[2]",
        ])
    mock_get_persisted_options_from_data = mocker.patch(
        "randovania.interface_common.persisted_options.get_persisted_options_from_data",
        autospec=True,
        side_effect=[
            migration_lib.UnsupportedVersion(),
            persisted_result,
        ])
    option = Options(tmp_path)
    option.load_from_persisted = MagicMock()

    # Run
    result = option.load_from_disk(True)

    # Assert
    assert result
    option.load_from_persisted.assert_called_once_with(persisted_result, True)
    mock_get_persisted_options_from_data.assert_has_calls([
        call([1]),
        call([2]),
    ])
Example #2
0
def test_load_from_disk_first_successful(tmp_path, mocker):
    mocker.patch(
        "randovania.interface_common.persisted_options.find_config_files",
        autospec=True,
        return_value=[
            "[1]",
            "[2]",
        ])
    mock_get_persisted_options_from_data = mocker.patch(
        "randovania.interface_common.persisted_options.get_persisted_options_from_data",
        autospec=True,
    )
    option = Options(tmp_path)
    option.load_from_persisted = MagicMock()

    # Run
    result = option.load_from_disk(False)

    # Assert
    assert result
    option.load_from_persisted.assert_called_once_with(
        mock_get_persisted_options_from_data.return_value, False)
    mock_get_persisted_options_from_data.assert_called_once_with([1])