diff --git a/README.rst b/README.rst index 7cf8e18..23cf9fc 100644 --- a/README.rst +++ b/README.rst @@ -245,19 +245,16 @@ savestate Options used: * ``wrapper`` (required) with ``archive`` as an value -* ``wrapper_archiver`` (conditionally required) archiver to use for storage - save state +* ``wrapper_archiver`` (required) archiver to use for storage save state * ``wrapper_gui_msg`` (optional) if set to "1", will display a graphical message during extracting files -* ``wrapper_save_state`` (optional) if set to "1", will archive save state - directory, defined as ``$CONFIG/[save-state-dir-name]`` using provided - ``wrapper_archiver`` archiver. If this option is enabled, - ``wrapper_archiver`` will be required. This module is primarily used to run emulator with read only media attached (like images of floppies or uncompressed CD-ROMs) and its purpose is to preserve save state which will be created as an archive alongside with original -configuration file in selected archive format. +configuration file in selected archive format. Note, that there is required to +provide ``wrapper_archiver``, since option ``wrapper_save_state`` is implicitly +set to value ``1`` in this module. Example configuration: @@ -268,7 +265,6 @@ Example configuration: wrapper = savestate wrapper_archiver = 7z wrapper_gui_msg = 1 - wrapper_save_state = 1 ... And execution is as usual: diff --git a/fs_uae_wrapper/savestate.py b/fs_uae_wrapper/savestate.py index 1d3aa2b..0a2b8cc 100644 --- a/fs_uae_wrapper/savestate.py +++ b/fs_uae_wrapper/savestate.py @@ -8,6 +8,19 @@ class SaveState(base.Base): """ Preserve save state. """ + def __init__(self, conf_file, fsuae_options, configuration): + """ + Params: + conf_file: a relative path to provided configuration file + fsuae_options: is an CmdOption object created out of command line + parameters + configuration: is config dictionary created out of config file + """ + super(SaveState, self).__init__(conf_file, fsuae_options, + configuration) + self.arch_filepath = None + self.all_options['wrapper_save_state'] = '1' + def run(self): """ Main function which accepts configuration file for FS-UAE diff --git a/tests/test_savestate.py b/tests/test_savestate.py index dced671..1e22ae3 100644 --- a/tests/test_savestate.py +++ b/tests/test_savestate.py @@ -47,7 +47,7 @@ class TestArchive(TestCase): arch = savestate.SaveState('Config.fs-uae', utils.CmdOption(), {}) self.assertFalse(arch.run()) - arch.all_options = {'wrapper': 'archive', + arch.all_options = {'wrapper': 'savestate', 'wrapper_save_state': '1', 'wrapper_archiver': 'rar'} @@ -70,3 +70,16 @@ class TestArchive(TestCase): save_state.return_value = True self.assertTrue(arch.run()) + + @mock.patch('fs_uae_wrapper.path.which') + def test_validate_options(self, which): + which.return_value = 'unrar' + + arch = savestate.SaveState('Config.fs-uae', utils.CmdOption(), {}) + self.assertFalse(arch._validate_options()) + + arch.all_options['wrapper'] = 'savestate' + self.assertFalse(arch._validate_options()) + + arch.all_options['wrapper_archiver'] = 'rar' + self.assertTrue(arch._validate_options())