Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pycalibration
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Contributor 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
calibration
pycalibration
Commits
d9bbb032
Unverified
Commit
d9bbb032
authored
4 years ago
by
Robert Rosca
Browse files
Options
Downloads
Patches
Plain Diff
Add user notebook tests
parent
1639338f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_xfel_calibrate/test_cli.py
+60
-0
60 additions, 0 deletions
tests/test_xfel_calibrate/test_cli.py
with
60 additions
and
0 deletions
tests/test_xfel_calibrate/test_cli.py
+
60
−
0
View file @
d9bbb032
...
@@ -8,6 +8,7 @@ the current test cases, this should be improved later on.
...
@@ -8,6 +8,7 @@ the current test cases, this should be improved later on.
import
ast
import
ast
import
sys
import
sys
import
shutil
from
datetime
import
date
from
datetime
import
date
from
pathlib
import
Path
from
pathlib
import
Path
from
unittest
import
mock
from
unittest
import
mock
...
@@ -243,6 +244,65 @@ class TestIntelliList:
...
@@ -243,6 +244,65 @@ class TestIntelliList:
assert
parameters
[
"
concurrency_parameter
"
][
0
]
==
i
+
1
assert
parameters
[
"
concurrency_parameter
"
][
0
]
==
i
+
1
class
TestUserNotebooks
:
@pytest.fixture
(
scope
=
"
class
"
)
def
mock_proposal
(
self
,
tmpdir_factory
):
return
MockProposal
(
tmp_path
=
Path
(
tmpdir_factory
.
mktemp
(
"
exp
"
)),
instrument
=
"
AGIPD
"
,
cycle
=
"
202031
"
,
proposal
=
"
p900113
"
,
runs
=
1
,
sequences
=
1
,
)
@pytest.fixture
(
scope
=
"
function
"
)
def
calibrate_call
(
self
,
mock_proposal
:
MockProposal
,
capsys
,
tmp_path
:
Path
):
# The user notebook path template for `TEST`/`TEST-USER-NB` is:
# `"/{instrumen}/{cycle}/p{proposal}/test-cli.ipynb"`
#
# So by setting `instrument` to tmp_path/TEST we set the user notebook
# location to one in our tmp dir
self
.
user_nb
=
mock_proposal
.
path_usr
/
"
test-cli.ipynb
"
shutil
.
copy
(
Path
(
"
./notebooks/test/test-cli.ipynb
"
).
absolute
(),
str
(
self
.
user_nb
)
)
return
CalibrateCall
(
tmp_path
,
capsys
,
in_folder
=
mock_proposal
.
path_raw
,
out_folder
=
mock_proposal
.
path_proc
,
detector
=
"
TEST
"
,
cal_type
=
"
TEST-USER-NB
"
,
extra_args
=
[
"
--root
"
,
str
(
mock_proposal
.
path_usr
),
"
--number
"
,
"
10
"
,
],
)
def
test_user_notebook_is_test_notebook
(
self
,
calibrate_call
:
CalibrateCall
):
assert
(
Path
(
"
./notebooks/test/test-cli.ipynb
"
).
read_bytes
()
==
self
.
user_nb
.
read_bytes
()
)
def
test_output_ipynb
(
self
,
calibrate_call
:
CalibrateCall
):
notebook_path
=
calibrate_call
.
paths
.
notebooks
assert
len
(
notebook_path
)
==
1
with
notebook_path
[
0
].
open
()
as
file
:
notebook
=
nbformat
.
read
(
file
,
as_version
=
4
)
parameters
=
{
p
.
name
:
p
.
value
for
p
in
extract_parameters
(
notebook
)}
assert
parameters
[
"
number
"
]
==
10
class
TestAgipdNotebook
:
class
TestAgipdNotebook
:
@pytest.fixture
(
scope
=
"
function
"
)
@pytest.fixture
(
scope
=
"
function
"
)
def
mock_proposal
(
self
,
tmpdir_factory
):
def
mock_proposal
(
self
,
tmpdir_factory
):
...
...
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