Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SOHViewer
Manage
Activity
Members
Labels
Plan
Issues
14
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
5
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
a2a41da5
Commit
a2a41da5
authored
1 year ago
by
Kien Le
Browse files
Options
Downloads
Patches
Plain Diff
Fix tests
parent
928cc0f6
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/model/reftek_data/test_reftek.py
+26
-6
26 additions, 6 deletions
tests/model/reftek_data/test_reftek.py
with
26 additions
and
6 deletions
tests/model/reftek_data/test_reftek.py
+
26
−
6
View file @
a2a41da5
from
datetime
import
datetime
from
unittest
import
TestCase
from
pathlib
import
Path
from
unittest.mock
import
patch
from
sohstationviewer.conf.constants
import
SOFTWARE_VERSION
from
sohstationviewer.model.reftek_data.reftek
import
RT130
from
sohstationviewer.model.general_data.general_data
import
\
ProcessingDataError
...
...
@@ -12,6 +15,19 @@ reftek_data = TEST_DATA_DIR.joinpath("RT130-sample")
reftek_gap_data
=
TEST_DATA_DIR
.
joinpath
(
"
RT130-gap
"
)
# noinspection PyMissingOrEmptyDocstring
class
Mock_datetime
(
datetime
):
# noqa: N801
@classmethod
def
now
(
cls
,
tz
=
None
)
->
datetime
:
"""
Mock datetime.now to return a static datetime object.
:return: a static datetime object
"""
# The formatting method we used does not take millisecond into
# account, so we can omit it.
return
datetime
(
2023
,
10
,
5
,
15
,
8
,
5
)
class
TestReftek
(
TestCase
):
def
test_path_not_exist
(
self
):
# raise exception when path not exist
...
...
@@ -28,6 +44,7 @@ class TestReftek(TestCase):
"
Path
'
_
'
not exist
"
)
@patch
(
'
datetime.datetime
'
,
Mock_datetime
)
def
test_read_soh
(
self
):
args
=
{
'
data_type
'
:
'
RT130
'
,
...
...
@@ -50,11 +67,12 @@ class TestReftek(TestCase):
self
.
assertEqual
(
len
(
obj
.
log_data
[
'
TEXT
'
]),
0
)
self
.
assertEqual
(
list
(
obj
.
log_data
[(
'
92EB
'
,
'
25
'
)].
keys
()),
[
'
SOH
'
])
self
.
assertEqual
(
len
(
obj
.
log_data
[(
'
92EB
'
,
'
25
'
)][
'
SOH
'
]),
1
)
formatted_time
=
'
Thu Oct 5 15:08:05 2023
'
self
.
assertEqual
(
obj
.
log_data
[(
'
92EB
'
,
'
25
'
)][
'
SOH
'
][
0
][:
100
],
'
\n
State of Health 17:150:00:00:00:000 ST: 92EB
'
'
\n
150:00:00:00 REF TEK 130
'
'
\
r
\n
150:00:00:00 CPU SOFTWARE
'
)
f
'
SOHStationViewer: v
{
SOFTWARE_VERSION
}
'
f
'
Run time (UTC):
{
formatted_time
}
'
'
\
n
\n
State of Health 17:150:00:0
'
)
self
.
assertEqual
(
list
(
obj
.
soh_data
.
keys
()),
[(
'
92EB
'
,
'
25
'
)])
self
.
assertEqual
(
sorted
(
list
(
obj
.
soh_data
[(
'
92EB
'
,
'
25
'
)].
keys
())),
sorted
(
expected_soh
))
...
...
@@ -149,6 +167,7 @@ class TestReftek(TestCase):
self
.
assertEqual
(
obj
.
gaps
[(
'
98AD
'
,
'
0
'
)],
[[
1648493999.64
,
1648508400.64
]])
@patch
(
'
datetime.datetime
'
,
Mock_datetime
)
def
test_select_2_folders
(
self
):
args
=
{
'
data_type
'
:
'
RT130
'
,
...
...
@@ -176,11 +195,12 @@ class TestReftek(TestCase):
self
.
assertEqual
(
len
(
obj
.
log_data
[
'
TEXT
'
]),
0
)
self
.
assertEqual
(
list
(
obj
.
log_data
[(
'
92EB
'
,
'
25
'
)].
keys
()),
[
'
SOH
'
])
self
.
assertEqual
(
len
(
obj
.
log_data
[(
'
92EB
'
,
'
25
'
)][
'
SOH
'
]),
1
)
formatted_time
=
'
Thu Oct 5 15:08:05 2023
'
self
.
assertEqual
(
obj
.
log_data
[(
'
92EB
'
,
'
25
'
)][
'
SOH
'
][
0
][:
100
],
'
\n
State of Health 17:150:00:00:00:000 ST: 92EB
'
'
\n
150:00:00:00 REF TEK 130
'
'
\
r
\n
150:00:00:00 CPU SOFTWARE
'
)
f
'
SOHStationViewer: v
{
SOFTWARE_VERSION
}
'
f
'
Run time (UTC):
{
formatted_time
}
'
'
\
n
\n
State of Health 17:150:00:0
'
)
self
.
assertEqual
(
list
(
obj
.
soh_data
.
keys
()),
[(
'
92EB
'
,
'
25
'
),
(
'
98AD
'
,
'
0
'
)])
self
.
assertEqual
(
sorted
(
list
(
obj
.
soh_data
[(
'
92EB
'
,
'
25
'
)].
keys
())),
...
...
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