-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconftest.py
147 lines (110 loc) · 3.58 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import json
import os
import pytest
from dotenv import load_dotenv
from judge0 import clients, RegularPeriodRetry
load_dotenv()
@pytest.fixture(scope="session")
def custom_ce_client():
endpoint = os.getenv("JUDGE0_CE_ENDPOINT")
auth_headers = os.getenv("JUDGE0_CE_AUTH_HEADERS")
if endpoint is None or auth_headers is None:
return None
else:
return clients.Client(endpoint=endpoint, auth_headers=json.loads(auth_headers))
@pytest.fixture(scope="session")
def custom_extra_ce_client():
endpoint = os.getenv("JUDGE0_EXTRA_CE_ENDPOINT")
auth_headers = os.getenv("JUDGE0_EXTRA_CE_AUTH_HEADERS")
if endpoint is None or auth_headers is None:
return None
else:
return clients.Client(endpoint=endpoint, auth_headers=json.loads(auth_headers))
@pytest.fixture(scope="session")
def atd_ce_client():
api_key = os.getenv("JUDGE0_ATD_API_KEY")
if api_key is None:
return None
else:
return clients.ATDJudge0CE(api_key)
@pytest.fixture(scope="session")
def atd_extra_ce_client():
api_key = os.getenv("JUDGE0_ATD_API_KEY")
if api_key is None:
return None
else:
return clients.ATDJudge0ExtraCE(api_key)
@pytest.fixture(scope="session")
def rapid_ce_client():
api_key = os.getenv("JUDGE0_RAPID_API_KEY")
if api_key is None:
return None
else:
return clients.RapidJudge0CE(api_key)
@pytest.fixture(scope="session")
def rapid_extra_ce_client():
api_key = os.getenv("JUDGE0_RAPID_API_KEY")
if api_key is None:
return None
else:
return clients.RapidJudge0ExtraCE(api_key)
@pytest.fixture(scope="session")
def sulu_ce_client():
api_key = os.getenv("JUDGE0_SULU_API_KEY")
if api_key is None:
return None
else:
return clients.SuluJudge0CE(api_key)
@pytest.fixture(scope="session")
def sulu_extra_ce_client():
api_key = os.getenv("JUDGE0_SULU_API_KEY")
if api_key is None:
return None
else:
return clients.SuluJudge0ExtraCE(api_key)
@pytest.fixture(scope="session")
def preview_ce_client() -> clients.SuluJudge0CE:
return clients.SuluJudge0CE(retry_strategy=RegularPeriodRetry(0.5))
@pytest.fixture(scope="session")
def preview_extra_ce_client() -> clients.SuluJudge0ExtraCE:
return clients.SuluJudge0ExtraCE(retry_strategy=RegularPeriodRetry(0.5))
@pytest.fixture(scope="session")
def ce_client(
custom_ce_client,
sulu_ce_client,
rapid_ce_client,
atd_ce_client,
preview_ce_client,
):
if custom_ce_client is not None:
return custom_ce_client
if sulu_ce_client is not None:
return sulu_ce_client
if rapid_ce_client is not None:
return rapid_ce_client
if atd_ce_client is not None:
return atd_ce_client
if preview_ce_client is not None:
return preview_ce_client
pytest.fail("No CE client available for testing. This error should not happen!")
@pytest.fixture(scope="session")
def extra_ce_client(
custom_extra_ce_client,
sulu_extra_ce_client,
rapid_extra_ce_client,
atd_extra_ce_client,
preview_extra_ce_client,
):
if custom_extra_ce_client is not None:
return custom_extra_ce_client
if sulu_extra_ce_client is not None:
return sulu_extra_ce_client
if rapid_extra_ce_client is not None:
return rapid_extra_ce_client
if atd_extra_ce_client is not None:
return atd_extra_ce_client
if preview_extra_ce_client is not None:
return preview_extra_ce_client
pytest.fail(
"No Extra CE client available for testing. This error should not happen!"
)