Skip to content
Snippets Groups Projects

Workflow Verification

Merged Adham Hashibon requested to merge workflow-verification into master
4 files
+ 133
49
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -3,7 +3,7 @@ import unittest
@@ -3,7 +3,7 @@ import unittest
from force_bdss.core.execution_layer import ExecutionLayer
from force_bdss.core.execution_layer import ExecutionLayer
from force_bdss.core.input_slot_info import InputSlotInfo
from force_bdss.core.input_slot_info import InputSlotInfo
from force_bdss.core.output_slot_info import OutputSlotInfo
from force_bdss.core.output_slot_info import OutputSlotInfo
from force_bdss.core.verifier import verify_workflow
from force_bdss.core.verifier import verify_workflow, multi_error_format
from force_bdss.core.workflow import Workflow
from force_bdss.core.workflow import Workflow
from force_bdss.core.kpi_specification import KPISpecification
from force_bdss.core.kpi_specification import KPISpecification
from force_bdss.tests.dummy_classes.extension_plugin import \
from force_bdss.tests.dummy_classes.extension_plugin import \
@@ -20,10 +20,10 @@ class TestVerifier(unittest.TestCase):
@@ -20,10 +20,10 @@ class TestVerifier(unittest.TestCase):
errors = verify_workflow(wf)
errors = verify_workflow(wf)
self.assertEqual(len(errors), 2)
self.assertEqual(len(errors), 2)
self.assertEqual(errors[0].subject, wf)
self.assertEqual(errors[0].subject, wf)
self.assertIn("no MCO", errors[0].error)
self.assertIn("no MCO", errors[0].local_error)
self.assertEqual(errors[1].subject, wf)
self.assertEqual(errors[1].subject, wf)
self.assertIn("no execution layers", errors[1].error)
self.assertIn("no execution layers", errors[1].local_error)
def test_no_mco_parameters(self):
def test_no_mco_parameters(self):
wf = self.workflow
wf = self.workflow
@@ -32,7 +32,7 @@ class TestVerifier(unittest.TestCase):
@@ -32,7 +32,7 @@ class TestVerifier(unittest.TestCase):
errors = verify_workflow(wf)
errors = verify_workflow(wf)
self.assertEqual(len(errors), 2)
self.assertEqual(len(errors), 2)
self.assertEqual(errors[0].subject, wf.mco)
self.assertEqual(errors[0].subject, wf.mco)
self.assertIn("no defined parameters", errors[0].error)
self.assertIn("no defined parameters", errors[0].local_error)
def test_empty_parameter_options(self):
def test_empty_parameter_options(self):
wf = self.workflow
wf = self.workflow
@@ -44,9 +44,9 @@ class TestVerifier(unittest.TestCase):
@@ -44,9 +44,9 @@ class TestVerifier(unittest.TestCase):
errors = verify_workflow(wf)
errors = verify_workflow(wf)
self.assertEqual(len(errors), 3)
self.assertEqual(len(errors), 3)
self.assertEqual(errors[0].subject, wf.mco.parameters[0])
self.assertEqual(errors[0].subject, wf.mco.parameters[0])
self.assertIn("Empty Name", errors[0].error)
self.assertIn("MCO parameter is not named", errors[0].local_error)
self.assertEqual(errors[1].subject, wf.mco.parameters[0])
self.assertEqual(errors[1].subject, wf.mco.parameters[0])
self.assertIn("Empty Type", errors[1].error)
self.assertIn("MCO parameter has no type set", errors[1].local_error)
def test_empty_kpi_options(self):
def test_empty_kpi_options(self):
wf = self.workflow
wf = self.workflow
@@ -59,8 +59,8 @@ class TestVerifier(unittest.TestCase):
@@ -59,8 +59,8 @@ class TestVerifier(unittest.TestCase):
self.assertEqual(len(errors), 4)
self.assertEqual(len(errors), 4)
self.assertEqual(errors[1].subject, wf.mco.kpis[0])
self.assertEqual(errors[1].subject, wf.mco.kpis[0])
self.assertIn("Empty Name", errors[1].error)
self.assertIn("KPI is not named", errors[1].local_error)
self.assertIn("Empty Objective", errors[2].error)
self.assertIn("KPI has no objective set", errors[2].local_error)
def test_empty_execution_layer(self):
def test_empty_execution_layer(self):
wf = self.workflow
wf = self.workflow
@@ -74,9 +74,10 @@ class TestVerifier(unittest.TestCase):
@@ -74,9 +74,10 @@ class TestVerifier(unittest.TestCase):
layer = ExecutionLayer()
layer = ExecutionLayer()
wf.execution_layers.append(layer)
wf.execution_layers.append(layer)
errors = verify_workflow(wf)
errors = verify_workflow(wf)
self.assertEqual(len(errors), 1)
 
self.assertEqual(len(errors), 2)
self.assertEqual(errors[0].subject, wf.execution_layers[0])
self.assertEqual(errors[0].subject, wf.execution_layers[0])
self.assertIn("Layer 0 has no data sources", errors[0].error)
self.assertIn("Layer 0 has no data sources", errors[1].local_error)
def test_data_sources(self):
def test_data_sources(self):
wf = self.workflow
wf = self.workflow
@@ -95,7 +96,8 @@ class TestVerifier(unittest.TestCase):
@@ -95,7 +96,8 @@ class TestVerifier(unittest.TestCase):
errors = verify_workflow(wf)
errors = verify_workflow(wf)
self.assertEqual(errors[0].subject, ds_model)
self.assertEqual(errors[0].subject, ds_model)
self.assertIn("Missing input slot name assignment", errors[0].error)
self.assertIn("Missing input slot name assignment in layer 0",
 
errors[0].local_error)
ds_model.input_slot_info.append(
ds_model.input_slot_info.append(
InputSlotInfo(name="name")
InputSlotInfo(name="name")
@@ -103,7 +105,8 @@ class TestVerifier(unittest.TestCase):
@@ -103,7 +105,8 @@ class TestVerifier(unittest.TestCase):
errors = verify_workflow(wf)
errors = verify_workflow(wf)
self.assertEqual(errors[0].subject, ds_model)
self.assertEqual(errors[0].subject, ds_model)
self.assertIn("Missing output slot name assignment", errors[0].error)
self.assertIn("Missing output slot name assignment in layer 0",
 
errors[0].local_error)
ds_model.output_slot_info.append(
ds_model.output_slot_info.append(
OutputSlotInfo(name="name")
OutputSlotInfo(name="name")
@@ -115,9 +118,17 @@ class TestVerifier(unittest.TestCase):
@@ -115,9 +118,17 @@ class TestVerifier(unittest.TestCase):
ds_model.input_slot_info[0].name = ''
ds_model.input_slot_info[0].name = ''
errors = verify_workflow(wf)
errors = verify_workflow(wf)
self.assertEqual(len(errors), 1)
self.assertEqual(len(errors), 1)
self.assertIn("Undefined name for input parameter", errors[0].error)
self.assertIn("Undefined name for input parameter",
 
errors[0].local_error)
ds_model.output_slot_info[0].name = ''
ds_model.output_slot_info[0].name = ''
errors = verify_workflow(wf)
errors = verify_workflow(wf)
self.assertEqual(len(errors), 2)
self.assertEqual(len(errors), 2)
self.assertIn("Undefined name for output parameter", errors[1].error)
self.assertIn("Undefined name for output parameter",
 
errors[1].local_error)
 
 
def test_multi_error_format(self):
 
 
self.assertEqual(multi_error_format([2]), '2')
 
self.assertEqual(multi_error_format([4, 2, 3, 7, 8, 11, 43]),
 
'2-4, 7-8, 11, 43')
Loading