11
11
job_id = "65efab5c-8b75-4454-a42c-882ff4c48786"
12
12
start_time = "2015-04-13T12:25:57.691+05:30"
13
13
duration = "10.68 secs"
14
- status = "STARTED"
14
+ started = "STARTED"
15
+ finished = "FINISHED"
16
+ running = "RUNNING"
15
17
context = "test-context"
16
18
class_path = "test.class.path"
17
19
23
25
"context": "%s"
24
26
}
25
27
}
26
- """ % (status , job_id , context )
28
+ """ % (started , job_id , context )
27
29
28
30
job_get_result_response = """
29
31
{
35
37
"jobId": "%s",
36
38
"result": [1, 2, 3]
37
39
}
38
- """ % (duration , class_path , start_time , context , status , job_id )
40
+ """ % (duration , class_path , start_time , context , finished , job_id )
39
41
40
42
job_get_status_not_found_response = """
41
43
{
53
55
"status": "%s",
54
56
"jobId": "%s"
55
57
}
56
- """ % (duration , class_path , start_time , context , status , job_id )
58
+ """ % (duration , class_path , start_time , context , running , job_id )
57
59
58
60
job_list_response = """
59
61
[{
64
66
"status": "%s",
65
67
"jobId": "%s"
66
68
}]
67
- """ % (duration , class_path , start_time , context , status , job_id )
69
+ """ % (duration , class_path , start_time , context , running , job_id )
68
70
69
71
job_delete_response = """
70
72
{
@@ -90,7 +92,7 @@ def setUp(self):
90
92
super (TestJob , self ).setUp ()
91
93
self .client = client .Client (self .TEST_ENDPOINT )
92
94
93
- def assertJobFields (self , test_job ):
95
+ def assertJobFields (self , test_job , status ):
94
96
self .assertEqual (job_repr , repr (test_job ))
95
97
self .assertIsInstance (test_job , job .Job )
96
98
self .assertEqual (duration , test_job .duration )
@@ -112,7 +114,7 @@ def test_job_list(self, mock_req):
112
114
mock_req .get (list_url , text = job_list_response )
113
115
job_list = self .client .jobs .list ()
114
116
test_job = next (job_list )
115
- self .assertJobFields (test_job )
117
+ self .assertJobFields (test_job , running )
116
118
117
119
@requests_mock .Mocker ()
118
120
def test_create (self , mock_req ):
@@ -121,19 +123,20 @@ def test_create(self, mock_req):
121
123
query = "?classPath=test.class.path&appName=test_app"
122
124
post_url = "{}{}" .format (post_url , query )
123
125
124
- get_url = utils .urljoin (self .TEST_ENDPOINT ,
125
- self .client .jobs .base_path ,
126
- job_id )
127
-
128
126
mock_req .post (post_url , text = job_create_response )
129
- mock_req .get (get_url , text = job_get_result_response )
130
127
131
128
test_job = self .client .jobs .create (FakeApp , "test.class.path" )
132
129
self .assertEqual (context , test_job .context )
133
- self .assertEqual (status , test_job .status )
130
+ self .assertEqual (started , test_job .status )
134
131
self .assertEqual (job_id , test_job .jobId )
135
- self .assertEqual ("STARTED" , test_job .status )
136
- self .assertEqual ([1 , 2 , 3 ], test_job .result )
132
+
133
+ get_url = utils .urljoin (self .TEST_ENDPOINT ,
134
+ self .client .jobs .base_path ,
135
+ job_id )
136
+ mock_req .get (get_url , text = job_get_result_response )
137
+ test_job_result = self .client .jobs .get (test_job .jobId )
138
+ self .assertEqual (finished , test_job_result .status )
139
+ self .assertEqual ([1 , 2 , 3 ], test_job_result .result )
137
140
138
141
@requests_mock .Mocker ()
139
142
def test_create_with_ctx (self , mock_req ):
@@ -143,20 +146,22 @@ def test_create_with_ctx(self, mock_req):
143
146
"context=test-context" )
144
147
post_url = "{}{}" .format (post_url , query )
145
148
146
- get_url = utils .urljoin (self .TEST_ENDPOINT ,
147
- self .client .jobs .base_path ,
148
- job_id )
149
-
150
149
mock_req .post (post_url , text = job_create_response )
151
- mock_req .get (get_url , text = job_get_result_response )
152
150
153
151
test_job = self .client .jobs .create (FakeApp , "test.class.path" ,
154
152
ctx = FakeContext )
155
153
self .assertEqual (context , test_job .context )
156
- self .assertEqual (status , test_job .status )
154
+ self .assertEqual (started , test_job .status )
157
155
self .assertEqual (job_id , test_job .jobId )
158
- self .assertEqual ("STARTED" , test_job .status )
159
- self .assertEqual ([1 , 2 , 3 ], test_job .result )
156
+
157
+ get_url = utils .urljoin (self .TEST_ENDPOINT ,
158
+ self .client .jobs .base_path ,
159
+ job_id )
160
+
161
+ mock_req .get (get_url , text = job_get_result_response )
162
+ test_job_result = self .client .jobs .get (test_job .jobId )
163
+ self .assertEqual (finished , test_job_result .status )
164
+ self .assertEqual ([1 , 2 , 3 ], test_job_result .result )
160
165
161
166
@requests_mock .Mocker ()
162
167
def test_get (self , mock_req ):
@@ -169,7 +174,7 @@ def test_get(self, mock_req):
169
174
mock_req .get (get_url , text = job_get_result_response )
170
175
mock_req .get (status_url , text = job_status_response )
171
176
test_job = self .client .jobs .get (job_id )
172
- self .assertJobFields (test_job )
177
+ self .assertJobFields (test_job , running )
173
178
174
179
@requests_mock .Mocker ()
175
180
def test_get_after_sjs_restart (self , mock_req ):
@@ -182,7 +187,7 @@ def test_get_after_sjs_restart(self, mock_req):
182
187
mock_req .get (get_url , status_code = 404 )
183
188
mock_req .get (status_url , text = job_status_response )
184
189
test_job = self .client .jobs .get (job_id )
185
- self .assertJobFields (test_job )
190
+ self .assertJobFields (test_job , running )
186
191
187
192
@requests_mock .Mocker ()
188
193
def test_get_non_existing (self , mock_req ):
0 commit comments