Skip to content
Snippets Groups Projects

New fsl_generate_module_manifest command

Merged Paul McCarthy requested to merge mnt/size into master
11 files
+ 344
92
Compare changes
  • Side-by-side
  • Inline
Files
11
@@ -73,14 +73,14 @@ def test_loadManifest_different_sources():
with pytest.raises(RuntimeError):
fam.loadManifest(fam.parseArgs(['-m', 'nomanifest']))
# otherwise should work ok
# Specify plugin URL
m, p = fam.loadManifest(
fam.parseArgs(['-m', 'nomanifest', 'http://abc.com/plugin.zip']))
assert p == ['plugin.zip']
assert list(m.keys()) == ['plugin.zip']
# default manifest
with mock.patch('fsl.scripts.fsl_add_module.DEFAULT_MANIFEST_URL', url):
with mock.patch('fsl.scripts.fsl_add_module.DEFAULT_MANIFEST', url):
m, p = fam.loadManifest(fam.parseArgs([]))
assert len(p) == 0
assert list(m.keys()) == ['abc', 'def']
@@ -158,7 +158,7 @@ def test_loadManifest_destination_specified():
def test_selectPlugins_from_filepath_and_url():
with mock.patch('fsl.scripts.fsl_add_module.DEFAULT_MANIFEST_URL', None):
with mock.patch('fsl.scripts.fsl_add_module.DEFAULT_MANIFEST', None):
args = fam.parseArgs('abc.zip def.zip -d dest'.split())
m, p = fam.loadManifest(args)
plugins = fam.selectPlugins(args, m, p)
@@ -188,7 +188,7 @@ def test_selectPlugins_name_from_manifest():
def test_selectPlugins_no_destination_specified():
with mock.patch('fsl.scripts.fsl_add_module.DEFAULT_MANIFEST_URL', None):
with mock.patch('fsl.scripts.fsl_add_module.DEFAULT_MANIFEST', None):
args = fam.parseArgs('abc.zip def.zip'.split())
m, p = fam.loadManifest(args)
@@ -389,9 +389,9 @@ def test_main_noargs():
# patch os.environ in case FSLDIR is set
fammod = 'fsl.scripts.fsl_add_module'
with mock.patch(f'{fammod}.DEFAULT_MANIFEST_URL', f'{cwd}/manifest.json'), \
mock.patch(f'{fammod}.DEFAULT_CATEGORY', None), \
mock.patch(f'{fammod}.ARCHIVE_DIR', f'{cwd}/archives'), \
with mock.patch(f'{fammod}.DEFAULT_MANIFEST', f'{cwd}/manifest.json'), \
mock.patch(f'{fammod}.DEFAULT_CATEGORY', None), \
mock.patch(f'{fammod}.ARCHIVE_DIR', f'{cwd}/archives'), \
mock.patch.dict(os.environ, clear=True):
# user will be asked what plugins they want,
@@ -414,7 +414,7 @@ def test_main_list():
with open('manifest.json', 'wt') as f:
f.write(json.dumps(manifest))
with mock.patch('fsl.scripts.fsl_add_module.DEFAULT_MANIFEST_URL',
with mock.patch('fsl.scripts.fsl_add_module.DEFAULT_MANIFEST',
f'{cwd}/manifest.json'):
fam.main(['-l'])
fam.main('-l -v'.split())
@@ -511,8 +511,8 @@ def test_main_plugin_paths():
args = f'./abc.zip http://localhost:{srv.port}/def.zip'.split()
fammod = 'fsl.scripts.fsl_add_module'
with mock.patch(f'{fammod}.DEFAULT_MANIFEST_URL', None), \
mock.patch(f'{fammod}.ARCHIVE_DIR', f'{cwd}/archives'), \
with mock.patch(f'{fammod}.DEFAULT_MANIFEST', None), \
mock.patch(f'{fammod}.ARCHIVE_DIR', f'{cwd}/archives'), \
mock.patch.dict(os.environ, clear=True):
with mock_input(''):
@@ -615,7 +615,7 @@ def test_main_skip_already_downloaded():
# direct download - if file exists, it is
# assumed to be ok, and not re-downloaded.
with mock.patch('fsl.scripts.fsl_add_module.DEFAULT_MANIFEST_URL', None):
with mock.patch('fsl.scripts.fsl_add_module.DEFAULT_MANIFEST', None):
fam.main(f'{url["abc"]} -a {archiveDir} -d {destDir} -f'.split())
assert os.stat(archivePath['abc']).st_mtime_ns == mtime['abc']
check_dir(destDir, ['a/b', 'c/d'])
@@ -652,7 +652,7 @@ def test_main_customise_plugin_dir():
os.mkdir(defdest)
os.mkdir(ghidest)
with mock.patch('fsl.scripts.fsl_add_module.DEFAULT_MANIFEST_URL', None), \
with mock.patch('fsl.scripts.fsl_add_module.DEFAULT_MANIFEST', None), \
mock_input('c', abcdest, defdest, ghidest):
fam.main(f'abc.zip def.zip ghi.zip'.split())
@@ -743,7 +743,7 @@ def test_default_categories():
make_archive('d.zip', 'd/d.txt')
# default -> only fsl_course_data downloaded
with mock.patch('fsl.scripts.fsl_add_module.DEFAULT_MANIFEST_URL',
with mock.patch('fsl.scripts.fsl_add_module.DEFAULT_MANIFEST',
f'{cwd}/manifest.json'):
fam.main('-f -a archives -d .'.split())
check_dir('.',
@@ -758,7 +758,7 @@ def test_default_categories():
shutil.rmtree('d')
# --category all -> all modules downloaded
with mock.patch('fsl.scripts.fsl_add_module.DEFAULT_MANIFEST_URL',
with mock.patch('fsl.scripts.fsl_add_module.DEFAULT_MANIFEST',
f'{cwd}/manifest.json'):
fam.main('-f -a archives -d . -c all'.split())
check_dir('.',
@@ -775,7 +775,7 @@ def test_default_categories():
shutil.rmtree('d')
# --category <something> -> <something> modules downloaded
with mock.patch('fsl.scripts.fsl_add_module.DEFAULT_MANIFEST_URL',
with mock.patch('fsl.scripts.fsl_add_module.DEFAULT_MANIFEST',
f'{cwd}/manifest.json'):
fam.main('-f -a archives -d . -c patches'.split())
check_dir('.',
Loading