def test_starting_location_world_select(skip_qtbot, preset_manager): # Setup base = preset_manager.default_preset_for_game( RandovaniaGame.METROID_PRIME_ECHOES).get_preset() preset = dataclasses.replace( base, uuid=uuid.UUID('b41fde84-1f57-4b79-8cd6-3e5a78077fa6'), base_preset_uuid=base.uuid) editor = PresetEditor(preset) window = PresetMetroidStartingArea( editor, default_database.game_description_for(preset.game)) skip_qtbot.addWidget(window) # Run checkbox_list = window._starting_location_for_world window.on_preset_changed(editor.create_custom_preset_with()) assert len(checkbox_list) == 10 temple_grounds_checkbox = checkbox_list["Temple Grounds"] assert temple_grounds_checkbox.checkState() == Qt.PartiallyChecked skip_qtbot.mouseClick(temple_grounds_checkbox, Qt.LeftButton) assert temple_grounds_checkbox.checkState() == Qt.Checked assert len(editor.configuration.starting_location.locations) == 39 skip_qtbot.mouseClick(temple_grounds_checkbox, Qt.LeftButton) assert temple_grounds_checkbox.checkState() == Qt.Unchecked assert len(editor.configuration.starting_location.locations) == 0 skip_qtbot.mouseClick(temple_grounds_checkbox, Qt.LeftButton) window.on_preset_changed(editor.create_custom_preset_with()) assert temple_grounds_checkbox.checkState() == Qt.Checked assert len(editor.configuration.starting_location.locations) == 39
def test_starting_location_world_select(skip_qtbot, default_preset): # Setup preset = dataclasses.replace( default_preset, uuid=uuid.UUID('b41fde84-1f57-4b79-8cd6-3e5a78077fa6'), base_preset_uuid=default_preset.uuid) editor = PresetEditor(preset) window = LogicSettingsWindow(None, editor) skip_qtbot.addWidget(window) # Run checkbox_list = window._starting_location_for_world window.on_preset_changed(editor.create_custom_preset_with()) assert len(checkbox_list) == 10 temple_grounds_checkbox = checkbox_list["Temple Grounds"] assert temple_grounds_checkbox.checkState() == Qt.PartiallyChecked skip_qtbot.mouseClick(temple_grounds_checkbox, Qt.LeftButton) assert temple_grounds_checkbox.checkState() == Qt.Checked assert len(editor.configuration.starting_location.locations) == 39 skip_qtbot.mouseClick(temple_grounds_checkbox, Qt.LeftButton) assert temple_grounds_checkbox.checkState() == Qt.Unchecked assert len(editor.configuration.starting_location.locations) == 0 skip_qtbot.mouseClick(temple_grounds_checkbox, Qt.LeftButton) window.on_preset_changed(editor.create_custom_preset_with()) assert temple_grounds_checkbox.checkState() == Qt.Checked assert len(editor.configuration.starting_location.locations) == 39
def test_on_preset_changed(skip_qtbot, default_preset): # Setup editor = PresetEditor(default_preset) window = LogicSettingsWindow(None, editor) # Run window.on_preset_changed(editor.create_custom_preset_with())
def test_on_preset_changed(skip_qtbot, preset_manager, game): # Setup editor = PresetEditor( preset_manager.default_preset_for_game(game).get_preset()) window = LogicSettingsWindow(None, editor) # Run window.on_preset_changed(editor.create_custom_preset_with())
def test_on_preset_changed(skip_qtbot, preset_manager, game): # Setup base = preset_manager.default_preset_for_game(game).get_preset() preset = dataclasses.replace( base, uuid=uuid.UUID('b41fde84-1f57-4b79-8cd6-3e5a78077fa6'), base_preset_uuid=base.uuid) editor = PresetEditor(preset) window = LogicSettingsWindow(None, editor) # Run window.on_preset_changed(editor.create_custom_preset_with())
def test_on_preset_changed(skip_qtbot, preset_manager, game_enum): # Setup window_manager = MagicMock() base = preset_manager.default_preset_for_game(game_enum).get_preset() preset = dataclasses.replace(base, uuid=uuid.UUID('b41fde84-1f57-4b79-8cd6-3e5a78077fa6'), base_preset_uuid=base.uuid) editor = PresetEditor(preset) window = CustomizePresetDialog(window_manager, editor) # Run window.on_preset_changed(editor.create_custom_preset_with())
def test_edit_menu_mod(editor: PresetEditor, initial_layout_configuration_params: dict, default_echoes_configuration, menu_mod): # Setup editor._configuration = dataclasses.replace( default_echoes_configuration, **initial_layout_configuration_params) editor._nested_autosave_level = 1 # Run initial_layout_configuration_params["menu_mod"] = menu_mod editor.set_configuration_field("menu_mod", menu_mod) # Assert assert editor.configuration == dataclasses.replace( default_echoes_configuration, **initial_layout_configuration_params)
def test_edit_layout_trick_level(editor: PresetEditor, initial_layout_configuration_params: dict, default_layout_configuration, new_trick_level: LayoutTrickLevel): # Setup editor._layout_configuration = dataclasses.replace(default_layout_configuration, **initial_layout_configuration_params) editor._nested_autosave_level = 1 # Run initial_layout_configuration_params["trick_level_configuration"] = TrickLevelConfiguration(new_trick_level) editor.set_layout_configuration_field("trick_level_configuration", TrickLevelConfiguration(new_trick_level)) # Assert assert editor.layout_configuration == dataclasses.replace(default_layout_configuration, **initial_layout_configuration_params)
def test_location_pool_row_disabled_on_major_minor_split( customized_preset, echoes_game_description, skip_qtbot): # Setup preset_editor = PresetEditor(customized_preset) location_pool_tab = PresetLocationPool(preset_editor, echoes_game_description) # Get the first major location in the list, and the first non-major one # Then, put it in a state which will have to be changed in the case where # major/minor split is enabled. first_major: LocationPoolRowWidget = None first_non_major: LocationPoolRowWidget = None for row_widget in location_pool_tab._row_widget_for_node.values(): if first_major is None and row_widget.node.major_location: first_major = row_widget elif first_non_major is None and not row_widget.node.major_location: first_non_major = row_widget if first_major is not None and first_non_major is not None: break first_major.radio_shuffled_no_progression.setChecked(True) # Run & Assert assert first_major.isEnabled() assert first_non_major.isEnabled() assert not first_major.radio_shuffled.isChecked() location_pool_tab._major_minor = True location_pool_tab._on_update_randomization_mode() assert first_major.isEnabled() assert not first_non_major.isEnabled() assert first_major.radio_shuffled.isChecked()
def test_edit_skip_final_bosses(editor: PresetEditor, initial_layout_configuration_params: dict, default_layout_configuration, skip_final_bosses): # Setup editor._configuration = dataclasses.replace( default_layout_configuration, **initial_layout_configuration_params) editor._nested_autosave_level = 1 # Run initial_layout_configuration_params[ "skip_final_bosses"] = skip_final_bosses editor.set_configuration_field("skip_final_bosses", skip_final_bosses) # Assert assert editor.configuration == dataclasses.replace( default_layout_configuration, **initial_layout_configuration_params)
def test_on_preset_changed(skip_qtbot, preset_manager, game): # Setup base = preset_manager.default_preset_for_game(game).get_preset() preset = dataclasses.replace( base, uuid=uuid.UUID('b41fde84-1f57-4b79-8cd6-3e5a78077fa6'), base_preset_uuid=base.uuid) editor = PresetEditor(preset) window = PresetStartingArea( editor, default_database.game_description_for(preset.game)) # Run window.on_preset_changed(editor.create_custom_preset_with()) # Assert num_areas = len(StartingLocationList.areas_list(preset.game)) assert len(window._starting_location_for_area) == num_areas
def test_on_preset_changed(skip_qtbot, preset_manager, game_data): # Setup game, has_specific_settings, has_min_logic, tab = game_data base = preset_manager.default_preset_for_game(game).get_preset() preset = dataclasses.replace(base, uuid=uuid.UUID('b41fde84-1f57-4b79-8cd6-3e5a78077fa6'), base_preset_uuid=base.uuid) editor = PresetEditor(preset) window: PresetGeneration = tab(editor, default_database.game_description_for(game)) parent = QGroupBox() window.setParent(parent) # Run window.on_preset_changed(editor.create_custom_preset_with()) # Assert assert window.trick_level_minimal_logic_check.isVisibleTo(parent) == has_min_logic assert window.game_specific_group.isVisibleTo(parent) == has_specific_settings
def test_preset_editor_tabs_for(skip_qtbot, game_enum: RandovaniaGame, preset_manager): preset = preset_manager.default_preset_for_game(game_enum) editor = PresetEditor(preset.get_preset().fork()) window_manager = MagicMock() # Run result = game_specific_gui.preset_editor_tabs_for(editor, window_manager) # Assert assert len(result) >= 3
def test_starting_location_world_select(skip_qtbot, default_preset): # Setup editor = PresetEditor(default_preset) window = LogicSettingsWindow(None, editor) skip_qtbot.addWidget(window) # Run checkbox_list = window._starting_location_for_world window.on_preset_changed(editor.create_custom_preset_with()) assert len(checkbox_list) == 10 temple_grounds_checkbox = checkbox_list["Temple Grounds"] assert temple_grounds_checkbox.checkState() == Qt.PartiallyChecked skip_qtbot.mouseClick(temple_grounds_checkbox, Qt.LeftButton) assert temple_grounds_checkbox.checkState() == Qt.Checked assert len(editor.layout_configuration.starting_location.locations) == 40 skip_qtbot.mouseClick(temple_grounds_checkbox, Qt.LeftButton) assert temple_grounds_checkbox.checkState() == Qt.Unchecked assert len(editor.layout_configuration.starting_location.locations) == 0 skip_qtbot.mouseClick(temple_grounds_checkbox, Qt.LeftButton) window.on_preset_changed(editor.create_custom_preset_with()) assert temple_grounds_checkbox.checkState() == Qt.Checked assert len(editor.layout_configuration.starting_location.locations) == 40
async def test_dock_weakness_distribute(default_blank_preset): _editor = PresetEditor(default_blank_preset.fork()) with _editor as editor: editor.dock_rando_configuration = dataclasses.replace( editor.dock_rando_configuration, mode=DockRandoMode.TWO_WAY ) preset = editor.create_custom_preset_with() gen_params = GeneratorParameters(5000, False, [preset]) description = await generate_and_validate_description(gen_params, None, False) assert list(description.all_patches[0].all_dock_weaknesses())
def test_elements_init(skip_qtbot, test_files_dir): preset_path = test_files_dir.joinpath( "presets/super_test_preset.rdvpreset") preset = VersionedPreset.from_file_sync(preset_path).get_preset() assert isinstance(preset.configuration, SuperMetroidConfiguration) editor = PresetEditor(preset) super_patches_tab = PresetSuperPatchConfiguration(editor) skip_qtbot.addWidget(super_patches_tab) # Test whether visual elements are initialized correctly patches = preset.configuration.patches for field_name, checkbox in super_patches_tab.checkboxes.items(): assert checkbox.isChecked() == getattr(patches, field_name)
def test_quick_fill_default(skip_qtbot, preset_manager, game_enum: RandovaniaGame): # Setup base = preset_manager.default_preset_for_game(game_enum).get_preset() preset = dataclasses.replace( base, uuid=uuid.UUID('b41fde84-1f57-4b79-8cd6-3e5a78077fa6'), base_preset_uuid=base.uuid) editor = PresetEditor(preset) window = PresetStartingArea( editor, default_database.game_description_for(preset.game)) skip_qtbot.addWidget(window) # Run skip_qtbot.mouseClick(window.starting_area_quick_fill_default, QtCore.Qt.LeftButton) # Assert assert editor.configuration.starting_location.locations == ( window.game_description.starting_location, )
def _on_customize_button(self): editor = PresetEditor(self._current_preset_data) self._logic_settings_window = LogicSettingsWindow( self._window_manager, editor) self._logic_settings_window.on_preset_changed( editor.create_custom_preset_with()) editor.on_changed = lambda: self._logic_settings_window.on_preset_changed( editor.create_custom_preset_with()) result = self._logic_settings_window.exec_() self._logic_settings_window = None if result == QDialog.Accepted: self._add_new_preset(editor.create_custom_preset_with())
async def _on_customize_button(self): if self._logic_settings_window is not None: self._logic_settings_window.raise_() return editor = PresetEditor(self._current_preset_data.get_preset()) self._logic_settings_window = LogicSettingsWindow(self._window_manager, editor) self._logic_settings_window.on_preset_changed(editor.create_custom_preset_with()) editor.on_changed = lambda: self._logic_settings_window.on_preset_changed(editor.create_custom_preset_with()) result = await async_dialog.execute_dialog(self._logic_settings_window) self._logic_settings_window = None if result == QDialog.Accepted: self._add_new_preset(VersionedPreset.with_preset(editor.create_custom_preset_with()))
def test_quick_fill_cs_classic(skip_qtbot, preset_manager): # Setup base = preset_manager.default_preset_for_game( RandovaniaGame.CAVE_STORY).get_preset() preset = dataclasses.replace( base, uuid=uuid.UUID('b41fde84-1f57-4b79-8cd6-3e5a78077fa6'), base_preset_uuid=base.uuid) editor = PresetEditor(preset) window = PresetCSStartingArea( editor, default_database.game_description_for(preset.game)) skip_qtbot.addWidget(window) # Run skip_qtbot.mouseClick(window.starting_area_quick_fill_classic, QtCore.Qt.LeftButton) # Assert expected = { AreaIdentifier("Mimiga Village", "Start Point"), AreaIdentifier("Mimiga Village", "Arthur's House"), AreaIdentifier("Labyrinth", "Camp") } assert set(editor.configuration.starting_location.locations) == expected
def test_toggle_immediate_parts(skip_qtbot, preset_manager): game = RandovaniaGame.METROID_DREAD base = preset_manager.default_preset_for_game(game).get_preset() preset = dataclasses.replace( base, uuid=uuid.UUID('b41fde84-1f57-4b79-8cd6-3e5a78077fa6'), base_preset_uuid=base.uuid) base_configuration = preset.configuration assert isinstance(base_configuration, DreadConfiguration) tab = PresetDreadEnergy(editor := PresetEditor(preset)) skip_qtbot.addWidget(tab) tab.on_preset_changed(preset) assert tab.energy_tank_capacity_spin_box.isEnabled() skip_qtbot.mouseClick(tab.immediate_energy_parts_check, QtCore.Qt.LeftButton) tab.on_preset_changed(editor.create_custom_preset_with()) configuration = editor.configuration assert isinstance(configuration, DreadConfiguration) assert configuration.immediate_energy_parts != base_configuration.immediate_energy_parts assert not tab.energy_tank_capacity_spin_box.isEnabled()
async def _on_customize_preset(self): if self._logic_settings_window is not None: self._logic_settings_window.raise_() return old_preset = self._current_preset_data.get_preset() if old_preset.base_preset_uuid is None: old_preset = old_preset.fork() editor = PresetEditor(old_preset) self._logic_settings_window = CustomizePresetDialog(self._window_manager, editor) self._logic_settings_window.on_preset_changed(editor.create_custom_preset_with()) editor.on_changed = lambda: self._logic_settings_window.on_preset_changed(editor.create_custom_preset_with()) result = await async_dialog.execute_dialog(self._logic_settings_window) self._logic_settings_window = None if result == QtWidgets.QDialog.Accepted: self._add_new_preset(VersionedPreset.with_preset(editor.create_custom_preset_with()))
def _editor() -> PresetEditor: return PresetEditor(MagicMock())