File tree Expand file tree Collapse file tree 4 files changed +57
-2
lines changed Expand file tree Collapse file tree 4 files changed +57
-2
lines changed Original file line number Diff line number Diff line change 2
2
from enum import IntEnum
3
3
4
4
5
+ # TODO: Consider moving enumerations and other possible future types to separate
6
+ # module (_types.py).
5
7
class Language (IntEnum ):
6
8
PYTHON = 0
7
9
CPP = 1
Original file line number Diff line number Diff line change @@ -125,6 +125,8 @@ def set_attributes(self, attributes):
125
125
126
126
if attr in ENCODED_FIELDS :
127
127
setattr (self , attr , decode (value ) if value else None )
128
+ elif attr == "status" :
129
+ self .status = Status (value ["id" ])
128
130
else :
129
131
setattr (self , attr , value )
130
132
@@ -151,5 +153,4 @@ def is_done(self) -> bool:
151
153
if self .status is None :
152
154
return False
153
155
else :
154
- # TODO: When status is changed to `Status`, refactor this as well.
155
- return self .status ["id" ] not in (Status .IN_QUEUE , Status .PROCESSING )
156
+ return self .status not in (Status .IN_QUEUE , Status .PROCESSING )
Original file line number Diff line number Diff line change 8
8
load_dotenv ()
9
9
10
10
11
+ @pytest .fixture (scope = "session" )
12
+ def judge0_ce_client ():
13
+ api_key = os .getenv ("JUDGE0_TEST_API_KEY" )
14
+ api_key_header = os .getenv ("JUDGE0_TEST_API_KEY_HEADER" )
15
+ endpoint = os .getenv ("JUDGE0_TEST_CE_ENDPOINT" )
16
+ client = clients .Client (
17
+ endpoint = endpoint ,
18
+ auth_headers = {api_key_header : api_key },
19
+ )
20
+ return client
21
+
22
+
23
+ @pytest .fixture (scope = "session" )
24
+ def judge0_extra_ce_client ():
25
+ api_key = os .getenv ("JUDGE0_TEST_API_KEY" )
26
+ api_key_header = os .getenv ("JUDGE0_TEST_API_KEY_HEADER" )
27
+ endpoint = os .getenv ("JUDGE0_TEST_EXTRA_CE_ENDPOINT" )
28
+ client = clients .Client (
29
+ endpoint = endpoint ,
30
+ auth_headers = {api_key_header : api_key },
31
+ )
32
+ return client
33
+
34
+
11
35
@pytest .fixture (scope = "session" )
12
36
def atd_ce_client ():
13
37
api_key = os .getenv ("JUDGE0_ATD_API_KEY" )
Original file line number Diff line number Diff line change
1
+ import pytest
2
+
3
+ from judge0 import Status , Submission , wait
4
+
5
+
6
+ def test_status_before_and_after_submission (request ):
7
+ client = request .getfixturevalue ("judge0_ce_client" )
8
+ submission = Submission ('print("Hello World!")' )
9
+
10
+ assert submission .status is None
11
+
12
+ client .create_submission (submission )
13
+ client .get_submission (submission )
14
+
15
+ assert submission .status .__class__ == Status
16
+ assert submission .status >= Status .IN_QUEUE
17
+
18
+
19
+ def test_is_done (request ):
20
+ client = request .getfixturevalue ("judge0_ce_client" )
21
+ submission = Submission ('print("Hello World!")' )
22
+
23
+ assert submission .status is None
24
+
25
+ client .create_submission (submission )
26
+ wait (client , submission )
27
+
28
+ assert submission .is_done ()
You can’t perform that action at this time.
0 commit comments