Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michiel Cottaar
fslpy
Commits
d89d3eee
Commit
d89d3eee
authored
8 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Many test updates
parent
d6ac1c86
No related branches found
No related tags found
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/test_fsl_utils_path.py
+52
-10
52 additions, 10 deletions
tests/test_fsl_utils_path.py
tests/test_immv_imcp.py
+324
-164
324 additions, 164 deletions
tests/test_immv_imcp.py
with
376 additions
and
174 deletions
tests/test_fsl_utils_path.py
+
52
−
10
View file @
d89d3eee
...
@@ -629,7 +629,7 @@ def test_getFileGroup_imageFiles_shouldPass():
...
@@ -629,7 +629,7 @@ def test_getFileGroup_imageFiles_shouldPass():
allowedExts
=
fslimage
.
ALLOWED_EXTENSIONS
allowedExts
=
fslimage
.
ALLOWED_EXTENSIONS
groups
=
fslimage
.
FILE_GROUPS
groups
=
fslimage
.
FILE_GROUPS
# [(files_to_create, path, files_to_expect),
# [(files_to_create, path, files_to_expect
[, unambiguous]
),
# ...
# ...
# ]
# ]
#
#
...
@@ -666,13 +666,30 @@ def test_getFileGroup_imageFiles_shouldPass():
...
@@ -666,13 +666,30 @@ def test_getFileGroup_imageFiles_shouldPass():
# file groups should still work.
# file groups should still work.
(
'
file.hdr
'
,
'
file
'
,
'
file.hdr
'
),
(
'
file.hdr
'
,
'
file
'
,
'
file.hdr
'
),
(
'
file.hdr
'
,
'
file.hdr
'
,
'
file.hdr
'
),
(
'
file.hdr
'
,
'
file.hdr
'
,
'
file.hdr
'
),
# Unambigiuous paths, when
# unambiguous = True,
# should be ok.
(
'
file.hdr file.img file.nii
'
,
'
file.nii
'
,
'
file.nii
'
,
True
),
(
'
file.hdr file.img file.nii
'
,
'
file.hdr
'
,
'
file.hdr file.img
'
,
True
),
(
'
file.hdr file.img file.nii
'
,
'
file.img
'
,
'
file.hdr file.img
'
,
True
),
]
]
# TODO You need to add passing tests for unambiguous=True
workdir
=
tempfile
.
mkdtemp
()
workdir
=
tempfile
.
mkdtemp
()
try
:
try
:
for
files_to_create
,
path
,
files_to_expect
in
tests
:
for
test
in
tests
:
files_to_create
=
test
[
0
]
path
=
test
[
1
]
files_to_expect
=
test
[
2
]
if
len
(
test
)
==
4
:
unambiguous
=
test
[
3
]
else
:
unambiguous
=
False
files_to_create
=
files_to_create
.
split
()
files_to_create
=
files_to_create
.
split
()
files_to_expect
=
files_to_expect
.
split
()
files_to_expect
=
files_to_expect
.
split
()
...
@@ -690,12 +707,14 @@ def test_getFileGroup_imageFiles_shouldPass():
...
@@ -690,12 +707,14 @@ def test_getFileGroup_imageFiles_shouldPass():
op
.
join
(
workdir
,
path
),
op
.
join
(
workdir
,
path
),
allowedExts
=
allowedExts
,
allowedExts
=
allowedExts
,
fileGroups
=
groups
,
fileGroups
=
groups
,
fullPaths
=
True
)
fullPaths
=
True
,
unambiguous
=
unambiguous
)
exts
=
fslpath
.
getFileGroup
(
exts
=
fslpath
.
getFileGroup
(
op
.
join
(
workdir
,
path
),
op
.
join
(
workdir
,
path
),
allowedExts
=
allowedExts
,
allowedExts
=
allowedExts
,
fileGroups
=
groups
,
fileGroups
=
groups
,
fullPaths
=
False
)
fullPaths
=
False
,
unambiguous
=
unambiguous
)
assert
sorted
(
fullPaths
)
==
sorted
([
op
.
join
(
workdir
,
e
)
for
e
in
files_to_expect
])
assert
sorted
(
fullPaths
)
==
sorted
([
op
.
join
(
workdir
,
e
)
for
e
in
files_to_expect
])
assert
sorted
(
exts
)
==
sorted
([
fslpath
.
getExt
(
e
,
allowedExts
)
for
e
in
files_to_expect
])
assert
sorted
(
exts
)
==
sorted
([
fslpath
.
getExt
(
e
,
allowedExts
)
for
e
in
files_to_expect
])
...
@@ -708,7 +727,7 @@ def test_getFileGroup_imageFiles_shouldPass():
...
@@ -708,7 +727,7 @@ def test_getFileGroup_imageFiles_shouldPass():
def
test_getFileGroup_otherFiles_shouldPass
():
def
test_getFileGroup_otherFiles_shouldPass
():
# (files_to_create, allowedExts, fileGroups, path, files_to_expect)
# (files_to_create, allowedExts, fileGroups, path, files_to_expect
[, unambiguous]
)
tests
=
[
tests
=
[
# allowedExts is None - incomplete paths are not allowed
# allowedExts is None - incomplete paths are not allowed
...
@@ -758,16 +777,34 @@ def test_getFileGroup_otherFiles_shouldPass():
...
@@ -758,16 +777,34 @@ def test_getFileGroup_otherFiles_shouldPass():
(
'
file1.a file1.b file2.c file2.d
'
,
'
.a .b .c .d
'
,
[
'
.a .b
'
,
'
.c .d
'
],
'
file2.c
'
,
'
file2.c file2.d
'
),
(
'
file1.a file1.b file2.c file2.d
'
,
'
.a .b .c .d
'
,
[
'
.a .b
'
,
'
.c .d
'
],
'
file2.c
'
,
'
file2.c file2.d
'
),
(
'
file1.a file1.b file2.c file2.d
'
,
'
.a .b .c .d
'
,
[
'
.a .b
'
,
'
.c .d
'
],
'
file2.d
'
,
'
file2.c file2.d
'
),
(
'
file1.a file1.b file2.c file2.d
'
,
'
.a .b .c .d
'
,
[
'
.a .b
'
,
'
.c .d
'
],
'
file2.d
'
,
'
file2.c file2.d
'
),
# incomplete group
# incomplete group should be ok when
# unambiguous = False (the default)
(
'
file.a
'
,
'
.a .b
'
,
[
'
.a .b
'
],
'
file
'
,
'
file.a
'
),
(
'
file.a
'
,
'
.a .b
'
,
[
'
.a .b
'
],
'
file
'
,
'
file.a
'
),
(
'
file.a
'
,
'
.a .b
'
,
[
'
.a .b
'
],
'
file.a
'
,
'
file.a
'
),
(
'
file.a
'
,
'
.a .b
'
,
[
'
.a .b
'
],
'
file.a
'
,
'
file.a
'
),
# Unambiguous/complete group should
# be ok when unambiguous = True
(
'
file.a file.b file.c
'
,
'
.a .b .c
'
,
[
'
.a .b
'
],
'
file.a
'
,
'
file.a file.b
'
,
True
),
(
'
file.a file.b file.c
'
,
'
.a .b .c
'
,
[
'
.a .b
'
],
'
file.b
'
,
'
file.a file.b
'
,
True
),
(
'
file.a file.b file.c
'
,
'
.a .b .c
'
,
[
'
.a .b
'
],
'
file.c
'
,
'
file.c
'
,
True
),
]
]
workdir
=
tempfile
.
mkdtemp
()
workdir
=
tempfile
.
mkdtemp
()
try
:
try
:
for
files_to_create
,
allowedExts
,
fileGroups
,
path
,
files_to_expect
in
tests
:
for
test
in
tests
:
files_to_create
=
test
[
0
]
allowedExts
=
test
[
1
]
fileGroups
=
test
[
2
]
path
=
test
[
3
]
files_to_expect
=
test
[
4
]
if
len
(
test
)
==
6
:
unambiguous
=
test
[
5
]
else
:
unambiguous
=
False
files_to_create
=
files_to_create
.
split
()
files_to_create
=
files_to_create
.
split
()
allowedExts
=
allowedExts
.
split
()
allowedExts
=
allowedExts
.
split
()
...
@@ -792,12 +829,14 @@ def test_getFileGroup_otherFiles_shouldPass():
...
@@ -792,12 +829,14 @@ def test_getFileGroup_otherFiles_shouldPass():
op
.
join
(
workdir
,
path
),
op
.
join
(
workdir
,
path
),
allowedExts
=
allowedExts
,
allowedExts
=
allowedExts
,
fileGroups
=
fileGroups
,
fileGroups
=
fileGroups
,
fullPaths
=
True
)
fullPaths
=
True
,
unambiguous
=
unambiguous
)
exts
=
fslpath
.
getFileGroup
(
exts
=
fslpath
.
getFileGroup
(
op
.
join
(
workdir
,
path
),
op
.
join
(
workdir
,
path
),
allowedExts
=
allowedExts
,
allowedExts
=
allowedExts
,
fileGroups
=
fileGroups
,
fileGroups
=
fileGroups
,
fullPaths
=
False
)
fullPaths
=
False
,
unambiguous
=
unambiguous
)
assert
sorted
(
fullPaths
)
==
sorted
([
op
.
join
(
workdir
,
e
)
for
e
in
files_to_expect
])
assert
sorted
(
fullPaths
)
==
sorted
([
op
.
join
(
workdir
,
e
)
for
e
in
files_to_expect
])
assert
sorted
(
exts
)
==
sorted
([
fslpath
.
getExt
(
e
,
allowedExts
)
for
e
in
files_to_expect
])
assert
sorted
(
exts
)
==
sorted
([
fslpath
.
getExt
(
e
,
allowedExts
)
for
e
in
files_to_expect
])
...
@@ -837,7 +876,10 @@ def test_getFileGroup_shouldFail():
...
@@ -837,7 +876,10 @@ def test_getFileGroup_shouldFail():
(
'
file.hdr
'
,
'
file
'
,
allowedExts
,
fileGroups
,
True
),
(
'
file.hdr
'
,
'
file
'
,
allowedExts
,
fileGroups
,
True
),
(
'
file.hdr
'
,
'
file.hdr
'
,
allowedExts
,
fileGroups
,
True
),
(
'
file.hdr
'
,
'
file.hdr
'
,
allowedExts
,
fileGroups
,
True
),
(
'
file.img
'
,
'
file
'
,
allowedExts
,
fileGroups
,
True
),
(
'
file.img
'
,
'
file
'
,
allowedExts
,
fileGroups
,
True
),
(
'
file.img
'
,
'
file.img
'
,
allowedExts
,
fileGroups
,
True
),
(
'
file.img
'
,
'
file.img
'
,
allowedExts
,
fileGroups
,
True
),
# Part of more than one group, when unambiguous is True
(
'
file.a file.b file.c
'
,
'
file.a
'
,
'
.a .b
'
,
[
'
.a .b
'
,
'
.a .c
'
],
True
),
]
]
workdir
=
tempfile
.
mkdtemp
()
workdir
=
tempfile
.
mkdtemp
()
...
...
This diff is collapsed.
Click to expand it.
tests/test_immv_imcp.py
+
324
−
164
View file @
d89d3eee
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment