Terarea  2
The automation project
Loading...
Searching...
No Matches
test_http_codes.py
Go to the documentation of this file.
1"""_summary_
2 File in charge of testing the http response codes.
3"""
4import os
5import sys
6from fastapi import Response
7
8sys.path.append(os.getcwd())
9try:
10 from src import HCI
11except ImportError as e:
12 raise ImportError("Failed to import the src module") from e
13
14
15def _get_status(data: Response) -> int:
16 """_summary_
17 Get the generated status from the boilerplate.
18
19 Args:
20 data (Response): _description_
21
22 Returns:
23 int: _description_
24 """
25 return data.status_code
26
27
28def test_send_continue() -> None:
29 """ send_continue: 100 """
30 status = _get_status(HCI.send_continue())
31 assert status == 100
32
33
35 """ switching_protocols: 101 """
36 status = _get_status(HCI.switching_protocols())
37 assert status == 101
38
39
40def test_processing() -> None:
41 """ processing: 102 """
42 status = _get_status(HCI.processing())
43 assert status == 102
44
45
46def test_early_hints() -> None:
47 """ early_hints: 103 """
48 status = _get_status(HCI.early_hints())
49 assert status == 103
50
51
53 """ response_is_stale: 110 """
54 status = _get_status(HCI.response_is_stale())
55 assert status == 110
56
57
58def test_success() -> None:
59 """ success: 200 """
60 status = _get_status(HCI.success())
61 assert status == 200
62
63
64def test_created() -> None:
65 """ created: 201 """
66 status = _get_status(HCI.created())
67 assert status == 201
68
69
70def test_accepted() -> None:
71 """ accepted: 202 """
72 status = _get_status(HCI.accepted())
73 assert status == 202
74
75
77 """ non_authoritative_information: 203 """
78 status = _get_status(HCI.non_authoritative_information())
79 assert status == 203
80
81
82def test_no_content() -> None:
83 """ no_content: 204 """
84 status = _get_status(HCI.no_content())
85 assert status == 204
86
87
88def test_reset_content() -> None:
89 """ reset_content: 205 """
90 status = _get_status(HCI.reset_content())
91 assert status == 205
92
93
95 """ partial_content: 206 """
96 status = _get_status(HCI.partial_content())
97 assert status == 206
98
99
100def test_multi_status() -> None:
101 """ multi_status: 207 """
102 status = _get_status(HCI.multi_status())
103 assert status == 207
104
105
107 """ already_reported: 208 """
108 status = _get_status(HCI.already_reported())
109 assert status == 208
110
111
112def test_im_used() -> None:
113 """ im_used: 226 """
114 status = _get_status(HCI.im_used())
115 assert status == 226
116
117
119 """ multiple_choices: 300 """
120 status = _get_status(HCI.multiple_choices())
121 assert status == 300
122
123
125 """ moved_permanently: 301 """
126 status = _get_status(HCI.moved_permanently())
127 assert status == 301
128
129
130def test_found() -> None:
131 """ found: 302 """
132 status = _get_status(HCI.found())
133 assert status == 302
134
135
136def test_see_other() -> None:
137 """ see_other: 303 """
138 status = _get_status(HCI.see_other())
139 assert status == 303
140
141
142def test_not_modified() -> None:
143 """ not_modified: 304 """
144 status = _get_status(HCI.not_modified())
145 assert status == 304
146
147
148def test_use_proxy() -> None:
149 """ use_proxy: 305 """
150 status = _get_status(HCI.use_proxy())
151 assert status == 305
152
153
154def test_switch_proxy() -> None:
155 """ switch_proxy: 306 """
156 status = _get_status(HCI.switch_proxy())
157 assert status == 306
158
159
161 """ temporary_redirect: 307 """
162 status = _get_status(HCI.temporary_redirect())
163 assert status == 307
164
165
167 """ permanent_redirect: 308 """
168 status = _get_status(HCI.permanent_redirect())
169 assert status == 308
170
171
172def test_bad_request() -> None:
173 """ bad_request: 400 """
174 status = _get_status(HCI.bad_request())
175 assert status == 400
176
177
178def test_unauthorized() -> None:
179 """ unauthorized: 401 """
180 status = _get_status(HCI.unauthorized())
181 assert status == 401
182
183
185 """ payment_required: 402 """
186 status = _get_status(HCI.payment_required())
187 assert status == 402
188
189
190def test_forbidden() -> None:
191 """ forbidden: 403 """
192 status = _get_status(HCI.forbidden())
193 assert status == 403
194
195
196def test_not_found() -> None:
197 """ not_found: 404 """
198 status = _get_status(HCI.not_found())
199 assert status == 404
200
201
203 """ method_not_allowed: 405 """
204 status = _get_status(HCI.method_not_allowed())
205 assert status == 405
206
207
209 """ not_acceptable: 406 """
210 status = _get_status(HCI.not_acceptable())
211 assert status == 406
212
213
215 """ proxy_authentication_required: 407 """
216 status = _get_status(HCI.proxy_authentication_required())
217 assert status == 407
218
219
221 """ request_timeout: 408 """
222 status = _get_status(HCI.request_timeout())
223 assert status == 408
224
225
226def test_conflict() -> None:
227 """ conflict: 409 """
228 status = _get_status(HCI.conflict())
229 assert status == 409
230
231
232def test_gone() -> None:
233 """ gone: 410 """
234 status = _get_status(HCI.gone())
235 assert status == 410
236
237
239 """ length_required: 411 """
240 status = _get_status(HCI.length_required())
241 assert status == 411
242
243
245 """ precondition_failed: 412 """
246 status = _get_status(HCI.precondition_failed())
247 assert status == 412
248
249
251 """ payload_too_large: 413 """
252 status = _get_status(HCI.payload_too_large())
253 assert status == 413
254
255
256def test_uri_too_long() -> None:
257 """ uri_too_long: 414 """
258 status = _get_status(HCI.uri_too_long())
259 assert status == 414
260
261
263 """ unsupported_media_type: 415 """
264 status = _get_status(HCI.unsupported_media_type())
265 assert status == 415
266
267
269 """ range_not_satisfiable: 416 """
270 status = _get_status(HCI.range_not_satisfiable())
271 assert status == 416
272
273
275 """ expectation_failed: 417 """
276 status = _get_status(HCI.expectation_failed())
277 assert status == 417
278
279
280def test_im_a_teapot() -> None:
281 """ im_a_teapot: 418 """
282 status = _get_status(HCI.im_a_teapot())
283 assert status == 418
284
285
286def test_page_expired() -> None:
287 """ page_expired: 419 """
288 status = _get_status(HCI.page_expired())
289 assert status == 419
290
291
293 """ enhance_your_calm: 420 """
294 status = _get_status(HCI.enhance_your_calm())
295 assert status == 420
296
297
299 """ misdirected_request: 421 """
300 status = _get_status(HCI.misdirected_request())
301 assert status == 421
302
303
305 """ unprocessable_entity: 422 """
306 status = _get_status(HCI.unprocessable_entity())
307 assert status == 422
308
309
310def test_locked() -> None:
311 """ locked: 423 """
312 status = _get_status(HCI.locked())
313 assert status == 423
314
315
317 """ failed_dependency: 424 """
318 status = _get_status(HCI.failed_dependency())
319 assert status == 424
320
321
322def test_too_early() -> None:
323 """ too_early: 425 """
324 status = _get_status(HCI.too_early())
325 assert status == 425
326
327
329 """ upgrade_required: 426 """
330 status = _get_status(HCI.upgrade_required())
331 assert status == 426
332
333
335 """ precondition_required: 428 """
336 status = _get_status(HCI.precondition_required())
337 assert status == 428
338
339
341 """ too_many_requests: 429 """
342 status = _get_status(HCI.too_many_requests())
343 assert status == 429
344
345
347 """ request_header_fields_too_large: 431 """
348 status = _get_status(HCI.request_header_fields_too_large())
349 assert status == 431
350
351
353 """ unavailable_for_legal_reasons: 451 """
354 status = _get_status(HCI.unavailable_for_legal_reasons())
355 assert status == 451
356
357
358def test_invalid_token() -> None:
359 """ invalid_token: 498 """
360 status = _get_status(HCI.invalid_token())
361 assert status == 498
362
363
365 """ internal_server_error: 500 """
366 status = _get_status(HCI.internal_server_error())
367 assert status == 500
368
369
371 """ not_implemented: 501 """
372 status = _get_status(HCI.not_implemented())
373 assert status == 501
374
375
376def test_bad_gateway() -> None:
377 """ bad_gateway: 502 """
378 status = _get_status(HCI.bad_gateway())
379 assert status == 502
380
381
383 """ service_unavailable: 503 """
384 status = _get_status(HCI.service_unavailable())
385 assert status == 503
386
387
389 """ gateway_timeout: 504 """
390 status = _get_status(HCI.gateway_timeout())
391 assert status == 504
392
393
395 """ http_version_not_supported: 505 """
396 status = _get_status(HCI.http_version_not_supported())
397 assert status == 505
398
399
401 """ variant_also_negotiates: 506 """
402 status = _get_status(HCI.variant_also_negotiates())
403 assert status == 506
404
405
407 """ insufficient_storage: 507 """
408 status = _get_status(HCI.insufficient_storage())
409 assert status == 507
410
411
412def test_loop_detected() -> None:
413 """ loop_detected: 508 """
414 status = _get_status(HCI.loop_detected())
415 assert status == 508
416
417
419 """ bandwidth_limit_exceeded: 509 """
420 status = _get_status(HCI.bandwidth_limit_exceeded())
421 assert status == 509
422
423
424def test_not_extended() -> None:
425 """ not_extended: 510 """
426 status = _get_status(HCI.not_extended())
427 assert status == 510
428
429
431 """ network_authentication_required: 511 """
432 status = _get_status(HCI.network_authentication_required())
433 assert status == 511
None test_method_not_allowed()
None test_internal_server_error()
None test_misdirected_request()
None test_insufficient_storage()
None test_proxy_authentication_required()
None test_unavailable_for_legal_reasons()
None test_precondition_required()
int _get_status(Response data)
None test_service_unavailable()
None test_enhance_your_calm()
None test_partial_content()
None test_request_header_fields_too_large()
None test_unprocessable_entity()
None test_permanent_redirect()
None test_payload_too_large()
None test_http_version_not_supported()
None test_too_many_requests()
None test_network_authentication_required()
None test_range_not_satisfiable()
None test_failed_dependency()
None test_expectation_failed()
None test_precondition_failed()
None test_non_authoritative_information()
None test_response_is_stale()
None test_bandwidth_limit_exceeded()
None test_switching_protocols()
None test_variant_also_negotiates()
None test_moved_permanently()
None test_temporary_redirect()
None test_unsupported_media_type()