5
5
pytestmark = pytest .mark .unit
6
6
7
7
from tests .api_adapter import UnitTestAPIAdapter
8
+ from tests .config import TEST_PROJECT_ID
8
9
from tests .instance_launcher import UnitTestInstanceLauncher
9
10
from tests .message_dispatcher import UnitTestMessageDispatcher
10
11
from tests .message_queue import UnitTestMessageQueue
@@ -21,14 +22,14 @@ def basic_launcher():
21
22
return [api_adapter , instance_launcher ]
22
23
23
24
24
- def test_get_nop_job (basic_launcher ):
25
+ def test_launch_nop (basic_launcher ):
25
26
# Arrange
26
27
utaa = basic_launcher [0 ]
27
28
launcher = basic_launcher [1 ]
28
29
response = utaa .create_workflow (workflow_definition = {"name" : "blah" })
29
30
response = utaa .create_running_workflow (
30
31
workflow_id = response ["id" ],
31
- project_id = "project-00000000-0000-0000-0000-000000000001" ,
32
+ project_id = TEST_PROJECT_ID ,
32
33
)
33
34
response = utaa .create_running_workflow_step (
34
35
running_workflow_id = response ["id" ], step = "step-1"
@@ -37,14 +38,75 @@ def test_get_nop_job(basic_launcher):
37
38
38
39
# Act
39
40
result = launcher .launch (
40
- project_id = "project-00000000-0000-0000-0000-000000000001" ,
41
+ project_id = TEST_PROJECT_ID ,
41
42
workflow_id = "workflow-00000000-0000-0000-0000-000000000001" ,
42
43
running_workflow_step_id = rwfsid ,
43
44
workflow_definition = {},
44
- step_specification = {"job" : "nop" , "variables" : { "x" : 1 } },
45
+ step_specification = {"job" : "nop" },
45
46
)
46
47
47
48
# Assert
48
49
assert result .error == 0
49
50
assert result .command .startswith ("python " )
50
51
assert result .command .endswith ("tests/jobs/nop.py" )
52
+
53
+
54
+ def test_launch_nop_fail (basic_launcher ):
55
+ # Arrange
56
+ utaa = basic_launcher [0 ]
57
+ launcher = basic_launcher [1 ]
58
+ response = utaa .create_workflow (workflow_definition = {"name" : "blah" })
59
+ response = utaa .create_running_workflow (
60
+ workflow_id = response ["id" ],
61
+ project_id = TEST_PROJECT_ID ,
62
+ )
63
+ response = utaa .create_running_workflow_step (
64
+ running_workflow_id = response ["id" ], step = "step-1"
65
+ )
66
+ rwfsid = response ["id" ]
67
+
68
+ # Act
69
+ result = launcher .launch (
70
+ project_id = TEST_PROJECT_ID ,
71
+ workflow_id = "workflow-00000000-0000-0000-0000-000000000001" ,
72
+ running_workflow_step_id = rwfsid ,
73
+ workflow_definition = {},
74
+ step_specification = {"job" : "nop-fail" },
75
+ )
76
+
77
+ # Assert
78
+ assert result .error == 0
79
+ assert result .command .startswith ("python " )
80
+ assert result .command .endswith ("tests/jobs/nop-fail.py" )
81
+
82
+
83
+ def test_launch_smiles_to_file (basic_launcher ):
84
+ # Arrange
85
+ utaa = basic_launcher [0 ]
86
+ launcher = basic_launcher [1 ]
87
+ response = utaa .create_workflow (workflow_definition = {"name" : "blah" })
88
+ response = utaa .create_running_workflow (
89
+ workflow_id = response ["id" ],
90
+ project_id = TEST_PROJECT_ID ,
91
+ )
92
+ response = utaa .create_running_workflow_step (
93
+ running_workflow_id = response ["id" ], step = "step-1"
94
+ )
95
+ rwfsid = response ["id" ]
96
+
97
+ # Act
98
+ result = launcher .launch (
99
+ project_id = TEST_PROJECT_ID ,
100
+ workflow_id = "workflow-00000000-0000-0000-0000-000000000001" ,
101
+ running_workflow_step_id = rwfsid ,
102
+ workflow_definition = {},
103
+ step_specification = {
104
+ "job" : "smiles-to-file" ,
105
+ "variables" : {"smiles" : "C1=CC=CC=C1" , "outputFile" : "output.smi" },
106
+ },
107
+ )
108
+
109
+ # Assert
110
+ assert result .error == 0
111
+ assert result .command .startswith ("python " )
112
+ assert result .command .endswith ("tests/jobs/smiles-to-file.py" )
0 commit comments