B _¸³^¸ ã@s.ddlTddlZddlZGdd„dejƒZdS)é)Ú*Nc@sDeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dS)Ú TestLogHelpercCsžt d¡}t ¡}| |¡g}x,tttjjƒƒD]}| tjj|j ¡q2Wt ddddg}x,tttjjƒƒD]}| tjj|j ¡qrW|  ||¡dS)NÚ1ÚDEBUGÚCRITICAL)ÚlevelÚ formatter_clsÚ boto_level) ÚloggingÚ getLoggerÚ StreamHandlerÚ addHandlerÚrangeÚlenÚrootÚhandlersÚappendÚ formatterÚsetupÚ assertEqual)ÚselfÚloggerÚhandlerZorig_formattersÚcZnew_formatters©rúm/private/var/folders/6d/485zl0ms10b8gn_c1vw1k_780000gn/T/pip-unpacked-wheel-ytewl15c/tests/test_log_helper.pyÚtest_logging_no_formattings  z(TestLogHelper.test_logging_no_formattingcCsTt d¡}t ¡}| |¡tddddx$dD]}t |¡}| |jd¡q0WdS)NÚ2rr)rrr )ÚbotoÚboto3ÚbotocoreÚurllib3é2)r r r r rrr)rrrÚtÚb_loggerrrrÚtest_logging_boto_explicits    z(TestLogHelper.test_logging_boto_explicitcCsRt d¡}t ¡}| |¡tdtddx"tjjD]}| tt |j ƒ¡q4WdS)NÚ3rÚ ContainerInit)rrÚ RequestType) r r r r rÚ JsonFormatterrrrÚtyper)rrrrrrÚtest_logging_jsons   zTestLogHelper.test_logging_jsoncCsTt d¡}t ¡}| |¡tdtddx$dD]}t |¡}| |jd¡q0WdS)NÚ4rr')rrr()rrr r!é )r r r r rr)rr)rrrr#r$rrrÚtest_logging_boto_implicit&s    z(TestLogHelper.test_logging_boto_implicitc Csx| ¡H}t ¡}t ¡}| |¡tdtdd| d¡t  |j d¡}WdQRX|  dddd d gt |  ¡ƒ¡dS) Nrr')rrr(ÚtestrÚ timestamprÚlocationr(Úmessage)Ú assertLogsr r r r rr)ÚinfoÚjsonÚloadsÚoutputrÚlistÚkeys)rÚctxrrÚlogsrrrÚtest_logging_json_keys/s   z$TestLogHelper.test_logging_json_keysc Csj| ¡H}t ¡}t ¡}| |¡tdtdd| d¡t  |j d¡}WdQRX|  i|d¡dS)Nrr')rrr(z{}rr2) r3r r r r rr)r4r5r6r7r)rr:rrr;rrrÚtest_logging_json_parse_message9s   z-TestLogHelper.test_logging_json_parse_messagec Csž| ¡|}t ¡}t ¡}| |¡tdtddy ddWn0tk rn}z|jdddWdd}~XYnXt   |j d ¡}WdQRX|  d |  ¡¡dS) Nrr')rrr(ér#z[]T)Úexc_inforÚ exception)r3r r r r rr)Ú Exceptionr4r5r6r7ZassertInr9)rr:rrÚer;rrrÚtest_logging_json_exceptionCs    z)TestLogHelper.test_logging_json_exceptionN) Ú__name__Ú __module__Ú __qualname__rr%r+r.r<r=rCrrrrrs     r)Zcrhelper.log_helperZunittestr ZTestCaserrrrrÚs