JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3RbrJFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr gddlmZddlmZmZddlmZmZddl mZm Z ddl m Z ddl mZddlmZdd lmZdd lmZdd lmZdd lmZdd l mZej4dZdZGddeZy))md5)loaddumps) b64decode b64encode)rloads)path) OneServer)pickling_support)exc_info)reraise) OrderedDict)open)environcTt|d}t|}|j|S)Nrt)rrclose) fixture_filefrets ;/opt/hc_python/lib/python3.12/site-packages/pyone/tester.pyread_fixture_filer s% \4 A q'CGGI Jct|d}|jt|j|j y)Nwb)rwrite json_dumpsencoder)robjrs rwrite_fixture_filer!'s0 \4 AGGJsO " " $%GGIrcNeZdZdZd dZdZdZdZdZdZ d Z d Z d Z d Z y)OneServerTesteraQ This class extends the OneServer to facilitate unit testing The idea is to be able to "record" fixtures while testing with a live OpenNebula platform. Those recordings can later be use in "replay" mode to simulate an OpenNebula platform. XMLAPI method calls are recorded as test_base/unit_test/method_signature_instance The signature is generated as the md5 of the parameters if several calls with the same signature are doing during the same unit test, instance is incremented. The order in which calls happen within the same unit_test must be deterministic. Nc |tjdd}|&tjddjdv}|tjdd}tj|rt ||_nt|_||_||_ |j|tj||||fi|y)NPYONE_TEST_FIXTURE_FILEPYONE_TEST_FIXTURE_REPLAYTrue)1yestruePYONE_TEST_FIXTURE_UNITinit) rgetlowerr isfiler _fixturesdict_fixture_replay _fixture_fileset_fixture_unit_testr __init__)selfurisessionr fixture_unittimeoutfixture_replayoptionss rr5zOneServerTester.__init__6s  ";;'@$GL  !%kk*EvNTTVZnnN  ";;'@&IL ;;| $.|rHpop Exception)r6rDrErs r _get_fixturezOneServerTester._get_fixturebsG%%j1$2I2I*U[2\]aabcdfg g rc|j||}||jvrt|j|<||j|vrg|j||<|j||j|y)z} Will create the fixture for a given call :param methodname: :param params: :return: N)rHr>r1append)r6rDrEobject signatures r _set_fixturezOneServerTester._set_fixtureqs|++Jv> T44404D # #J /D33J??;=D # #J / :  +I6==fErcd}|jr5|j||}d|vrttt |d|S t j |||} |j||||S#t$r4}dtttdji}|d}~wwxYw#|j|||wxYw)z Intercepts requests. In record mode they are recorded before being returned. In replay mode they are read from fixtures instead Exceptions are also captured and reraised N exception) r2rLrrrr _do_requestrKrrr decoderQ)r6methodrErrSs rrUzOneServerTester._do_requests   ##F62Cc!y[)9:;<  5++D&&A!!&4  5Q+?!@!G!G!I   !!&4s$A22 B/;/B**B//B22Cct|}t|D]*\}}t|ts|j |||<,t j ||S)a Parameters will be used to generate the signature of the method, an md5. So we need signatures to be deterministic. There are two sources of randomness - Python version, in particular differences in dealing with encodings - Unsorted sets. This method will add casting transformations to fix those, only required for testing. :param params: :return: a list of parameters that should generate a deterministic md5 signature. )list enumerate isinstancer1_to_ordered_dictr _cast_parms)r6rElparamsiparams rr]zOneServerTester._cast_parmssSv,!'*HAu%&!2259 +%%dG44rct|tr_tt|j }|j D]*\}}t|ts|j |||<,|S)zQ deep orders a dictionary :param param: :return: )r[r1rsorteditemsr\)r6r`keyvalues rr\z OneServerTester._to_ordered_dicts\ eD !u{{} 56E#kkm UeT*!%!6!6u!=E#J, rcy)Ng{Gz?r6s rserver_retry_intervalz%OneServerTester.server_retry_intervalsrc^|js!t|j|jyy)zQ Unpdates the fixture data if we are recording. :return: N)r2r!r3r0rhs r server_closezOneServerTester.server_closes& ## t114>> B$r)NNNN)__name__ __module__ __qualname____doc__r5r4rHrLrQrUr]r\rirkrgrrr#r#,s<C4 7) F$45& Crr#N)hashlibrjsonrrrbase64rrpicklerosr r tblibr sysr sixr collectionsrgziprrinstallrr!r#rgrrr|sT *'"# ]Ci]Cr