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
c1a02b99
Commit
c1a02b99
authored
1 year ago
by
Lan Dam
Browse files
Options
Downloads
Patches
Plain Diff
modify unittest for changes in get_index_from_data_picked
parent
b92d2e1d
Loading
Loading
Loading
Pipeline
#2887
failed with stage
Stage: Build Env and Test
in 3 minutes and 3 seconds
This commit is part of merge request
!159
. Comments created here will be created in the context of that merge request.
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/view/plotting/plotting_widget/test_plotting_widget_helper.py
+65
-2
65 additions, 2 deletions
...w/plotting/plotting_widget/test_plotting_widget_helper.py
with
65 additions
and
2 deletions
tests/view/plotting/plotting_widget/test_plotting_widget_helper.py
+
65
−
2
Edit
View file @
c1a02b99
...
...
@@ -2,7 +2,70 @@ import numpy as np
from
unittest
import
TestCase
from
sohstationviewer.view.plotting.plotting_widget.plotting_widget_helper
\
import
get_total_miny_maxy
import
get_total_miny_maxy
,
get_index_from_data_picked
class
TestGetIndexFromTime
(
TestCase
):
@classmethod
def
setUpClass
(
cls
)
->
None
:
cls
.
plotting_data
=
{
'
CH1
'
:
{
'
times
'
:
[
np
.
array
([
1
,
2
,
3
,
4
,
5
,
6
])],
'
data
'
:
[
np
.
array
([
1
,
1
,
0
,
1
,
1
,
0
])],
'
chan_db_info
'
:
{
'
plotType
'
:
'
upDownDots
'
}
},
'
CH2
'
:
{
'
times
'
:
[
np
.
array
([
1
,
2
,
3
,
3
,
5
,
6
])],
'
data
'
:
[
np
.
array
([
6
,
9
,
7
,
4
,
3
,
9
])],
'
chan_db_info
'
:
{
'
plotType
'
:
'
linesDots
'
}
},
'
CH3
'
:
{
'
times
'
:
[
np
.
array
([
1
,
2
,
3
,
4
,
5
,
6
])],
'
data
'
:
[
np
.
array
([
6
,
9
,
7
,
4
,
3
,
9
])],
'
chan_db_info
'
:
{
'
plotType
'
:
'
dotForTime
'
}
}
}
def
test_time_not_included
(
self
):
real_idx
=
get_index_from_data_picked
(
self
.
plotting_data
[
'
CH1
'
],
7
,
1
)
self
.
assertIsNone
(
real_idx
)
def
test_type_not_need_data_info
(
self
):
# CH3 has plotType='dotForTime' in ["multiColorDots", "dotForTime"])
real_idx
=
get_index_from_data_picked
(
self
.
plotting_data
[
'
CH3
'
],
4
,
4
)
self
.
assertEqual
(
real_idx
,
3
)
def
test_type_need_data_info
(
self
):
# CH2 has plotType='linesDots' not in ["multiColorDots", "dotForTime"])
with
self
.
subTest
(
'
data not match time
'
):
real_idx
=
get_index_from_data_picked
(
self
.
plotting_data
[
'
CH2
'
],
3
,
5
)
self
.
assertIsNone
(
real_idx
)
with
self
.
subTest
(
'
data match 1st value
'
):
real_idx
=
get_index_from_data_picked
(
self
.
plotting_data
[
'
CH2
'
],
3
,
7
)
self
.
assertEqual
(
real_idx
,
2
)
with
self
.
subTest
(
'
data match 2nd value
'
):
real_idx
=
get_index_from_data_picked
(
self
.
plotting_data
[
'
CH2
'
],
3
,
4
)
self
.
assertEqual
(
real_idx
,
3
)
def
test_type_up_down
(
self
):
# CH1 has plotType='upDownDots'
with
self
.
subTest
(
'
data not match time
'
):
real_idx
=
get_index_from_data_picked
(
self
.
plotting_data
[
'
CH1
'
],
1
,
-
0.5
)
self
.
assertIsNone
(
real_idx
)
with
self
.
subTest
(
'
data=1 match time
'
):
real_idx
=
get_index_from_data_picked
(
self
.
plotting_data
[
'
CH1
'
],
1
,
0.5
)
self
.
assertEqual
(
real_idx
,
0
)
with
self
.
subTest
(
'
data=0 match time
'
):
real_idx
=
get_index_from_data_picked
(
self
.
plotting_data
[
'
CH1
'
],
3
,
-
0.5
)
self
.
assertEqual
(
real_idx
,
2
)
class
TestGetTotalMinyMaxy
(
TestCase
):
...
...
@@ -21,4 +84,4 @@ class TestGetTotalMinyMaxy(TestCase):
ret
=
get_total_miny_maxy
(
self
.
x
,
self
.
y
,
8.1
,
8.9
)
self
.
assertEqual
(
ret
[
0
],
0
)
self
.
assertIsNone
(
ret
[
1
])
self
.
assertIsNone
(
ret
[
2
])
\ No newline at end of file
self
.
assertIsNone
(
ret
[
2
])
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