66from unittest .mock import patch
77
88from openhexa .sdk .pipelines .exceptions import InvalidParameterError , PipelineNotFound
9- from openhexa .sdk .pipelines .parameter import ParameterWidget
9+ from openhexa .sdk .pipelines .parameter import DHIS2Widget
1010from openhexa .sdk .pipelines .runtime import get_pipeline
1111
1212
@@ -436,10 +436,10 @@ def test_pipeline_with_connection_parameter(self):
436436 "\n " .join (
437437 [
438438 "from openhexa.sdk.pipelines import pipeline, parameter" ,
439- "from openhexa.sdk.pipelines.widgets import ParameterWidget " ,
439+ "from openhexa.sdk.pipelines.widgets import DHIS2Widget " ,
440440 "" ,
441441 "@parameter('dhis_con', name='DHIS2 Connection', type=DHIS2Connection, required=True)" ,
442- "@parameter('data_element_ids', name='Data Elements id', type=str, widget=ParameterWidget.DHIS2_ORG_UNITS , connection='dhis_con', required=True)" ,
442+ "@parameter('data_element_ids', name='Data Elements id', type=str, widget=DHIS2Widget.ORG_UNITS , connection='dhis_con', required=True)" ,
443443 "@pipeline('Test pipeline')" ,
444444 "def test_pipeline():" ,
445445 " pass" ,
@@ -472,7 +472,7 @@ def test_pipeline_with_connection_parameter(self):
472472 "code" : "data_element_ids" ,
473473 "type" : "str" ,
474474 "name" : "Data Elements id" ,
475- "widget" : ParameterWidget . DHIS2_ORG_UNITS .value ,
475+ "widget" : DHIS2Widget . ORG_UNITS .value ,
476476 "connection" : "dhis_con" ,
477477 "default" : None ,
478478 "multiple" : False ,
@@ -493,11 +493,11 @@ def test_pipeline_wit_wrong_connection_parameter(self):
493493 "\n " .join (
494494 [
495495 "from openhexa.sdk.pipelines import pipeline, parameter" ,
496- "from openhexa.sdk.pipelines.parameter import ParameterWidget " ,
496+ "from openhexa.sdk.pipelines.parameter import DHIS2Widget " ,
497497 "" ,
498498 "@parameter('dhis_con', name='DHIS2 Connection', type=DHIS2Connection, required=True)" ,
499499 "@pipeline('Test pipeline')" ,
500- "@parameter('data_element_ids', name='Data Elements id', type=str, widget=ParameterWidget.DHIS2_ORG_UNITS , connection='sds_con', required=True)" ,
500+ "@parameter('data_element_ids', name='Data Elements id', type=str, widget=DHIS2Widget.ORG_UNITS , connection='sds_con', required=True)" ,
501501 "def test_pipeline():" ,
502502 " pass" ,
503503 "" ,
@@ -507,48 +507,26 @@ def test_pipeline_wit_wrong_connection_parameter(self):
507507 with self .assertRaises (InvalidParameterError ):
508508 get_pipeline (tmpdirname )
509509
510- def test_pipeline_with_widget_without_connection (self ):
510+ def test_pipeline_with_dhis2_widget_without_connection (self ):
511511 """The file contains a @pipeline decorator and a @parameter decorator with a widget parameter field."""
512512 with tempfile .TemporaryDirectory () as tmpdirname :
513513 with open (f"{ tmpdirname } /pipeline.py" , "w" ) as f :
514514 f .write (
515515 "\n " .join (
516516 [
517517 "from openhexa.sdk.pipelines import pipeline, parameter" ,
518- "from openhexa.sdk.pipelines.parameter import ParameterWidget " ,
518+ "from openhexa.sdk.pipelines.parameter import DHIS2Widget " ,
519519 "" ,
520- "@parameter('test_field_for_widget', name='Widget Param', type=str, widget=ParameterWidget.DHIS2_ORG_UNITS , help='Param help')" ,
520+ "@parameter('test_field_for_widget', name='Widget Param', type=str, widget=DHIS2Widget.ORG_UNITS , help='Param help')" ,
521521 "@pipeline('Test pipeline')" ,
522522 "def test_pipeline():" ,
523523 " pass" ,
524524 "" ,
525525 ]
526526 )
527527 )
528- pipeline = get_pipeline (tmpdirname )
529- self .assertEqual (
530- pipeline .to_dict (),
531- {
532- "name" : "Test pipeline" ,
533- "function" : None ,
534- "tasks" : [],
535- "parameters" : [
536- {
537- "code" : "test_field_for_widget" ,
538- "type" : "str" ,
539- "name" : "Widget Param" ,
540- "default" : None ,
541- "multiple" : False ,
542- "choices" : None ,
543- "widget" : ParameterWidget .DHIS2_ORG_UNITS .value ,
544- "connection" : None ,
545- "help" : "Param help" ,
546- "required" : True ,
547- }
548- ],
549- "timeout" : None ,
550- },
551- )
528+ with self .assertRaises (InvalidParameterError ):
529+ get_pipeline (tmpdirname )
552530
553531 def test_pipeline_with_deprecated_code_argument_with_name (self ):
554532 """The file contains a @pipeline decorator with the deprecated 'code' argument."""
0 commit comments