Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
beat.editor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
11
Issues
11
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
beat
beat.editor
Commits
12d12887
Commit
12d12887
authored
Sep 03, 2019
by
Samuel GAIST
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[test][experimenteditor] Refactor block editor tests
This makes the tests better separated.
parent
4aa45bc7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
93 additions
and
91 deletions
+93
-91
beat/editor/test/test_experimenteditor.py
beat/editor/test/test_experimenteditor.py
+93
-91
No files found.
beat/editor/test/test_experimenteditor.py
View file @
12d12887
...
...
@@ -443,84 +443,8 @@ class TestEnvironmentModel:
assert
combobox
.
itemText
(
i
)
==
visual_name
class
TestExecutionPropertiesEditor
:
"""Test that the AlgorithmEdior works as expected"""
editor_klass
=
ExecutionPropertiesEditor
declaration_field
=
"blocks"
parameter_field
=
"parameters"
@
pytest
.
fixture
()
def
properties_editor
(
self
,
beat_context
,
test_prefix
,
algorithm_model
):
environment_model
=
EnvironmentModel
()
environment_model
.
setContext
(
beat_context
)
editor
=
self
.
editor_klass
(
test_prefix
)
editor
.
setAlgorithmModel
(
algorithm_model
)
editor
.
setEnvironmentModel
(
environment_model
)
editor
.
setQueueModel
(
QStringListModel
([
"Test"
]))
return
editor
def
test_load_and_dump
(
self
,
qtbot
,
properties_editor
,
test_prefix
,
test_experiment
,
algorithm_model
):
qtbot
.
addWidget
(
properties_editor
)
experiment_declaration
=
get_experiment_declaration
(
test_prefix
,
test_experiment
)
algorithms
=
experiment_declaration
[
self
.
declaration_field
]
first_algorithm
=
next
(
iter
(
algorithms
))
json_reference
=
algorithms
[
first_algorithm
]
properties_editor
.
load
(
json_reference
)
assert
properties_editor
.
dump
()
==
json_reference
def
test_edit_environment
(
self
,
qtbot
,
properties_editor
,
test_prefix
,
test_experiment
,
algorithm_model
):
qtbot
.
addWidget
(
properties_editor
)
experiment_declaration
=
get_experiment_declaration
(
test_prefix
,
test_experiment
)
algorithms
=
experiment_declaration
[
self
.
declaration_field
]
first_algorithm
=
next
(
iter
(
algorithms
))
json_reference
=
algorithms
[
first_algorithm
]
properties_editor
.
load
(
json_reference
)
environment_model
=
properties_editor
.
environmentModel
()
environment
=
environment_model
.
environment
(
environment_model
.
index
(
1
,
0
))
with
qtbot
.
waitSignal
(
properties_editor
.
dataChanged
):
combobox
=
properties_editor
.
findChild
(
QComboBox
,
"environments"
)
combobox
.
setCurrentIndex
(
1
)
assert
properties_editor
.
dump
()[
"environment"
]
==
environment
def
test_edit_algorithm
(
self
,
qtbot
,
properties_editor
,
test_prefix
,
test_experiment
,
algorithm_model
):
qtbot
.
addWidget
(
properties_editor
)
experiment_declaration
=
get_experiment_declaration
(
test_prefix
,
test_experiment
)
algorithms
=
experiment_declaration
[
self
.
declaration_field
]
first_algorithm
=
next
(
iter
(
algorithms
))
json_reference
=
algorithms
[
first_algorithm
]
properties_editor
.
load
(
json_reference
)
combobox
=
properties_editor
.
findChild
(
QComboBox
,
"algorithms"
)
with
qtbot
.
waitSignal
(
properties_editor
.
dataChanged
):
next_index
=
combobox
.
currentIndex
()
+
1
if
next_index
==
combobox
.
count
():
next_index
-=
2
combobox
.
setCurrentIndex
(
next_index
)
assert
properties_editor
.
dump
()[
"algorithm"
]
==
combobox
.
currentText
()
class
ParameterTestMixin
:
"""Mixin related to editors for blocks that can have parameters"""
def
test_edit_parameter
(
self
,
qtbot
,
properties_editor
,
test_prefix
,
test_experiment
,
algorithm_model
...
...
@@ -589,6 +513,77 @@ class TestExecutionPropertiesEditor:
dump
=
properties_editor
.
dump
()
assert
dump
[
self
.
parameter_field
]
==
{
label
:
new_value
}
class
PropertiesEditorTestMixin
:
"""Mixin that provides the common tests to execute for editors related to
block properties
"""
editor_klass
=
None
declaration_field
=
""
parameter_field
=
""
def
test_load_and_dump
(
self
,
qtbot
,
properties_editor
,
test_prefix
,
test_experiment
,
algorithm_model
):
qtbot
.
addWidget
(
properties_editor
)
experiment_declaration
=
get_experiment_declaration
(
test_prefix
,
test_experiment
)
algorithms
=
experiment_declaration
[
self
.
declaration_field
]
first_algorithm
=
next
(
iter
(
algorithms
))
json_reference
=
algorithms
[
first_algorithm
]
properties_editor
.
load
(
json_reference
)
assert
properties_editor
.
dump
()
==
json_reference
def
test_edit_environment
(
self
,
qtbot
,
properties_editor
,
test_prefix
,
test_experiment
,
algorithm_model
):
qtbot
.
addWidget
(
properties_editor
)
experiment_declaration
=
get_experiment_declaration
(
test_prefix
,
test_experiment
)
algorithms
=
experiment_declaration
[
self
.
declaration_field
]
first_algorithm
=
next
(
iter
(
algorithms
))
json_reference
=
algorithms
[
first_algorithm
]
properties_editor
.
load
(
json_reference
)
environment_model
=
properties_editor
.
environmentModel
()
environment
=
environment_model
.
environment
(
environment_model
.
index
(
1
,
0
))
with
qtbot
.
waitSignal
(
properties_editor
.
dataChanged
):
combobox
=
properties_editor
.
findChild
(
QComboBox
,
"environments"
)
combobox
.
setCurrentIndex
(
1
)
assert
properties_editor
.
dump
()[
"environment"
]
==
environment
def
test_edit_algorithm
(
self
,
qtbot
,
properties_editor
,
test_prefix
,
test_experiment
,
algorithm_model
):
qtbot
.
addWidget
(
properties_editor
)
experiment_declaration
=
get_experiment_declaration
(
test_prefix
,
test_experiment
)
algorithms
=
experiment_declaration
[
self
.
declaration_field
]
first_algorithm
=
next
(
iter
(
algorithms
))
json_reference
=
algorithms
[
first_algorithm
]
properties_editor
.
load
(
json_reference
)
combobox
=
properties_editor
.
findChild
(
QComboBox
,
"algorithms"
)
with
qtbot
.
waitSignal
(
properties_editor
.
dataChanged
):
next_index
=
combobox
.
currentIndex
()
+
1
if
next_index
==
combobox
.
count
():
next_index
-=
2
combobox
.
setCurrentIndex
(
next_index
)
assert
properties_editor
.
dump
()[
"algorithm"
]
==
combobox
.
currentText
()
def
test_edit_io_mapping
(
self
,
qtbot
,
...
...
@@ -633,6 +628,25 @@ class TestExecutionPropertiesEditor:
assert
properties_editor
.
dump
()[
"outputs"
]
==
io_mapping_answer
[
"outputs"
]
class
TestExecutionPropertiesEditor
(
PropertiesEditorTestMixin
,
ParameterTestMixin
):
"""Test that the AlgorithmEdior works as expected"""
editor_klass
=
ExecutionPropertiesEditor
declaration_field
=
"blocks"
parameter_field
=
"parameters"
@
pytest
.
fixture
()
def
properties_editor
(
self
,
beat_context
,
test_prefix
,
algorithm_model
):
environment_model
=
EnvironmentModel
()
environment_model
.
setContext
(
beat_context
)
editor
=
self
.
editor_klass
(
test_prefix
)
editor
.
setAlgorithmModel
(
algorithm_model
)
editor
.
setEnvironmentModel
(
environment_model
)
editor
.
setQueueModel
(
QStringListModel
([
"Test"
]))
return
editor
class
TestBlockEditor
(
TestExecutionPropertiesEditor
):
"""Test that the editor for blocks works correctly"""
...
...
@@ -651,7 +665,7 @@ class TestBlockEditor(TestExecutionPropertiesEditor):
return
editor
class
TestAnalyzerBlockEditor
(
TestExecutionPropertiesEditor
):
class
TestAnalyzerBlockEditor
(
PropertiesEditorTestMixin
):
"""Test that the editor for analyzer blocks works correctly"""
editor_klass
=
AnalyzerBlockEditor
...
...
@@ -668,18 +682,6 @@ class TestAnalyzerBlockEditor(TestExecutionPropertiesEditor):
editor
.
setQueueModel
(
QStringListModel
([
"Test"
]))
return
editor
@
pytest
.
mark
.
skip
(
reason
=
"Analyzers don't have properties"
)
def
test_edit_parameter
(
self
,
qtbot
,
properties_editor
,
test_prefix
,
test_experiment
,
algorithm_model
):
pass
@
pytest
.
mark
.
skip
(
reason
=
"Analyzers don't have properties"
)
def
test_edit_parameter_going_back_to_default_value
(
self
,
qtbot
,
properties_editor
,
test_prefix
,
test_experiment
,
algorithm_model
):
pass
class
TestLoopBlockEditor
(
TestExecutionPropertiesEditor
):
"""Test that the editor for the loop blocks works correctly"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment