
    };e/                         d Z eZddlZddlmZmZmZmZm	Z	m
Z
mZmZmZ  G d de      Z G d dej                         Zy)z(Tests for the error_for helper function.    N)	ClientErrorConflictMethodNotAllowedNotFoundPreconditionFailedResponseErrorServerErrorUnauthorized	error_forc                       e Zd ZdZd Zy)StubRequestz-Just enough of a request to fool error_for().c                     || _         y )N)statusselfr   s     E/usr/lib/python3/dist-packages/lazr/restfulclient/tests/test_error.py__init__zStubRequest.__init__(   s	        N)__name__
__module____qualname____doc__r    r   r   r   r   %   s
    7r   r   c                   P    e Zd ZddZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zy)TestErrorForc                     t        |      }t        ||      }|| j                  |       y| j                  t	        ||             | j                  ||j                         y)z9Make sure error_for returns the right HTTPError subclass.N)r   r   assertIsNone
assertTrue
isinstanceassertEqualcontent)r   r   expected_errorr!   requesterrors         r   error_for_statuszTestErrorFor.error_for_status-   sS    f%'7+!e$OOJun=>Wemm4r   c                 6    dD ]  }| j                  |d        y)z.Make sure a 2xx response code yields no error.)         i+  Nr%   r   s     r   test_no_error_for_2xxz"TestErrorFor.test_no_error_for_2xx7   s!    * 	0F!!&$/	0r   c                 6    dD ]  }| j                  |d        y)z.Make sure a 3xx response code yields no error.)i-  i.  i/  i0  i  Nr*   r   s     r   test_no_error_for_3xxz"TestErrorFor.test_no_error_for_3xx<   s!    / 	0F!!&$/	0r   c                 2    | j                  dt        d       y)z3Make sure a 400 response code yields ResponseError.i  error messageN)r%   r   r   s    r   test_error_for_400zTestErrorFor.test_error_for_400A   s    c=/Br   c                 2    | j                  dt        d       y)z2Make sure a 401 response code yields Unauthorized.i  r/   N)r%   r
   r0   s    r   test_error_for_401zTestErrorFor.test_error_for_401E   s    c<Ar   c                 2    | j                  dt        d       y)z/Make sure a 404 response code yields Not Found.i  r/   N)r%   r   r0   s    r   test_error_for_404zTestErrorFor.test_error_for_404I       c8_=r   c                 2    | j                  dt        d       y)z6Make sure a 405 response code yields MethodNotAllowed.i  r/   N)r%   r   r0   s    r   test_error_for_405zTestErrorFor.test_error_for_405M   s    c#3_Er   c                 2    | j                  dt        d       y)z.Make sure a 409 response code yields Conflict.i  r/   N)r%   r   r0   s    r   test_error_for_409zTestErrorFor.test_error_for_409Q   r6   r   c                 2    | j                  dt        d       y)z8Make sure a 412 response code yields PreconditionFailed.i  r/   N)r%   r   r0   s    r   test_error_for_412zTestErrorFor.test_error_for_412U   s    c#5Gr   c                 2    | j                  dt        d       y)z?Make sure an unrexognized 4xx response code yields ClientError.i  r/   N)r%   r   r0   s    r   test_error_for_4xxzTestErrorFor.test_error_for_4xxY   s    c;@r   c                 >    dD ]  }| j                  |t                y)z2Make sure a 5xx response codes yields ServerError.)i  i  i  iW  N)r%   r	   r   s     r   test_no_error_for_5xxz"TestErrorFor.test_no_error_for_5xx]   s!    * 	7F!!&+6	7r   N) )r   r   r   r%   r+   r-   r1   r3   r5   r8   r:   r<   r>   r@   r   r   r   r   r   ,   s>    50
0
CB>F>HA7r   r   )r   type__metaclass__unittestlazr.restfulclient.errorsr   r   r   r   r   r   r	   r
   r   objectr   TestCaser   r   r   r   <module>rH      s?   $ / 
 
 
& 478$$ 47r   