mirror of
https://github.com/gryf/fs-uae-wrapper.git
synced 2026-01-05 21:34:17 +01:00
Setting assets paths in base class
This commit is contained in:
@@ -40,7 +40,6 @@ class Archive(base.Base):
|
|||||||
if not super(Archive, self).run():
|
if not super(Archive, self).run():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self._set_assets_paths()
|
|
||||||
if not self._extract():
|
if not self._extract():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ class Base(object):
|
|||||||
|
|
||||||
self.dir = tempfile.mkdtemp()
|
self.dir = tempfile.mkdtemp()
|
||||||
|
|
||||||
|
self._set_assets_paths()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
@@ -91,15 +93,17 @@ class Base(object):
|
|||||||
conf_base = os.path.basename(self.conf_file)
|
conf_base = os.path.basename(self.conf_file)
|
||||||
conf_base = os.path.splitext(conf_base)[0]
|
conf_base = os.path.splitext(conf_base)[0]
|
||||||
|
|
||||||
arch = self.all_options['wrapper_archive']
|
arch = self.all_options.get('wrapper_archive')
|
||||||
if os.path.isabs(arch):
|
if arch:
|
||||||
self.arch_filepath = arch
|
if os.path.isabs(arch):
|
||||||
else:
|
self.arch_filepath = arch
|
||||||
self.arch_filepath = os.path.join(conf_abs_dir, arch)
|
else:
|
||||||
|
self.arch_filepath = os.path.join(conf_abs_dir, arch)
|
||||||
# set optional save_state
|
# set optional save_state
|
||||||
arch_ext = utils.get_arch_ext(self.all_options['wrapper_archiver'])
|
arch_ext = utils.get_arch_ext(self.all_options.get('wrapper_archiver'))
|
||||||
self.save_filename = os.path.join(conf_abs_dir, conf_base + '_save' +
|
if arch_ext:
|
||||||
arch_ext)
|
self.save_filename = os.path.join(conf_abs_dir, conf_base +
|
||||||
|
'_save' + arch_ext)
|
||||||
|
|
||||||
def _copy_conf(self):
|
def _copy_conf(self):
|
||||||
"""copy provided configuration as Config.fs-uae"""
|
"""copy provided configuration as Config.fs-uae"""
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ class CD32(base.Base):
|
|||||||
if not self._validate_options():
|
if not self._validate_options():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self._set_assets_paths()
|
|
||||||
if not self._extract():
|
if not self._extract():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
@@ -146,16 +146,18 @@ class TestBase(TestCase):
|
|||||||
@mock.patch('fs_uae_wrapper.utils.create_archive')
|
@mock.patch('fs_uae_wrapper.utils.create_archive')
|
||||||
def test_save_save(self, carch, saves_dir):
|
def test_save_save(self, carch, saves_dir):
|
||||||
|
|
||||||
bobj = base.Base('Config.fs-uae', utils.CmdOption(), {})
|
os.chdir(self.confdir)
|
||||||
|
|
||||||
|
bobj = base.Base('myconf.fs-uae', utils.CmdOption(), {})
|
||||||
bobj.dir = self.dirname
|
bobj.dir = self.dirname
|
||||||
bobj.save_filename = 'foobar_save.7z'
|
bobj.save_filename = os.path.join(self.confdir, 'myconf_save.7z')
|
||||||
saves_dir.bobj.save_filenamereturn_value = None
|
|
||||||
|
saves_dir.return_value = None
|
||||||
carch.return_value = True
|
carch.return_value = True
|
||||||
|
|
||||||
self.assertTrue(bobj._save_save())
|
self.assertTrue(bobj._save_save())
|
||||||
|
|
||||||
saves_dir.return_value = bobj.save_filename
|
saves_dir.return_value = bobj.save_filename
|
||||||
os.chdir(self.confdir)
|
|
||||||
with open(bobj.save_filename, 'w') as fobj:
|
with open(bobj.save_filename, 'w') as fobj:
|
||||||
fobj.write('asd')
|
fobj.write('asd')
|
||||||
|
|
||||||
@@ -218,6 +220,9 @@ class TestBase(TestCase):
|
|||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
self.assertEqual(bobj._get_saves_dir(), 'saves')
|
self.assertEqual(bobj._get_saves_dir(), 'saves')
|
||||||
|
|
||||||
|
bobj.all_options['save_states_dir'] = '$CONFIG/saves/'
|
||||||
|
self.assertEqual(bobj._get_saves_dir(), 'saves')
|
||||||
|
|
||||||
@mock.patch('fs_uae_wrapper.path.which')
|
@mock.patch('fs_uae_wrapper.path.which')
|
||||||
def test_validate_options(self, which):
|
def test_validate_options(self, which):
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user