Commit 83946657 authored by Samuel GAIST's avatar Samuel GAIST

[widgets][experimenteditor] Refactor algorithm handling using new prefix modelisation

This also start the implementation for support "wrong"
experiments as in not yet fully configured.

It also now does updating of the IO mapping when selecting
a new algorithm.
parent 6cda0bf9
......@@ -23,7 +23,6 @@
# #
###############################################################################
import re
import copy
import pytest
......@@ -58,7 +57,6 @@ from ..widgets.experimenteditor import AnalyzerBlockEditor
from ..widgets.experimenteditor import LoopBlockEditor
from ..widgets.experimenteditor import GlobalParametersEditor
from ..widgets.experimenteditor import EnvironmentModel
from ..widgets.experimenteditor import FieldPresenceFilterProxyModel
from ..widgets.experimenteditor import ExperimentEditor
from ..widgets.experimenteditor import typed_user_property
......@@ -501,58 +499,6 @@ class TestAlgorithmParametersEditor:
assert widget.itemText(i) in choices
class TestFieldPresenceFilter:
"""Test that the field presence filter works as expected"""
@pytest.mark.parametrize("must_be_present", [True, False])
@pytest.mark.parametrize("field_name", ["results", "type"])
def test_field_presence(self, algorithm_model, field_name, must_be_present):
filter_model = FieldPresenceFilterProxyModel(field_name, must_be_present)
filter_model.setSourceModel(algorithm_model)
assert filter_model.rowCount() < algorithm_model.rowCount()
for i in range(filter_model.rowCount()):
algorithm_name = filter_model.index(i, 0).data()
declaration = get_algorithm_declaration(
algorithm_model.prefix_path, algorithm_name
)
if must_be_present:
assert field_name in declaration
else:
assert field_name not in declaration
@pytest.mark.parametrize("must_be_present", [True, False])
@pytest.mark.parametrize(
"field_value", ["autonomous", "[autonomous|sequential]", ".*loop.*"]
)
@pytest.mark.parametrize("field_name", ["type"])
def test_field_value(
self, algorithm_model, field_name, must_be_present, field_value
):
filter_model = FieldPresenceFilterProxyModel(
field_name, must_be_present, field_value
)
filter_model.setSourceModel(algorithm_model)
assert filter_model.rowCount() < algorithm_model.rowCount()
for i in range(filter_model.rowCount()):
algorithm_name = filter_model.index(i, 0).data()
declaration = get_algorithm_declaration(
algorithm_model.prefix_path, algorithm_name
)
if must_be_present:
value = declaration[field_name]
match = re.match(field_value, value)
assert match is not None
else:
if field_name in declaration:
value = declaration[field_name]
match = re.match(field_value, value)
assert match is None
class TestEnvironmentModel:
"""Test that the environment model shows and return value as expected"""
......@@ -760,12 +706,20 @@ class PropertiesEditorTestMixin:
class TestExecutionPropertiesEditor(PropertiesEditorTestMixin, ParameterTestMixin):
"""Test that the AlgorithmEdior works as expected"""
"""Test that the AlgorithmEditor works as expected"""
editor_klass = ExecutionPropertiesEditor
declaration_field = "blocks"
parameter_field = "parameters"
@pytest.fixture(autouse=True)
def prefix_model(self, beat_context):
return PrefixModel(beat_context)
@pytest.fixture()
def algorithm_model(self):
return AlgorithmModel()
@pytest.fixture()
def properties_editor(self, beat_context, test_prefix, algorithm_model):
environment_model = EnvironmentModel()
......@@ -785,12 +739,11 @@ class TestBlockEditor(TestExecutionPropertiesEditor):
declaration_field = "blocks"
@pytest.fixture()
def properties_editor(self, beat_context, test_prefix, algorithm_model):
def properties_editor(self, beat_context, test_prefix):
environment_model = EnvironmentModel()
environment_model.setContext(beat_context)
editor = self.editor_klass("block_name", test_prefix)
editor.setAlgorithmModel(algorithm_model)
editor.setEnvironmentModel(environment_model)
editor.setQueueModel(QStringListModel(["Test"]))
return editor
......@@ -803,12 +756,11 @@ class TestAnalyzerBlockEditor(PropertiesEditorTestMixin):
declaration_field = "analyzers"
@pytest.fixture()
def properties_editor(self, beat_context, test_prefix, algorithm_model):
def properties_editor(self, beat_context, test_prefix):
environment_model = EnvironmentModel()
environment_model.setContext(beat_context)
editor = self.editor_klass("block_name", test_prefix)
editor.setAlgorithmModel(algorithm_model)
editor.setEnvironmentModel(environment_model)
editor.setQueueModel(QStringListModel(["Test"]))
return editor
......@@ -826,7 +778,6 @@ class TestLoopBlockEditor(TestExecutionPropertiesEditor):
environment_model.setContext(beat_context)
editor = self.editor_klass("block_name", test_prefix)
editor.setAlgorithmModel(algorithm_model)
editor.setEnvironmentModel(environment_model)
editor.setQueueModel(QStringListModel(["Test"]))
return editor
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment