5
5
from airone .lib .types import AttrTypeValue
6
6
from entity .models import Entity , EntityAttr
7
7
from entry .models import Entry
8
- from job .models import Job , JobOperation
8
+ from job .models import Job , JobOperation , JobStatus
9
9
from job .settings import CONFIG
10
10
11
11
# constants using this tests
@@ -64,10 +64,10 @@ def test_get_jobs(self):
64
64
self .assertEqual (
65
65
results ["constant" ]["status" ],
66
66
{
67
- "processing" : Job . STATUS [ " PROCESSING" ] ,
68
- "done" : Job . STATUS [ " DONE" ] ,
69
- "error" : Job . STATUS [ " ERROR" ] ,
70
- "timeout" : Job . STATUS [ " TIMEOUT" ] ,
67
+ "processing" : JobStatus . PROCESSING . value ,
68
+ "done" : JobStatus . DONE . value ,
69
+ "error" : JobStatus . ERROR . value ,
70
+ "timeout" : JobStatus . TIMEOUT . value ,
71
71
},
72
72
)
73
73
@@ -119,7 +119,7 @@ def test_rerun_jobs(self):
119
119
self .assertEqual (resp .content , b'"Success to run command"' )
120
120
121
121
job = Job .objects .get (id = job .id )
122
- self .assertEqual (job .status , Job . STATUS [ " DONE" ] )
122
+ self .assertEqual (job .status , JobStatus . DONE . value )
123
123
self .assertEqual (entry .attrs .count (), 1 )
124
124
125
125
attrv = entry .attrs .first ().get_latest_value ()
@@ -152,7 +152,7 @@ def test_rerun_jobs(self):
152
152
153
153
self .assertEqual (resp .status_code , 200 )
154
154
self .assertEqual (resp .content , b'"Success to run command"' )
155
- self .assertEqual (Job .objects .get (id = job .id ).status , Job . STATUS [ " DONE" ] )
155
+ self .assertEqual (Job .objects .get (id = job .id ).status , JobStatus . DONE . value )
156
156
self .assertEqual (entry .attrs .first ().get_latest_value ().value , "fuga" )
157
157
158
158
# make and send a job to copy entry
@@ -161,7 +161,7 @@ def test_rerun_jobs(self):
161
161
162
162
self .assertEqual (resp .status_code , 200 )
163
163
self .assertEqual (resp .content , b'"Success to run command"' )
164
- self .assertEqual (Job .objects .get (id = job .id ).status , Job . STATUS [ " DONE" ] )
164
+ self .assertEqual (Job .objects .get (id = job .id ).status , JobStatus . DONE . value )
165
165
166
166
# checks it's success to clone entry
167
167
new_entry = Entry .objects .get (name = "new_entry" , schema = entity )
@@ -225,7 +225,7 @@ def test_cancel_job(self):
225
225
226
226
# make a job
227
227
job = Job .new_delete (user , entry )
228
- self .assertEqual (job .status , Job . STATUS [ " PREPARING" ] )
228
+ self .assertEqual (job .status , JobStatus . PREPARING . value )
229
229
230
230
# send request without any parameters
231
231
resp = self .client .delete ("/api/v1/job/" , json .dumps ({}), "application/json" )
@@ -246,7 +246,7 @@ def test_cancel_job(self):
246
246
247
247
# send request with proper parameter
248
248
job = Job .new_create (user , entry )
249
- self .assertEqual (job .status , Job . STATUS [ " PREPARING" ] )
249
+ self .assertEqual (job .status , JobStatus . PREPARING . value )
250
250
251
251
resp = self .client .delete (
252
252
"/api/v1/job/" , json .dumps ({"job_id" : job .id }), "application/json"
@@ -255,7 +255,7 @@ def test_cancel_job(self):
255
255
self .assertEqual (resp .content , b'"Success to cancel job"' )
256
256
257
257
job .refresh_from_db ()
258
- self .assertEqual (job .status , Job . STATUS [ " CANCELED" ] )
258
+ self .assertEqual (job .status , JobStatus . CANCELED . value )
259
259
260
260
def test_hidden_jobs_is_not_shown (self ):
261
261
user = self .guest_login ()
0 commit comments