mirror of
https://github.com/gryf/fs-uae-wrapper.git
synced 2025-12-19 04:20:23 +01:00
Fix tests for file path calculations
This commit is contained in:
@@ -47,9 +47,11 @@ class TestBase(TestCase):
|
||||
bobj.clean()
|
||||
self.assertFalse(os.path.exists(self.dirname))
|
||||
|
||||
@mock.patch('os.path.exists')
|
||||
@mock.patch('fs_uae_wrapper.utils.get_config')
|
||||
def test_normalize_options(self, get_config):
|
||||
def test_normalize_options(self, get_config, os_exists):
|
||||
|
||||
os_exists.return_value = True
|
||||
bobj = base.Base('Config.fs-uae', utils.CmdOption(), {})
|
||||
|
||||
get_config.return_value = {'kickstarts_dir': '/some/path'}
|
||||
@@ -92,6 +94,28 @@ class TestBase(TestCase):
|
||||
bobj._normalize_options()
|
||||
self.assertDictEqual(bobj.fsuae_options, {})
|
||||
|
||||
@mock.patch('os.path.exists')
|
||||
@mock.patch('fs_uae_wrapper.utils.get_config')
|
||||
def test_normalize_options_path_not_exists(self, get_config, os_exists):
|
||||
|
||||
os_exists.return_value = False
|
||||
bobj = base.Base('Config.fs-uae', utils.CmdOption(), {})
|
||||
|
||||
get_config.return_value = {'kickstarts_dir': '/some/path'}
|
||||
bobj._normalize_options()
|
||||
self.assertDictEqual(bobj.fsuae_options, {})
|
||||
|
||||
os.chdir(self.dirname)
|
||||
get_config.return_value = {'fmv_rom': 'bar'}
|
||||
bobj._normalize_options()
|
||||
self.assertDictEqual(bobj.fsuae_options, {'fmv_rom': 'bar'})
|
||||
|
||||
get_config.return_value = {'floppies_dir': '../some/path'}
|
||||
bobj.fsuae_options = utils.CmdOption()
|
||||
bobj._normalize_options()
|
||||
self.assertDictEqual(bobj.fsuae_options,
|
||||
{'floppies_dir': '../some/path'})
|
||||
|
||||
def test_set_assets_paths(self):
|
||||
|
||||
bobj = base.Base('Config.fs-uae', utils.CmdOption(), {})
|
||||
|
||||
@@ -234,11 +234,13 @@ class TestCmdOptions(TestCase):
|
||||
self.assertListEqual(sorted(cmd.list()),
|
||||
['--fast_memory=4096', '--fullscreen'])
|
||||
|
||||
@mock.patch('os.path.exists')
|
||||
@mock.patch('os.getenv')
|
||||
@mock.patch('os.path.expandvars')
|
||||
@mock.patch('distutils.spawn.find_executable')
|
||||
def test_interpolate_variables(self, find_exe, expandv, getenv):
|
||||
def test_interpolate_variables(self, find_exe, expandv, getenv, os_exists):
|
||||
|
||||
os_exists.return_value = True
|
||||
itrpl = utils.interpolate_variables
|
||||
|
||||
string = '$CONFIG/../path/to/smth'
|
||||
@@ -264,3 +266,11 @@ class TestCmdOptions(TestCase):
|
||||
'$BASE')
|
||||
self.assertEqual(itrpl(string, '/home/user/Config.fs-uae', 'base'),
|
||||
'base')
|
||||
|
||||
@mock.patch('os.getenv')
|
||||
@mock.patch('os.path.expandvars')
|
||||
def test_interpolate_variables_path_not_exists(self, expandv, getenv):
|
||||
itrpl = utils.interpolate_variables
|
||||
|
||||
string = '$CONFIG/../path/to/smth'
|
||||
self.assertEqual(itrpl(string, '/home/user/Config.fs-uae'), string)
|
||||
|
||||
Reference in New Issue
Block a user