Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD 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
FSL
fslpy
Commits
4858ff09
Commit
4858ff09
authored
4 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
TEST: test imln
parent
de3a09cb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_scripts/test_imln.py
+117
-0
117 additions, 0 deletions
tests/test_scripts/test_imln.py
with
117 additions
and
0 deletions
tests/test_scripts/test_imln.py
0 → 100644
+
117
−
0
View file @
4858ff09
#!/usr/bin/env python
#
# test_imln.py -
#
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
import
os
import
os.path
as
op
from
unittest
import
mock
import
pytest
from
fsl.utils.tempdir
import
tempdir
import
fsl.utils.path
as
fslpath
import
fsl.scripts.imln
as
imln
from
tests
import
touch
def
test_usage
():
assert
imln
.
main
([])
!=
0
with
mock
.
patch
(
'
sys.argv
'
,
[]):
assert
imln
.
main
()
!=
0
def
test_imln
():
# (files, command, expected links)
tests
=
[
(
'
a.nii
'
,
'
a.nii link.nii
'
,
'
link.nii
'
),
(
'
a.nii
'
,
'
a link
'
,
'
link.nii
'
),
(
'
a.nii
'
,
'
a.nii link
'
,
'
link.nii
'
),
(
'
a.nii
'
,
'
a link.nii
'
,
'
link.nii
'
),
(
'
a.nii
'
,
'
a link.nii.gz
'
,
'
link.nii
'
),
(
'
a.nii.gz
'
,
'
a.nii.gz link.nii.gz
'
,
'
link.nii.gz
'
),
(
'
a.nii.gz
'
,
'
a link
'
,
'
link.nii.gz
'
),
(
'
a.nii.gz
'
,
'
a.nii.gz link
'
,
'
link.nii.gz
'
),
(
'
a.nii.gz
'
,
'
a link.nii.gz
'
,
'
link.nii.gz
'
),
(
'
a.nii.gz
'
,
'
a link.nii
'
,
'
link.nii.gz
'
),
(
'
a.img a.hdr
'
,
'
a link
'
,
'
link.img link.hdr
'
),
(
'
a.img a.hdr
'
,
'
a link.img
'
,
'
link.img link.hdr
'
),
(
'
a.img a.hdr
'
,
'
a link.hdr
'
,
'
link.img link.hdr
'
),
(
'
a.img a.hdr
'
,
'
a.img link
'
,
'
link.img link.hdr
'
),
(
'
a.img a.hdr
'
,
'
a.hdr link
'
,
'
link.img link.hdr
'
),
(
'
a.img a.hdr
'
,
'
a.img link.img
'
,
'
link.img link.hdr
'
),
(
'
a.img a.hdr
'
,
'
a.hdr link.hdr
'
,
'
link.img link.hdr
'
),
(
'
a.img a.hdr
'
,
'
a.img link.hdr
'
,
'
link.img link.hdr
'
),
(
'
a.img a.hdr
'
,
'
a.hdr link.img
'
,
'
link.img link.hdr
'
),
]
for
files
,
command
,
explinks
in
tests
:
with
tempdir
():
files
=
files
.
split
()
command
=
command
.
split
()
explinks
=
explinks
.
split
()
for
f
in
files
:
touch
(
f
)
assert
imln
.
main
(
command
)
==
0
assert
sorted
(
os
.
listdir
(
'
.
'
))
==
sorted
(
files
+
explinks
)
for
f
,
l
in
zip
(
sorted
(
files
),
sorted
(
explinks
)):
assert
op
.
islink
(
l
)
assert
op
.
isfile
(
f
)
and
not
op
.
islink
(
f
)
assert
op
.
realpath
(
l
)
==
op
.
abspath
(
f
)
# subdirs - imln currently only
# works with absolute paths (we
# make all paths absolute below)
tests
=
[
(
'
dir/a.nii
'
,
'
dir/a dir/link
'
,
'
dir/link.nii
'
),
(
'
dir/a.img dir/a.hdr
'
,
'
dir/a dir/link
'
,
'
dir/link.img dir/link.hdr
'
),
(
'
dir/a.nii
'
,
'
dir/a link
'
,
'
link.nii
'
),
(
'
dir/a.img dir/a.hdr
'
,
'
dir/a link
'
,
'
link.img link.hdr
'
),
(
'
a.nii
'
,
'
a dir/link
'
,
'
dir/link.nii
'
),
(
'
a.img a.hdr
'
,
'
a dir/link
'
,
'
dir/link.img dir/link.hdr
'
),
]
for
files
,
command
,
explinks
in
tests
:
with
tempdir
():
files
=
files
.
split
()
command
=
[
op
.
abspath
(
c
)
for
c
in
command
.
split
()]
explinks
=
explinks
.
split
()
os
.
mkdir
(
'
dir
'
)
for
f
in
files
:
touch
(
f
)
assert
imln
.
main
(
command
)
==
0
for
f
,
l
in
zip
(
sorted
(
files
),
sorted
(
explinks
)):
assert
op
.
islink
(
l
)
assert
op
.
isfile
(
f
)
and
not
op
.
islink
(
f
)
assert
op
.
realpath
(
l
)
==
op
.
abspath
(
f
)
# error cases
# (files, commnad)
tests
=
[
(
'
a.img
'
,
'
a link
'
),
(
'
a.nii a.img a.hdr
'
,
'
a link
'
),
]
for
files
,
command
in
tests
:
with
tempdir
():
files
=
files
.
split
()
command
=
command
.
split
()
for
f
in
files
:
touch
(
f
)
assert
imln
.
main
(
command
)
!=
0
assert
sorted
(
os
.
listdir
(
'
.
'
))
==
sorted
(
files
)
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