HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/lazr/restfulclient/tests/__pycache__/test_error.cpython-38.pyc
U

��%U
�@sbdZeZddlZddlmZmZmZmZm	Z	m
Z
mZmZm
Z
Gdd�de�ZGdd�dej�ZdS)z(Tests for the error_for helper function.�N)	�ClientError�Conflict�MethodNotAllowed�NotFound�PreconditionFailed�
ResponseError�ServerError�Unauthorized�	error_forc@seZdZdZdd�ZdS)�DummyRequestz-Just enough of a request to fool error_for().cCs
||_dS)N)�status��selfr�r�E/usr/lib/python3/dist-packages/lazr/restfulclient/tests/test_error.py�__init__szDummyRequest.__init__N)�__name__�
__module__�__qualname__�__doc__rrrrrrsrc@sfeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�TestErrorFor�cCsHt|�}t||�}|dkr&|�|�n|�t||��|�||j�dS)z9Make sure error_for returns the right HTTPError subclass.N)rr
ZassertIsNoneZ
assertTrue�
isinstanceZassertEqual�content)rrZexpected_errorrZrequest�errorrrr�error_for_status%s
zTestErrorFor.error_for_statuscCsdD]}|�|d�qdS)z.Make sure a 2xx response code yields no error.)������i+N�rr
rrr�test_no_error_for_2xx/sz"TestErrorFor.test_no_error_for_2xxcCsdD]}|�|d�qdS)z.Make sure a 3xx response code yields no error.)i-i.i/i0i�Nrr
rrr�test_no_error_for_3xx4sz"TestErrorFor.test_no_error_for_3xxcCs|�dtd�dS)z3Make sure a 400 response code yields ResponseError.i��
error messageN)rr�rrrr�test_error_for_4009szTestErrorFor.test_error_for_400cCs|�dtd�dS)z2Make sure a 401 response code yields Unauthorized.i�r"N)rr	r#rrr�test_error_for_401=szTestErrorFor.test_error_for_401cCs|�dtd�dS)z/Make sure a 404 response code yields Not Found.i�r"N)rrr#rrr�test_error_for_404AszTestErrorFor.test_error_for_404cCs|�dtd�dS)z6Make sure a 405 response code yields MethodNotAllowed.i�r"N)rrr#rrr�test_error_for_405EszTestErrorFor.test_error_for_405cCs|�dtd�dS)z.Make sure a 409 response code yields Conflict.i�r"N)rrr#rrr�test_error_for_409IszTestErrorFor.test_error_for_409cCs|�dtd�dS)z8Make sure a 412 response code yields PreconditionFailed.i�r"N)rrr#rrr�test_error_for_412MszTestErrorFor.test_error_for_412cCs|�dtd�dS)z?Make sure an unrexognized 4xx response code yields ClientError.i�r"N)rrr#rrr�test_error_for_4xxQszTestErrorFor.test_error_for_4xxcCsdD]}|�|t�qdS)z2Make sure a 5xx response codes yields ServerError.)i�i�i�iWN)rrr
rrr�test_no_error_for_5xxUsz"TestErrorFor.test_no_error_for_5xxN)r)rrrrr r!r$r%r&r'r(r)r*r+rrrrr#s

r)r�typeZ
__metaclass__ZunittestZlazr.restfulclient.errorsrrrrrrrr	r
�objectrZTestCaserrrrr�<module>s
,