Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/cwltool/tests/test_pathmapper.py @ 5:9b1c78e6ba9c draft default tip
"planemo upload commit 6c0a8142489327ece472c84e558c47da711a9142"
| author | shellac |
|---|---|
| date | Mon, 01 Jun 2020 08:59:25 -0400 |
| parents | 79f47841a781 |
| children |
comparison
equal
deleted
inserted
replaced
| 4:79f47841a781 | 5:9b1c78e6ba9c |
|---|---|
| 1 import pytest | |
| 2 | |
| 3 from cwltool.pathmapper import PathMapper, normalizeFilesDirs | |
| 4 | |
| 5 | |
| 6 def test_subclass(): | |
| 7 class SubPathMapper(PathMapper): | |
| 8 def __init__(self, referenced_files, basedir, stagedir, new): | |
| 9 super(SubPathMapper, self).__init__(referenced_files, basedir, stagedir) | |
| 10 self.new = new | |
| 11 | |
| 12 pathmap = SubPathMapper([], '', '', 'new') | |
| 13 assert pathmap.new is not None, 'new' | |
| 14 | |
| 15 normalization_parameters = [ | |
| 16 ('strip trailing slashes', | |
| 17 {'class': 'Directory', | |
| 18 'location': '/foo/bar/' | |
| 19 }, | |
| 20 {'class': 'Directory', | |
| 21 'location': '/foo/bar', | |
| 22 'basename': 'bar' | |
| 23 } | |
| 24 ), | |
| 25 ('file', | |
| 26 {'class': 'File', | |
| 27 'location': 'file1.txt' | |
| 28 }, | |
| 29 {'class': 'File', | |
| 30 'location': 'file1.txt', | |
| 31 'basename': 'file1.txt', | |
| 32 'nameext': '.txt', | |
| 33 'nameroot': 'file1' | |
| 34 } | |
| 35 ), | |
| 36 ('file with local uri', | |
| 37 {'class': 'File', | |
| 38 'location': 'file:///foo/file1.txt' | |
| 39 }, | |
| 40 {'class': 'File', | |
| 41 'location': 'file:///foo/file1.txt', | |
| 42 'basename': 'file1.txt', | |
| 43 'nameext': '.txt', | |
| 44 'nameroot': 'file1' | |
| 45 } | |
| 46 ), | |
| 47 ('file with http url', | |
| 48 {'class': 'File', | |
| 49 'location': 'http://example.com/file1.txt' | |
| 50 }, | |
| 51 {'class': 'File', | |
| 52 'location': 'http://example.com/file1.txt', | |
| 53 'basename': 'file1.txt', | |
| 54 'nameext': '.txt', | |
| 55 'nameroot': 'file1' | |
| 56 } | |
| 57 ) | |
| 58 ] | |
| 59 | |
| 60 @pytest.mark.parametrize('name,file_dir,expected', normalization_parameters) | |
| 61 def test_normalizeFilesDirs(name, file_dir, expected): | |
| 62 normalizeFilesDirs(file_dir) | |
| 63 assert file_dir == expected, name | |
| 64 | |
| 65 # (filename, expected: (nameroot, nameext)) | |
| 66 basename_generation_parameters = [ | |
| 67 ('foo.bar', ('foo', '.bar')), | |
| 68 ('foo', ('foo', '')), | |
| 69 ('.foo', ('.foo', '')), | |
| 70 ('foo.', ('foo', '.')), | |
| 71 ('foo.bar.baz', ('foo.bar', '.baz')) | |
| 72 ] | |
| 73 @pytest.mark.parametrize('filename,expected', basename_generation_parameters) | |
| 74 def test_basename_field_generation(filename, expected): | |
| 75 nameroot, nameext = expected | |
| 76 expected = { | |
| 77 'class': 'File', | |
| 78 'location': '/foo/' + filename, | |
| 79 'basename': filename, | |
| 80 'nameroot': nameroot, | |
| 81 'nameext': nameext | |
| 82 } | |
| 83 | |
| 84 file = { | |
| 85 'class': 'File', | |
| 86 'location': '/foo/' + filename | |
| 87 } | |
| 88 | |
| 89 normalizeFilesDirs(file) | |
| 90 assert file == expected |
