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
2de3fcbf
Commit
2de3fcbf
authored
2 years ago
by
Kien Le
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for readText
parent
3f72f6aa
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
+41
-3
41 additions, 3 deletions
tests/test_model/test_handling_data.py
with
41 additions
and
3 deletions
tests/test_model/test_handling_data.py
+
41
−
3
View file @
2de3fcbf
...
...
@@ -17,6 +17,7 @@ from sohstationviewer.model.handling_data import (
readWaveformMSeed
,
readWaveformReftek
,
readASCII
,
readText
,
)
from
sohstationviewer.model.reftek.from_rt2ms.core
import
Reftek130
...
...
@@ -322,8 +323,7 @@ class TestReadWaveformReftek(TestCase):
def
test_read_data_existing_channel_appended_to
(
self
):
self
.
read_data
=
{
'
DS1-1
'
:
{
'
tracesInfo
'
:
[{
'
startTmEpoch
'
:
0
,
'
endTmEpoch
'
:
0
}],
{
'
tracesInfo
'
:
[{
'
startTmEpoch
'
:
0
,
'
endTmEpoch
'
:
0
}],
'
samplerate
'
:
40.0
}
}
readWaveformReftek
(
self
.
rt130_waveform
,
self
.
key
,
self
.
read_data
,
...
...
@@ -421,7 +421,8 @@ class TestReadASCII(TestCase):
)
def
test_trace_does_not_contain_log_data
(
self
):
raise
NotImplementedError
(
self
.
test_trace_does_not_contain_log_data
.
__qualname__
)
# noqa
raise
NotImplementedError
(
self
.
test_trace_does_not_contain_log_data
.
__qualname__
)
# We are only reassigning the data reference of the trace and are not
# modifying the stored data. As a result, we only need a shallow copy
# of the trace.
...
...
@@ -441,3 +442,40 @@ class TestReadASCII(TestCase):
self
.
assertEqual
(
log_string
,
self
.
log_data
[
self
.
station_id
][
self
.
channel_id
][
0
])
class
TestReadText
(
TestCase
):
def
setUp
(
self
):
self
.
text_file
=
tempfile
.
NamedTemporaryFile
(
mode
=
'
w+t
'
)
self
.
text_file
.
write
(
'
Test text
'
)
self
.
text_file
.
flush
()
self
.
text_file_name
=
Path
(
self
.
text_file
.
name
).
name
self
.
non_text_file
=
TEST_DATA_DIR
.
joinpath
(
'
Q330-sample/
'
'
day_vols_AX08/
'
'
AX08.XA..HHE.2021.186
'
)
self
.
text_logs
=
[]
def
tearDown
(
self
)
->
None
:
self
.
text_file
.
close
()
def
test_log_appended_to
(
self
):
readText
(
self
.
text_file
.
name
,
self
.
text_file
.
name
,
self
.
text_logs
)
self
.
assertGreater
(
len
(
self
.
text_logs
),
0
)
def
test_text_file
(
self
):
readText
(
self
.
text_file
.
name
,
Path
(
self
.
text_file
.
name
).
name
,
self
.
text_logs
)
self
.
assertEqual
(
self
.
text_logs
[
0
],
f
'
\n\n
** STATE OF HEALTH:
{
Path
(
self
.
text_file
.
name
).
name
}
\n
Test text
'
)
# noqa: E501
def
test_non_text_file
(
self
):
with
self
.
assertRaises
(
Exception
):
readText
(
self
.
non_text_file
,
self
.
non_text_file
.
name
,
self
.
text_logs
)
def
test_non_existent_file
(
self
):
non_existent_file
=
TEST_DATA_DIR
.
joinpath
(
'
non_existent_file
'
)
with
self
.
assertRaises
(
FileNotFoundError
):
readText
(
str
(
non_existent_file
),
non_existent_file
.
name
,
self
.
text_logs
)
\ 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