@@ -392,6 +392,32 @@ def test_shell_cmd_inputspec_3(plugin, results_function):
392
392
@pytest .mark .parametrize ("results_function" , [result_no_submitter , result_submitter ])
393
393
@pytest .mark .parametrize ("plugin" , Plugins )
394
394
def test_shell_cmd_inputspec_3a (plugin , results_function ):
395
+ """ mandatory field added to fields, value provided
396
+ using shorter syntax for input spec (no attr.ib)
397
+ """
398
+ cmd_exec = "echo"
399
+ hello = "HELLO"
400
+ my_input_spec = SpecInfo (
401
+ name = "Input" ,
402
+ fields = [
403
+ ("text" , str , {"position" : 1 , "help_string" : "text" , "mandatory" : True })
404
+ ],
405
+ bases = (ShellSpec ,),
406
+ )
407
+
408
+ # separate command into exec + args
409
+ shelly = ShellCommandTask (
410
+ name = "shelly" , executable = cmd_exec , text = hello , input_spec = my_input_spec
411
+ )
412
+ assert shelly .inputs .executable == cmd_exec
413
+ assert shelly .cmdline == "echo HELLO"
414
+ res = results_function (shelly , plugin )
415
+ assert res .output .stdout == "HELLO\n "
416
+
417
+
418
+ @pytest .mark .parametrize ("results_function" , [result_no_submitter , result_submitter ])
419
+ @pytest .mark .parametrize ("plugin" , Plugins )
420
+ def test_shell_cmd_inputspec_3b (plugin , results_function ):
395
421
""" mandatory field added to fields, value provided after init"""
396
422
cmd_exec = "echo"
397
423
hello = "HELLO"
@@ -421,7 +447,7 @@ def test_shell_cmd_inputspec_3a(plugin, results_function):
421
447
422
448
423
449
@pytest .mark .parametrize ("plugin" , Plugins )
424
- def test_shell_cmd_inputspec_3b_exception (plugin ):
450
+ def test_shell_cmd_inputspec_3c_exception (plugin ):
425
451
""" mandatory field added to fields, value is not provided, so exception is raised """
426
452
cmd_exec = "echo"
427
453
my_input_spec = SpecInfo (
@@ -511,6 +537,31 @@ def test_shell_cmd_inputspec_4(plugin, results_function):
511
537
@pytest .mark .parametrize ("results_function" , [result_no_submitter , result_submitter ])
512
538
@pytest .mark .parametrize ("plugin" , Plugins )
513
539
def test_shell_cmd_inputspec_4a (plugin , results_function ):
540
+ """ mandatory field added to fields, value provided
541
+ using shorter syntax for input spec (no attr.ib)
542
+ """
543
+ cmd_exec = "echo"
544
+ my_input_spec = SpecInfo (
545
+ name = "Input" ,
546
+ fields = [("text" , str , "Hello" , {"position" : 1 , "help_string" : "text" })],
547
+ bases = (ShellSpec ,),
548
+ )
549
+
550
+ # separate command into exec + args
551
+ shelly = ShellCommandTask (
552
+ name = "shelly" , executable = cmd_exec , input_spec = my_input_spec
553
+ )
554
+
555
+ assert shelly .inputs .executable == cmd_exec
556
+ assert shelly .cmdline == "echo Hello"
557
+
558
+ res = results_function (shelly , plugin )
559
+ assert res .output .stdout == "Hello\n "
560
+
561
+
562
+ @pytest .mark .parametrize ("results_function" , [result_no_submitter , result_submitter ])
563
+ @pytest .mark .parametrize ("plugin" , Plugins )
564
+ def test_shell_cmd_inputspec_4b (plugin , results_function ):
514
565
""" mandatory field added to fields, value provided """
515
566
cmd_exec = "echo"
516
567
my_input_spec = SpecInfo (
@@ -1170,6 +1221,33 @@ def test_shell_cmd_inputspec_state_1(plugin, results_function):
1170
1221
assert res [1 ].output .stdout == "hi\n "
1171
1222
1172
1223
1224
+ @pytest .mark .parametrize ("results_function" , [result_no_submitter , result_submitter ])
1225
+ @pytest .mark .parametrize ("plugin" , Plugins )
1226
+ def test_shell_cmd_inputspec_state_1a (plugin , results_function ):
1227
+ """ adding state to the input from input_spec
1228
+ using shorter syntax for input_spec (without default)
1229
+ """
1230
+ cmd_exec = "echo"
1231
+ hello = ["HELLO" , "hi" ]
1232
+ my_input_spec = SpecInfo (
1233
+ name = "Input" ,
1234
+ fields = [
1235
+ ("text" , str , {"position" : 1 , "help_string" : "text" , "mandatory" : True })
1236
+ ],
1237
+ bases = (ShellSpec ,),
1238
+ )
1239
+
1240
+ # separate command into exec + args
1241
+ shelly = ShellCommandTask (
1242
+ name = "shelly" , executable = cmd_exec , text = hello , input_spec = my_input_spec
1243
+ ).split ("text" )
1244
+ assert shelly .inputs .executable == cmd_exec
1245
+
1246
+ res = results_function (shelly , plugin )
1247
+ assert res [0 ].output .stdout == "HELLO\n "
1248
+ assert res [1 ].output .stdout == "hi\n "
1249
+
1250
+
1173
1251
@pytest .mark .parametrize ("results_function" , [result_no_submitter , result_submitter ])
1174
1252
@pytest .mark .parametrize ("plugin" , Plugins )
1175
1253
def test_shell_cmd_inputspec_state_2 (plugin , results_function ):
0 commit comments