Terarea  2
The automation project
Loading...
Searching...
No Matches
status_check.py
Go to the documentation of this file.
1"""_summary_
2File in charge of containing the boilerplate functions for checking if a given status corresponds to the expected response.
3"""
4
5from requests import Response
6
7
9 """_summary_
10 This is the class in charge of checking if a response corresponds to a given status.
11 """
12
13 def __init__(self) -> None:
14 pass
15
16 def _get_status(self, response: Response) -> int:
17 """_summary_
18 This function is in charge of getting the status code from the response.
19 Args:
20 response (Response): _description_: The response from the server.
21 Returns:
22 int: _description_: The status code from the response.
23 """
24 return response.status_code
25
26 # """ 1xx informational response"""
27
28 def send_continue(self, response: Response) -> bool:
29 """ send_continue: 100 """
30 status = self._get_status(response)
31 return status == 100
32
33 def switching_protocols(self, response: Response) -> bool:
34 """ switching_protocols: 101 """
35 status = self._get_status(response)
36 return status == 101
37
38 def processing(self, response: Response) -> bool:
39 """ processing: 102 """
40 status = self._get_status(response)
41 return status == 102
42
43 def early_hints(self, response: Response) -> bool:
44 """ early_hints: 103 """
45 status = self._get_status(response)
46 return status == 103
47
48 def response_is_stale(self, response: Response) -> bool:
49 """ response_is_stale: 110 """
50 status = self._get_status(response)
51 return status == 110
52
53 # """success: 200"""
54
55 def success(self, response: Response) -> bool:
56 """ success: 200 """
57 status = self._get_status(response)
58 return status == 200
59
60 def created(self, response: Response) -> bool:
61 """ created: 201 """
62 status = self._get_status(response)
63 return status == 201
64
65 def accepted(self, response: Response) -> bool:
66 """ accepted: 202 """
67 status = self._get_status(response)
68 return status == 202
69
70 def non_authoritative_information(self, response: Response) -> bool:
71 """ non_authoritative_information: 203 """
72 status = self._get_status(response)
73 return status == 203
74
75 def no_content(self, response: Response) -> bool:
76 """ no_content: 204 """
77 status = self._get_status(response)
78 return status == 204
79
80 def reset_content(self, response: Response) -> bool:
81 """ reset_content: 205 """
82 status = self._get_status(response)
83 return status == 205
84
85 def partial_content(self, response: Response) -> bool:
86 """ partial_content: 206 """
87 status = self._get_status(response)
88 return status == 206
89
90 def multi_status(self, response: Response) -> bool:
91 """ multi_status: 207 """
92 status = self._get_status(response)
93 return status == 207
94
95 def already_reported(self, response: Response) -> bool:
96 """ already_reported: 208 """
97 status = self._get_status(response)
98 return status == 208
99
100 def im_used(self, response: Response) -> bool:
101 """ im_used: 226 """
102 status = self._get_status(response)
103 return status == 226
104
105 """ 3xx redirection """
106
107 def multiple_choices(self, response: Response) -> bool:
108 """ multiple_choices: 300 """
109 status = self._get_status(response)
110 return status == 300
111
112 def moved_permanently(self, response: Response) -> bool:
113 """ moved_permanently: 301 """
114 status = self._get_status(response)
115 return status == 301
116
117 def found(self, response: Response) -> bool:
118 """ found: 302 """
119 status = self._get_status(response)
120 return status == 302
121
122 def see_other(self, response: Response) -> bool:
123 """ see_other: 303 """
124 status = self._get_status(response)
125 return status == 303
126
127 def not_modified(self, response: Response) -> bool:
128 """ not_modified: 304 """
129 status = self._get_status(response)
130 return status == 304
131
132 def use_proxy(self, response: Response) -> bool:
133 """ use_proxy: 305 """
134 status = self._get_status(response)
135 return status == 305
136
137 def switch_proxy(self, response: Response) -> bool:
138 """ switch_proxy: 306 """
139 status = self._get_status(response)
140 return status == 306
141
142 def temporary_redirect(self, response: Response) -> bool:
143 """ temporary_redirect: 307 """
144 status = self._get_status(response)
145 return status == 307
146
147 def permanent_redirect(self, response: Response) -> bool:
148 """ permanent_redirect: 308 """
149 status = self._get_status(response)
150 return status == 308
151
152 """ 4xx client error """
153
154 def bad_request(self, response: Response) -> bool:
155 """ bad_request: 400 """
156 status = self._get_status(response)
157 return status == 400
158
159 def unauthorized(self, response: Response) -> bool:
160 """ unauthorized: 401 """
161 status = self._get_status(response)
162 return status == 401
163
164 def payment_required(self, response: Response) -> bool:
165 """ payment_required: 402 """
166 status = self._get_status(response)
167 return status == 402
168
169 def forbidden(self, response: Response) -> bool:
170 """ forbidden: 403 """
171 status = self._get_status(response)
172 return status == 403
173
174 def not_found(self, response: Response) -> bool:
175 """ not_found: 404 """
176 status = self._get_status(response)
177 return status == 404
178
179 def method_not_allowed(self, response: Response) -> bool:
180 """ method_not_allowed: 405 """
181 status = self._get_status(response)
182 return status == 405
183
184 def not_acceptable(self, response: Response) -> bool:
185 """ not_acceptable: 406 """
186 status = self._get_status(response)
187 return status == 406
188
189 def proxy_authentication_required(self, response: Response) -> bool:
190 """ proxy_authentication_required: 407 """
191 status = self._get_status(response)
192 return status == 407
193
194 def request_timeout(self, response: Response) -> bool:
195 """ request_timeout: 408 """
196 status = self._get_status(response)
197 return status == 408
198
199 def conflict(self, response: Response) -> bool:
200 """ conflict: 409 """
201 status = self._get_status(response)
202 return status == 409
203
204 def gone(self, response: Response) -> bool:
205 """ gone: 410 """
206 status = self._get_status(response)
207 return status == 410
208
209 def length_required(self, response: Response) -> bool:
210 """ length_required: 411 """
211 status = self._get_status(response)
212 return status == 411
213
214 def precondition_failed(self, response: Response) -> bool:
215 """ precondition_failed: 412 """
216 status = self._get_status(response)
217 return status == 412
218
219 def payload_too_large(self, response: Response) -> bool:
220 """ payload_too_large: 413 """
221 status = self._get_status(response)
222 return status == 413
223
224 def uri_too_long(self, response: Response) -> bool:
225 """ uri_too_long: 414 """
226 status = self._get_status(response)
227 return status == 414
228
229 def unsupported_media_type(self, response: Response) -> bool:
230 """ unsupported_media_type: 415 """
231 status = self._get_status(response)
232 return status == 415
233
234 def range_not_satisfiable(self, response: Response) -> bool:
235 """ range_not_satisfiable: 416 """
236 status = self._get_status(response)
237 return status == 416
238
239 def expectation_failed(self, response: Response) -> bool:
240 """ expectation_failed: 417 """
241 status = self._get_status(response)
242 return status == 417
243
244 def im_a_teapot(self, response: Response) -> bool:
245 """ im_a_teapot: 418 """
246 status = self._get_status(response)
247 return status == 418
248
249 def page_expired(self, response: Response) -> bool:
250 """ page_expired: 419 """
251 status = self._get_status(response)
252 return status == 419
253
254 def enhance_your_calm(self, response: Response) -> bool:
255 """ enhance_your_calm: 420 """
256 status = self._get_status(response)
257 return status == 420
258
259 def misdirected_request(self, response: Response) -> bool:
260 """ misdirected_request: 421 """
261 status = self._get_status(response)
262 return status == 421
263
264 def unprocessable_entity(self, response: Response) -> bool:
265 """ unprocessable_entity: 422 """
266 status = self._get_status(response)
267 return status == 422
268
269 def locked(self, response: Response) -> bool:
270 """ locked: 423 """
271 status = self._get_status(response)
272 return status == 423
273
274 def failed_dependency(self, response: Response) -> bool:
275 """ failed_dependency: 424 """
276 status = self._get_status(response)
277 return status == 424
278
279 def too_early(self, response: Response) -> bool:
280 """ too_early: 425 """
281 status = self._get_status(response)
282 return status == 425
283
284 def upgrade_required(self, response: Response) -> bool:
285 """ upgrade_required: 426 """
286 status = self._get_status(response)
287 return status == 426
288
289 def precondition_required(self, response: Response) -> bool:
290 """ precondition_required: 428 """
291 status = self._get_status(response)
292 return status == 428
293
294 def too_many_requests(self, response: Response) -> bool:
295 """ too_many_requests: 429 """
296 status = self._get_status(response)
297 return status == 429
298
299 def request_header_fields_too_large(self, response: Response) -> bool:
300 """ request_header_fields_too_large: 431 """
301 status = self._get_status(response)
302 return status == 431
303
304 def unavailable_for_legal_reasons(self, response: Response) -> bool:
305 """ unavailable_for_legal_reasons: 451 """
306 status = self._get_status(response)
307 return status == 451
308
309 def invalid_token(self, response: Response) -> bool:
310 """ invalid_token: 498 """
311 status = self._get_status(response)
312 return status == 498
313
314 """ 5xx server error"""
315
316 def internal_server_error(self, response: Response) -> bool:
317 """ internal_server_error: 500 """
318 status = self._get_status(response)
319 return status == 500
320
321 def not_implemented(self, response: Response) -> bool:
322 """ not_implemented: 501 """
323 status = self._get_status(response)
324 return status == 501
325
326 def bad_gateway(self, response: Response) -> bool:
327 """ bad_gateway: 502 """
328 status = self._get_status(response)
329 return status == 502
330
331 def service_unavailable(self, response: Response) -> bool:
332 """ service_unavailable: 503 """
333 status = self._get_status(response)
334 return status == 503
335
336 def gateway_timeout(self, response: Response) -> bool:
337 """ gateway_timeout: 504 """
338 status = self._get_status(response)
339 return status == 504
340
341 def http_version_not_supported(self, response: Response) -> bool:
342 """ http_version_not_supported: 505 """
343 status = self._get_status(response)
344 return status == 505
345
346 def variant_also_negotiates(self, response: Response) -> bool:
347 """ variant_also_negotiates: 506 """
348 status = self._get_status(response)
349 return status == 506
350
351 def insufficient_storage(self, response: Response) -> bool:
352 """ insufficient_storage: 507 """
353 status = self._get_status(response)
354 return status == 507
355
356 def loop_detected(self, response: Response) -> bool:
357 """ loop_detected: 508 """
358 status = self._get_status(response)
359 return status == 508
360
361 def bandwidth_limit_exceeded(self, response: Response) -> bool:
362 """ bandwidth_limit_exceeded: 509 """
363 status = self._get_status(response)
364 return status == 509
365
366 def not_extended(self, response: Response) -> bool:
367 """ not_extended: 510 """
368 status = self._get_status(response)
369 return status == 510
370
371 def network_authentication_required(self, response: Response) -> bool:
372 """ network_authentication_required: 511 """
373 status = self._get_status(response)
374 return status == 511
bool unauthorized(self, Response response)
bool permanent_redirect(self, Response response)
bool im_used(self, Response response)
bool failed_dependency(self, Response response)
bool not_acceptable(self, Response response)
bool see_other(self, Response response)
bool precondition_required(self, Response response)
bool proxy_authentication_required(self, Response response)
bool no_content(self, Response response)
bool method_not_allowed(self, Response response)
bool unprocessable_entity(self, Response response)
bool multi_status(self, Response response)
bool success(self, Response response)
bool invalid_token(self, Response response)
bool payment_required(self, Response response)
bool multiple_choices(self, Response response)
bool im_a_teapot(self, Response response)
bool request_header_fields_too_large(self, Response response)
bool page_expired(self, Response response)
bool response_is_stale(self, Response response)
bool payload_too_large(self, Response response)
bool forbidden(self, Response response)
bool switching_protocols(self, Response response)
bool upgrade_required(self, Response response)
bool gone(self, Response response)
bool found(self, Response response)
bool created(self, Response response)
bool accepted(self, Response response)
bool reset_content(self, Response response)
bool send_continue(self, Response response)
bool range_not_satisfiable(self, Response response)
bool length_required(self, Response response)
bool expectation_failed(self, Response response)
bool uri_too_long(self, Response response)
bool too_early(self, Response response)
bool conflict(self, Response response)
bool already_reported(self, Response response)
bool processing(self, Response response)
bool too_many_requests(self, Response response)
bool not_modified(self, Response response)
bool misdirected_request(self, Response response)
bool moved_permanently(self, Response response)
bool not_found(self, Response response)
bool switch_proxy(self, Response response)
bool use_proxy(self, Response response)
bool unsupported_media_type(self, Response response)
bool unavailable_for_legal_reasons(self, Response response)
bool non_authoritative_information(self, Response response)
bool bad_request(self, Response response)
bool early_hints(self, Response response)
bool precondition_failed(self, Response response)
int _get_status(self, Response response)
bool request_timeout(self, Response response)
bool enhance_your_calm(self, Response response)
bool temporary_redirect(self, Response response)
bool partial_content(self, Response response)
bool locked(self, Response response)