示例#1
0
        def work(progress_update: ProgressUpdateCallable):
            num_updaters = 2
            if input_file is not None:
                num_updaters += 1
            updaters = status_update_lib.split_progress_update(progress_update, num_updaters)

            if input_file is not None:
                simplified_patcher.unpack_iso(input_iso=input_file,
                                              options=options,
                                              progress_update=updaters[0])

            # Apply Layout
            simplified_patcher.apply_layout(layout=layout,
                                            players_config=PlayersConfiguration(
                                                player_index=player_index,
                                                player_names=player_names,
                                            ),
                                            options=options,
                                            progress_update=updaters[-2])

            # Pack ISO
            simplified_patcher.pack_iso(output_iso=output_file,
                                        options=options,
                                        progress_update=updaters[-1])
            if has_spoiler and auto_save_spoiler:
                layout.save_to_file(output_file.with_suffix(f".{LayoutDescription.file_extension()}"))

            progress_update(f"Finished!", 1)
def test_apply_layout(mock_patch_game_name_and_id: MagicMock,
                      mock_change_starting_spawn: MagicMock,
                      mock_claris_apply_layout: MagicMock, empty_patches):
    # Setup
    layout = MagicMock(spec=LayoutDescription(version="0.15.0",
                                              permalink=MagicMock(),
                                              patches=empty_patches,
                                              solver_path=()))
    progress_update = MagicMock()
    options: Options = MagicMock()

    # Run
    simplified_patcher.apply_layout(layout, options, progress_update)

    # Assert
    mock_patch_game_name_and_id.assert_called_once_with(
        options.game_files_path,
        "Metroid Prime 2: Randomizer - {}".format(layout.shareable_hash))
    mock_change_starting_spawn.assert_called_once_with(
        options.game_files_path, layout.patches.starting_location)
    mock_claris_apply_layout.assert_called_once_with(
        description=layout,
        cosmetic_patches=options.cosmetic_patches,
        game_root=options.game_files_path,
        backup_files_path=options.backup_files_path,
        progress_update=progress_update)
示例#3
0
        def work(progress_update: ProgressUpdateCallable):
            num_updaters = 2
            if input_file is not None:
                num_updaters += 1
            updaters = status_update_lib.split_progress_update(
                progress_update, num_updaters)

            if input_file is not None:
                simplified_patcher.unpack_iso(input_iso=input_file,
                                              options=options,
                                              progress_update=updaters[0])

            # Apply Layout
            simplified_patcher.apply_layout(layout=layout,
                                            options=options,
                                            progress_update=updaters[-2])

            # Pack ISO
            simplified_patcher.pack_iso(output_iso=output_file,
                                        options=options,
                                        progress_update=updaters[-1])

            progress_update(f"Finished!", 1)
def test_apply_layout(mock_patch_game_name_and_id: MagicMock,
                      mock_claris_apply_layout: MagicMock, empty_patches):
    # Setup
    layout = MagicMock()
    progress_update = MagicMock()
    options: Options = MagicMock()
    players_config = MagicMock()

    # Run
    simplified_patcher.apply_layout(layout, options, players_config,
                                    progress_update)

    # Assert
    mock_patch_game_name_and_id.assert_called_once_with(
        options.game_files_path,
        "Metroid Prime 2: Randomizer - {}".format(layout.shareable_hash))
    mock_claris_apply_layout.assert_called_once_with(
        description=layout,
        players_config=players_config,
        cosmetic_patches=options.cosmetic_patches,
        game_root=options.game_files_path,
        backup_files_path=options.backup_files_path,
        progress_update=progress_update,
    )