Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SOHViewer
Manage
Activity
Members
Labels
Plan
Issues
11
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
3
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Software Public
PASSOFT
SOHViewer
Commits
50ef46a2
Commit
50ef46a2
authored
2 years ago
by
Kien Le
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for checkSOHChan
parent
b1f76599
No related branches found
Branches containing commit
No related tags found
1 merge request
!27
Draft: Add tests for functions in handling_data.py
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_model/test_handling_data.py
+50
-6
50 additions, 6 deletions
tests/test_model/test_handling_data.py
with
50 additions
and
6 deletions
tests/test_model/test_handling_data.py
+
50
−
6
View file @
50ef46a2
...
...
@@ -559,7 +559,7 @@ class TestSaveData2File(TestCase):
class
TestCheckChan
(
TestCase
):
def
setUp
(
self
)
->
None
:
self
.
req_soh_chans
=
[
'
LCE
'
,
'
LCQ
'
,
'
VM1
'
]
self
.
req_soh_chans
=
[
'
LCE
'
,
'
LCQ
'
]
self
.
req_wf_chans
=
[
'
LHE
'
,
'
HHE
'
]
check_soh_chan_patcher
=
patch
(
...
...
@@ -591,13 +591,57 @@ class TestCheckChan(TestCase):
self
.
assertTrue
(
self
.
mock_check_wf_chan
.
called
)
def
test_channel_is_soh_and_is_requested
(
self
):
soh_channel
=
'
LCE
'
ret
=
checkChan
(
soh_channel
,
self
.
req_soh_chans
,
self
.
req_wf_chans
)
self
.
assertEqual
(
ret
,
'
SOH
'
)
self
.
assertTrue
(
self
.
mock_check_soh_chan
.
called
)
with
self
.
subTest
(
'
test_normal_channel
'
):
soh_channel
=
'
LCE
'
ret
=
checkChan
(
soh_channel
,
self
.
req_soh_chans
,
self
.
req_wf_chans
)
self
.
assertEqual
(
ret
,
'
SOH
'
)
self
.
assertTrue
(
self
.
mock_check_soh_chan
.
called
)
self
.
mock_check_soh_chan
.
reset_mock
()
with
self
.
subTest
(
'
test_mass_position_channel
'
):
soh_channel
=
'
VM1
'
ret
=
checkChan
(
soh_channel
,
self
.
req_soh_chans
,
self
.
req_wf_chans
)
self
.
assertEqual
(
ret
,
'
SOH
'
)
self
.
assertTrue
(
self
.
mock_check_soh_chan
.
called
)
def
test_channel_is_soh_but_not_requested
(
self
):
soh_channel
=
'
VKI
'
ret
=
checkChan
(
soh_channel
,
self
.
req_soh_chans
,
self
.
req_wf_chans
)
self
.
assertFalse
(
ret
)
self
.
assertTrue
(
self
.
mock_check_soh_chan
.
called
)
\ No newline at end of file
self
.
assertTrue
(
self
.
mock_check_soh_chan
.
called
)
class
TestCheckSohChan
(
TestCase
):
def
setUp
(
self
)
->
None
:
self
.
req_soh_chans
=
[
'
LCE
'
,
'
LCQ
'
,
'
EX?
'
]
# Generated using the builtin random library with a seed of
# 22589824271860044. This seed is obtained by converting the string
# PASSCAL to bytes and converting the resulting bytes to an integer
# with big endian ordering.
self
.
sample_channel_ids
=
[
'
ODV
'
,
'
QGA
'
,
'
NF4
'
,
'
OLY
'
,
'
UZM
'
]
def
test_all_channels_requested
(
self
):
self
.
req_soh_chans
=
[]
for
channel_id
in
self
.
sample_channel_ids
:
self
.
assertTrue
(
checkSOHChan
(
channel_id
,
self
.
req_soh_chans
))
def
test_channel_is_requested
(
self
):
with
self
.
subTest
(
'
test_normal_channels
'
):
channel_id
=
'
LCE
'
self
.
assertTrue
(
checkSOHChan
(
channel_id
,
self
.
req_soh_chans
))
with
self
.
subTest
(
'
test_mass_position_channels
'
):
base_channel_id
=
'
VM
'
channel_suffixes
=
[
'
0
'
,
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
,
'
5
'
,
'
6
'
]
for
suffix
in
channel_suffixes
:
channel_id
=
base_channel_id
+
suffix
self
.
assertTrue
(
checkSOHChan
(
channel_id
,
self
.
req_soh_chans
))
with
self
.
subTest
(
'
test_external_soh_channels
'
):
base_channel_id
=
'
EX
'
channel_suffixes
=
[
'
1
'
,
'
2
'
,
'
3
'
]
for
suffix
in
channel_suffixes
:
channel_id
=
base_channel_id
+
suffix
self
.
assertTrue
(
checkSOHChan
(
channel_id
,
self
.
req_soh_chans
))
def
test_channel_not_requested
(
self
):
for
channel_id
in
self
.
sample_channel_ids
:
self
.
assertFalse
(
checkSOHChan
(
channel_id
,
self
.
req_soh_chans
))
\ No newline at end of file
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