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
16a930fa
Commit
16a930fa
authored
2 years ago
by
Kien Le
Browse files
Options
Downloads
Patches
Plain Diff
Add test for readWaveformTrace
parent
e3ae443b
No related branches found
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
+29
-5
29 additions, 5 deletions
tests/test_model/test_handling_data.py
with
29 additions
and
5 deletions
tests/test_model/test_handling_data.py
+
29
−
5
View file @
16a930fa
from
pathlib
import
Path
from
pathlib
import
Path
import
tempfile
from
math
import
isclose
from
math
import
isclose
from
unittest
import
TestCase
from
unittest
import
TestCase
...
@@ -11,10 +12,12 @@ from sohstationviewer.model.handling_data import (
...
@@ -11,10 +12,12 @@ from sohstationviewer.model.handling_data import (
readSOHMSeed
,
readSOHMSeed
,
readSOHTrace
,
readSOHTrace
,
readMPTrace
,
readMPTrace
,
readWaveformTrace
,
)
)
from
sohstationviewer.model.reftek.from_rt2ms.core
import
Reftek130
from
sohstationviewer.model.reftek.from_rt2ms.core
import
Reftek130
TEST_DATA_DIR
=
Path
(
__file__
).
parent
.
parent
.
joinpath
(
'
test_data
'
)
TEST_DATA_DIR
=
Path
(
__file__
).
parent
.
parent
.
joinpath
(
'
test_data
'
)
# tempfile.tempdir = './tempdir'
class
TestHandlingData
(
TestCase
):
class
TestHandlingData
(
TestCase
):
...
@@ -49,7 +52,6 @@ class TestHandlingData(TestCase):
...
@@ -49,7 +52,6 @@ class TestHandlingData(TestCase):
]
]
self
.
assertTrue
(
self
.
assertTrue
(
all
(
key
in
processed_trace
for
key
in
expected_key_list
),
all
(
key
in
processed_trace
for
key
in
expected_key_list
),
msg
=
'
Processed trace is missing some fields.
'
)
)
def
test_read_soh_trace_times_calculated_correctly
(
self
):
def
test_read_soh_trace_times_calculated_correctly
(
self
):
...
@@ -76,10 +78,32 @@ class TestHandlingData(TestCase):
...
@@ -76,10 +78,32 @@ class TestHandlingData(TestCase):
np
.
array_equal
(
processed_trace
[
'
data
'
],
expected
)
np
.
array_equal
(
processed_trace
[
'
data
'
],
expected
)
)
)
# @skip
@patch
(
'
sohstationviewer.model.handling_data.saveData2File
'
)
# def test_read_waveform_trace(self):
def
test_read_waveform_trace
(
self
,
mock_save_data_2_file
):
# self.fail()
station_id
=
self
.
rt130_trace
.
stats
[
'
station
'
]
#
channel_id
=
self
.
rt130_trace
.
stats
[
'
channel
'
]
# The function itself only cares about the length of this list so we
# stub it out.
traces_info
=
[
dict
()
for
_
in
range
(
4
)]
tmp_dir
=
tempfile
.
TemporaryDirectory
()
processed_trace
=
readWaveformTrace
(
self
.
rt130_trace
,
station_id
,
channel_id
,
traces_info
,
tmp_dir
.
name
)
expected_key_list
=
[
'
samplerate
'
,
'
startTmEpoch
'
,
'
endTmEpoch
'
,
'
size
'
,
'
times_f
'
,
'
data_f
'
,
]
self
.
assertTrue
(
all
(
key
in
processed_trace
for
key
in
expected_key_list
),
)
self
.
assertTrue
(
mock_save_data_2_file
.
called
)
# @skip
# @skip
# def test_read_waveform_mseed(self):
# def test_read_waveform_mseed(self):
# self.fail()
# self.fail()
...
...
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