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 22from enum import IntEnum
33
44
5+ # TODO: Consider moving enumerations and other possible future types to separate
6+ # module (_types.py).
57class Language (IntEnum ):
68 PYTHON = 0
79 CPP = 1
Original file line number Diff line number Diff line change @@ -125,6 +125,8 @@ def set_attributes(self, attributes):
125125
126126 if attr in ENCODED_FIELDS :
127127 setattr (self , attr , decode (value ) if value else None )
128+ elif attr == "status" :
129+ self .status = Status (value ["id" ])
128130 else :
129131 setattr (self , attr , value )
130132
@@ -151,5 +153,4 @@ def is_done(self) -> bool:
151153 if self .status is None :
152154 return False
153155 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 88load_dotenv ()
99
1010
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+
1135@pytest .fixture (scope = "session" )
1236def atd_ce_client ():
1337 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