o %U @sbdZeZddlZddlmZmZmZmZm Z m Z m Z m Z m Z GdddeZGdddejZdS)z(Tests for the error_for helper function.N) ClientErrorConflictMethodNotAllowedNotFoundPreconditionFailed ResponseError ServerError Unauthorized error_forc@seZdZdZddZdS) DummyRequestz-Just enough of a request to fool error_for().cCs ||_dS)N)statusselfr rE/usr/lib/python3/dist-packages/lazr/restfulclient/tests/test_error.py__init__s zDummyRequest.__init__N)__name__ __module__ __qualname____doc__rrrrrr s r c@sfeZdZdddZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ dS) TestErrorForcCsJt|}t||}|dur||dS|t|||||jdS)z9Make sure error_for returns the right HTTPError subclass.N)r r assertIsNone assertTrue isinstance assertEqualcontent)rr expected_errorrrequesterrorrrrerror_for_status%s  zTestErrorFor.error_for_statuscCdD]}||dqdS)z.Make sure a 2xx response code yields no error.)i+Nr r rrrtest_no_error_for_2xx/z"TestErrorFor.test_no_error_for_2xxcCr!)z.Make sure a 3xx response code yields no error.)i-i.i/i0iNr%r rrrtest_no_error_for_3xx4r'z"TestErrorFor.test_no_error_for_3xxcC|dtddS)z3Make sure a 400 response code yields ResponseError.i error messageN)r rrrrrtest_error_for_4009zTestErrorFor.test_error_for_400cCr))z2Make sure a 401 response code yields Unauthorized.ir*N)r r r+rrrtest_error_for_401=r-zTestErrorFor.test_error_for_401cCr))z/Make sure a 404 response code yields Not Found.ir*N)r rr+rrrtest_error_for_404Ar-zTestErrorFor.test_error_for_404cCr))z6Make sure a 405 response code yields MethodNotAllowed.ir*N)r rr+rrrtest_error_for_405Er-zTestErrorFor.test_error_for_405cCr))z.Make sure a 409 response code yields Conflict.ir*N)r rr+rrrtest_error_for_409Ir-zTestErrorFor.test_error_for_409cCr))z8Make sure a 412 response code yields PreconditionFailed.ir*N)r rr+rrrtest_error_for_412Mr-zTestErrorFor.test_error_for_412cCr))z?Make sure an unrexognized 4xx response code yields ClientError.ir*N)r rr+rrrtest_error_for_4xxQr-zTestErrorFor.test_error_for_4xxcCsdD]}||tqdS)z2Make sure a 5xx response codes yields ServerError.)iiiiWN)r rr rrrtest_no_error_for_5xxUr'z"TestErrorFor.test_no_error_for_5xxN)r)rrrr r&r(r,r.r/r0r1r2r3r4rrrrr#s   r)rtype __metaclass__unittestlazr.restfulclient.errorsrrrrrrrr r objectr TestCaserrrrrs ,