Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review 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
mantidproject
mantid
Commits
ad720bea
Commit
ad720bea
authored
5 years ago
by
Lorenzo Basso
Browse files
Options
Downloads
Patches
Plain Diff
refs #26353. Added tests for load utils
parent
a1fe28f2
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scripts/Muon/GUI/ElementalAnalysis/LoadWidget/load_utils.py
+2
-3
2 additions, 3 deletions
scripts/Muon/GUI/ElementalAnalysis/LoadWidget/load_utils.py
scripts/test/Muon/elemental_analysis/LoadWidgetModel_test.py
+20
-2
20 additions, 2 deletions
scripts/test/Muon/elemental_analysis/LoadWidgetModel_test.py
with
22 additions
and
5 deletions
scripts/Muon/GUI/ElementalAnalysis/LoadWidget/load_utils.py
+
2
−
3
View file @
ad720bea
...
...
@@ -54,7 +54,7 @@ class LModel(object):
def
pad_run
(
run
):
"""
Pads run number: i.e. 123 -> 00123; 2695
-
> 02695
"""
"""
Pads run number: i.e. 123 -> 00123; 2695
-
> 02695
"""
return
str
(
run
).
zfill
(
5
)
...
...
@@ -138,8 +138,7 @@ def flatten_run_data(*workspaces):
out
=
[]
for
workspace
in
workspaces
:
detectors
=
[
mantid
.
mtd
[
detector
]
for
detector
in
workspace
]
out
.
append
(
sorted
([
_workspace
.
getName
()
for
detector
in
detectors
for
_workspace
in
detector
]))
out
.
append
(
sorted
([
_workspace
.
getName
()
for
detector
in
detectors
for
_workspace
in
detector
]))
return
out
...
...
This diff is collapsed.
Click to expand it.
scripts/test/Muon/elemental_analysis/LoadWidgetModel_test.py
+
20
−
2
View file @
ad720bea
...
...
@@ -31,26 +31,44 @@ class LoadUtilsTest(unittest.TestCase):
for
run
,
padded_run
in
iteritems
(
tests
):
self
.
assertEqual
(
lutils
.
pad_run
(
run
),
padded_run
)
@mock.patch
(
'
Muon.GUI.ElementalAnalysis.LoadWidget.load_utils.glob.iglob
'
)
@mock.patch
(
'
Muon.GUI.ElementalAnalysis.LoadWidget.load_utils.os.path.join
'
)
def
test_that_search_user_dirs_explores_all_directories
(
self
,
mock_join
,
mock_iglob
):
expected_len
=
len
(
config
[
"
datasearch.directories
"
].
split
(
"
;
"
))
lutils
.
search_user_dirs
(
self
.
test_run
)
self
.
assertEqual
(
mock_join
.
call_count
,
expected_len
)
def
test_get_detector_num_from_ws
(
self
):
self
.
assertEquals
(
lutils
.
get_detector_num_from_ws
(
self
.
test_ws_name
),
"
1
"
)
def
test_get_detectors_num
(
self
):
self
.
assertEqual
(
lutils
.
get_detectors_num
(
self
.
test_path
),
"
1
"
)
def
test_get_detectors_num_throws_with_bad_input
(
self
):
input
=
[
'
only.one_separator
'
,
'
one.much_longer32123.three
'
]
for
value
in
input
:
with
self
.
assertRaises
(
Exception
):
lutils
.
get_detectors_num
(
value
)
def
test_get_end_num
(
self
):
self
.
assertEqual
(
lutils
.
get_end_num
(
self
.
test_path
),
"
rooth2020
"
)
def
test_get_run_type
(
self
):
self
.
assertEqual
(
lutils
.
get_run_type
(
self
.
test_path
),
"
Delayed
"
)
self
.
assertEqual
(
lutils
.
get_run_type
(
'
a.b10.c
'
),
"
Prompt
"
)
self
.
assertEqual
(
lutils
.
get_run_type
(
'
a.b99.c
'
),
"
Total
"
)
with
self
.
assertRaises
(
KeyError
):
lutils
.
get_run_type
(
self
.
bad_path
)
def
test_get_filename
(
self
):
self
.
assertEquals
(
lutils
.
get_filename
(
self
.
test_path
,
self
.
test_run
),
self
.
test_ws_name
)
def
test_get_filename_returns_none_if_given_bad_path
(
self
):
self
.
assertEqual
(
lutils
.
get_filename
(
self
.
bad_path
,
self
.
test_run
),
None
)
def
test_hyphenise
(
self
):
tests
=
{
"
1-5
"
:
[
1
,
2
,
3
,
4
,
5
],
"
1, 4-5
"
:
[
1
,
4
,
5
],
"
1-3, 5
"
:
[
1
,
3
,
2
,
5
],
"
1, 3, 5
"
:
[
1
,
5
,
3
]}
tests
=
{
"
1-5
"
:
[
1
,
2
,
3
,
4
,
5
],
"
1, 4-5
"
:
[
1
,
4
,
5
],
"
1-3, 5
"
:
[
1
,
3
,
2
,
5
],
"
1, 3, 5
"
:
[
1
,
5
,
3
]}
for
out
,
arg
in
iteritems
(
tests
):
self
.
assertEqual
(
lutils
.
hyphenise
(
arg
),
out
)
...
...
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