mirror of
https://github.com/gryf/fs-uae-wrapper.git
synced 2025-12-19 12:28:12 +01:00
Moved save state out of _make_archive method
Now _save_save method will be called from run() method.
This commit is contained in:
@@ -126,6 +126,7 @@ Options used:
|
|||||||
|
|
||||||
* ``wrapper`` (required) with ``cd32`` as an value
|
* ``wrapper`` (required) with ``cd32`` as an value
|
||||||
* ``wrapper_archive`` (required) path to the archive with CD32 iso/cue/wav
|
* ``wrapper_archive`` (required) path to the archive with CD32 iso/cue/wav
|
||||||
|
* ``wrapper_archiver`` (required) archiver to use for storage save state
|
||||||
* ``wrapper_gui_msg`` (optional) if set to "1", will display a graphical
|
* ``wrapper_gui_msg`` (optional) if set to "1", will display a graphical
|
||||||
message during extracting files
|
message during extracting files
|
||||||
|
|
||||||
@@ -181,7 +182,8 @@ Options used:
|
|||||||
|
|
||||||
* ``wrapper`` (required) with ``cd32`` as an value
|
* ``wrapper`` (required) with ``cd32`` as an value
|
||||||
* ``wrapper_archive`` (required) path to the archive with assets (usually means
|
* ``wrapper_archive`` (required) path to the archive with assets (usually means
|
||||||
whole system directories, floppies or hd images)
|
* ``wrapper_archiver`` (required) archiver to use for storage save state
|
||||||
|
whole system directories, floppies or hard disk images)
|
||||||
* ``wrapper_gui_msg`` (optional) if set to "1", will display a graphical
|
* ``wrapper_gui_msg`` (optional) if set to "1", will display a graphical
|
||||||
message during extracting files
|
message during extracting files
|
||||||
* ``wrapper_persist_data`` (optional) if set to "1", will compress (possibly
|
* ``wrapper_persist_data`` (optional) if set to "1", will compress (possibly
|
||||||
|
|||||||
@@ -56,6 +56,10 @@ class Archive(base.Base):
|
|||||||
if not self._run_emulator(self.fsuae_options.list()):
|
if not self._run_emulator(self.fsuae_options.list()):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
if self._get_saves_dir():
|
||||||
|
if not self._save_save():
|
||||||
|
return False
|
||||||
|
|
||||||
return self._make_archive()
|
return self._make_archive()
|
||||||
|
|
||||||
def _validate_options(self):
|
def _validate_options(self):
|
||||||
@@ -79,14 +83,10 @@ class Archive(base.Base):
|
|||||||
if self.all_options.get('wrapper_persist_data', '0') != '1':
|
if self.all_options.get('wrapper_persist_data', '0') != '1':
|
||||||
return True
|
return True
|
||||||
|
|
||||||
saves = self._get_saves_dir()
|
|
||||||
if saves:
|
|
||||||
if not self._save_save():
|
|
||||||
return False
|
|
||||||
|
|
||||||
curdir = os.path.abspath('.')
|
curdir = os.path.abspath('.')
|
||||||
os.chdir(self.dir)
|
os.chdir(self.dir)
|
||||||
|
|
||||||
|
saves = self._get_saves_dir()
|
||||||
if saves:
|
if saves:
|
||||||
shutil.rmtree(saves)
|
shutil.rmtree(saves)
|
||||||
os.unlink('Config.fs-uae')
|
os.unlink('Config.fs-uae')
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ class TestArchive(TestCase):
|
|||||||
self.assertFalse(arch._validate_options())
|
self.assertFalse(arch._validate_options())
|
||||||
|
|
||||||
arch.all_options['wrapper_archive'] = 'fake.tgz'
|
arch.all_options['wrapper_archive'] = 'fake.tgz'
|
||||||
|
self.assertFalse(arch._validate_options())
|
||||||
|
|
||||||
|
arch.all_options['wrapper_archiver'] = 'rar'
|
||||||
self.assertTrue(arch._validate_options())
|
self.assertTrue(arch._validate_options())
|
||||||
|
|
||||||
@mock.patch('tempfile.mkdtemp')
|
@mock.patch('tempfile.mkdtemp')
|
||||||
@@ -57,7 +60,8 @@ class TestArchive(TestCase):
|
|||||||
self.assertFalse(arch.run())
|
self.assertFalse(arch.run())
|
||||||
|
|
||||||
arch.all_options = {'wrapper': 'archive',
|
arch.all_options = {'wrapper': 'archive',
|
||||||
'wrapper_archive': 'fake.tgz'}
|
'wrapper_archive': 'fake.tgz',
|
||||||
|
'wrapper_archiver': 'rar'}
|
||||||
|
|
||||||
self.assertFalse(arch.run())
|
self.assertFalse(arch.run())
|
||||||
|
|
||||||
@@ -85,12 +89,10 @@ class TestArchive(TestCase):
|
|||||||
@mock.patch('shutil.rmtree')
|
@mock.patch('shutil.rmtree')
|
||||||
@mock.patch('fs_uae_wrapper.utils.create_archive')
|
@mock.patch('fs_uae_wrapper.utils.create_archive')
|
||||||
@mock.patch('fs_uae_wrapper.base.Base._get_title')
|
@mock.patch('fs_uae_wrapper.base.Base._get_title')
|
||||||
@mock.patch('fs_uae_wrapper.base.Base._save_save')
|
|
||||||
@mock.patch('fs_uae_wrapper.base.Base._get_saves_dir')
|
@mock.patch('fs_uae_wrapper.base.Base._get_saves_dir')
|
||||||
def test_make_archive(self, sdir, save, title, carch, rmt, unlink, rename):
|
def test_make_archive(self, sdir, title, carch, rmt, unlink, rename):
|
||||||
|
|
||||||
sdir.return_value = None
|
sdir.return_value = None
|
||||||
save.return_value = False
|
|
||||||
title.return_value = ''
|
title.return_value = ''
|
||||||
carch.return_value = False
|
carch.return_value = False
|
||||||
|
|
||||||
@@ -107,7 +109,4 @@ class TestArchive(TestCase):
|
|||||||
self.assertTrue(arch._make_archive())
|
self.assertTrue(arch._make_archive())
|
||||||
|
|
||||||
sdir.return_value = '/some/path'
|
sdir.return_value = '/some/path'
|
||||||
self.assertFalse(arch._make_archive())
|
|
||||||
|
|
||||||
save.return_value = True
|
|
||||||
self.assertTrue(arch._make_archive())
|
self.assertTrue(arch._make_archive())
|
||||||
|
|||||||
Reference in New Issue
Block a user