Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pyjapc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
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
scripting-tools
pyjapc
Commits
c47e93c6
Commit
c47e93c6
authored
3 months ago
by
Philip Elson
Browse files
Options
Downloads
Plain Diff
Merge branch 'feature/mockito-5-workaround' into 'master'
mockito 5 workaround See merge request
!112
parents
f5344c0d
c39d8262
No related branches found
No related tags found
1 merge request
!112
mockito 5 workaround
Pipeline
#11971717
running
Stage: build
Stage: test
Changes
3
Pipelines
80
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pyjapc/tests/conftest.py
+11
-0
11 additions, 0 deletions
pyjapc/tests/conftest.py
pyjapc/tests/test_getNextParamValue.py
+6
-9
6 additions, 9 deletions
pyjapc/tests/test_getNextParamValue.py
pyjapc/tests/test_subscribeParam.py
+2
-5
2 additions, 5 deletions
pyjapc/tests/test_subscribeParam.py
with
19 additions
and
14 deletions
pyjapc/tests/conftest.py
+
11
−
0
View file @
c47e93c6
...
@@ -118,3 +118,14 @@ def japc_mock(jvm) -> typing.Generator[typing.Type["cern.japc.ext.mockito.JapcMo
...
@@ -118,3 +118,14 @@ def japc_mock(jvm) -> typing.Generator[typing.Type["cern.japc.ext.mockito.JapcMo
yield
mock
yield
mock
mock
.
resetToDefault
()
mock
.
resetToDefault
()
mock
.
mockNoService
()
mock
.
mockNoService
()
@pytest.fixture
def
japc_set
(
jvm
):
cern
=
jp
.
JPackage
(
'
cern
'
)
JapcUtils
=
cern
.
japc
.
core
.
util
.
JapcUtils
def
setter
(
param
,
selector
,
value
):
result
=
JapcUtils
.
setValuesAsync
({
param
:
value
},
selector
)
exception
=
result
.
values
().
iterator
().
next
().
getException
()
if
exception
is
not
None
:
raise
RuntimeError
(
exception
.
getMessage
())
return
setter
This diff is collapsed.
Click to expand it.
pyjapc/tests/test_getNextParamValue.py
+
6
−
9
View file @
c47e93c6
...
@@ -3,12 +3,10 @@ import time
...
@@ -3,12 +3,10 @@ import time
import
pytest
import
pytest
WAIT_TIME
=
0.05
WAIT_TIME
=
0.05
@pytest.mark.skip
(
reason
=
"
Unhandled problem with mockito 5
"
)
def
test_simple_case
(
japc
,
japc_mock
,
japc_set
):
def
test_simple_case
(
japc
,
japc_mock
):
param_name
=
'
TEST/TestProperty
'
param_name
=
'
TEST/TestProperty
'
param
=
japc_mock
.
mockParameter
(
param_name
)
param
=
japc_mock
.
mockParameter
(
param_name
)
japc_mock
.
whenGetValueThen
(
japc_mock
.
whenGetValueThen
(
...
@@ -18,7 +16,7 @@ def test_simple_case(japc, japc_mock):
...
@@ -18,7 +16,7 @@ def test_simple_case(japc, japc_mock):
japc
.
getNextParamValue
(
param_name
,
timeout
=
0.25
)
japc
.
getNextParamValue
(
param_name
,
timeout
=
0.25
)
def
set_value
():
def
set_value
():
param
.
setValue
(
japc_mock
.
sel
(
"
LHC.USER.TEST
"
),
japc_mock
.
spv
(
112
))
japc_set
(
param
,
japc_mock
.
sel
(
"
LHC.USER.TEST
"
),
japc_mock
.
spv
(
112
))
threading
.
Timer
(
WAIT_TIME
,
set_value
).
start
()
threading
.
Timer
(
WAIT_TIME
,
set_value
).
start
()
result
=
japc
.
getNextParamValue
(
param_name
,
timeout
=
1
,
timingSelectorOverride
=
"
LHC.USER.TEST
"
)
result
=
japc
.
getNextParamValue
(
param_name
,
timeout
=
1
,
timingSelectorOverride
=
"
LHC.USER.TEST
"
)
...
@@ -30,19 +28,18 @@ def test_simple_case(japc, japc_mock):
...
@@ -30,19 +28,18 @@ def test_simple_case(japc, japc_mock):
assert
'
isFirstUpdate
'
in
result
[
1
]
assert
'
isFirstUpdate
'
in
result
[
1
]
@pytest.mark.skip
(
reason
=
"
Unhandled problem with mockito 5
"
)
def
test_n_values
(
japc
,
japc_mock
,
japc_set
):
def
test_n_values
(
japc
,
japc_mock
):
param_name
=
'
TEST/TestProperty
'
param_name
=
'
TEST/TestProperty
'
param
=
japc_mock
.
mockParameter
(
param_name
)
param
=
japc_mock
.
mockParameter
(
param_name
)
japc_mock
.
whenGetValueThen
(
japc_mock
.
whenGetValueThen
(
param
,
japc_mock
.
sel
(
'
LHC.USER.TEST
'
),
japc_mock
.
acqVal
(
param_name
,
42
,
0
))
param
,
japc_mock
.
sel
(
'
LHC.USER.TEST
'
),
japc_mock
.
acqVal
(
param_name
,
42
,
0
))
def
set_several_values
():
def
set_several_values
():
param
.
setValue
(
japc_mock
.
sel
(
"
LHC.USER.TEST
"
),
japc_mock
.
spv
(
112
))
japc_set
(
param
,
japc_mock
.
sel
(
"
LHC.USER.TEST
"
),
japc_mock
.
spv
(
112
))
time
.
sleep
(
WAIT_TIME
)
time
.
sleep
(
WAIT_TIME
)
param
.
setValue
(
japc_mock
.
sel
(
"
LHC.USER.TEST
"
),
japc_mock
.
spv
(
113
))
japc_set
(
param
,
japc_mock
.
sel
(
"
LHC.USER.TEST
"
),
japc_mock
.
spv
(
113
))
time
.
sleep
(
WAIT_TIME
)
time
.
sleep
(
WAIT_TIME
)
param
.
setValue
(
japc_mock
.
sel
(
"
LHC.USER.TEST
"
),
japc_mock
.
spv
(
-
1
))
japc_set
(
param
,
japc_mock
.
sel
(
"
LHC.USER.TEST
"
),
japc_mock
.
spv
(
-
1
))
threading
.
Timer
(
WAIT_TIME
,
set_several_values
).
start
()
threading
.
Timer
(
WAIT_TIME
,
set_several_values
).
start
()
result
=
japc
.
getNextParamValue
(
param_name
,
timeout
=
1
,
timingSelectorOverride
=
"
LHC.USER.TEST
"
,
n_values
=
3
)
result
=
japc
.
getNextParamValue
(
param_name
,
timeout
=
1
,
timingSelectorOverride
=
"
LHC.USER.TEST
"
,
n_values
=
3
)
...
...
This diff is collapsed.
Click to expand it.
pyjapc/tests/test_subscribeParam.py
+
2
−
5
View file @
c47e93c6
...
@@ -2,13 +2,10 @@ import logging
...
@@ -2,13 +2,10 @@ import logging
import
time
import
time
from
unittest
import
mock
from
unittest
import
mock
import
pytest
SMALL_WAIT
=
0.1
SMALL_WAIT
=
0.1
@pytest.mark.xfail
(
reason
=
"
Unhandled problem with mockito 5
"
)
def
test_subscription_integration
(
japc
,
japc_mock
,
japc_set
):
def
test_subscription_integration
(
japc
,
japc_mock
):
param_name
=
"
TEST/TestProperty
"
param_name
=
"
TEST/TestProperty
"
param
=
japc_mock
.
mockParameter
(
param_name
)
param
=
japc_mock
.
mockParameter
(
param_name
)
japc_mock
.
whenGetValueThen
(
japc_mock
.
whenGetValueThen
(
...
@@ -36,7 +33,7 @@ def test_subscription_integration(japc, japc_mock):
...
@@ -36,7 +33,7 @@ def test_subscription_integration(japc, japc_mock):
callback
.
reset_mock
()
callback
.
reset_mock
()
# Check that a new value is sent.
# Check that a new value is sent.
param
.
setValue
(
japc_mock
.
sel
(
"
LHC.USER.TEST
"
),
japc_mock
.
spv
(
112
))
japc_set
(
param
,
japc_mock
.
sel
(
"
LHC.USER.TEST
"
),
japc_mock
.
spv
(
112
))
time
.
sleep
(
SMALL_WAIT
)
time
.
sleep
(
SMALL_WAIT
)
assert
callback
.
call_args
[
0
][:
2
]
==
(
param_name
,
112
)
assert
callback
.
call_args
[
0
][:
2
]
==
(
param_name
,
112
)
assert
callback
.
call_args
[
0
][
2
][
'
isFirstUpdate
'
]
is
False
assert
callback
.
call_args
[
0
][
2
][
'
isFirstUpdate
'
]
is
False
...
...
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