§
    ÈtºfbG  ã                   óR  — d Z ddlmZmZ ddlmZmZmZmZm	Z	m
Z
 ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ d	d
lmZ d	dlmZ d	dlmZ d	dlmZmZ d	dlmZm Z m!Z!m"Z"m#Z$ d	dl%m&Z& d	dl'm(Z( d	dl)m*Z* dede+de+fd„Z, G d„ de¦  «        Z- G d„ de¦  «        Z. G d„ de¦  «        Z/dS )z$
Tests for L{twisted.logger._json}.
é    )ÚBytesIOÚStringIO)ÚIOÚAnyÚListÚOptionalÚSequenceÚcast)Úimplementer)ÚBrokenMethodImplementation)ÚverifyObject)ÚFailure)ÚTestCaseé   )ÚextractField)ÚformatEvent)ÚglobalLogPublisher)ÚILogObserverÚLogEvent)ÚeventAsJSONÚeventFromJSONÚeventsFromJSONLogFileÚjsonFileLogObserverÚlog)ÚLogLevel)ÚLogger)ÚLogPublisherÚtestCaseÚ	savedJSONÚreturnc                 óŽ   — |                       |t          ¦  «         |                      |                     d¦  «        d¦  «         |S )a*  
    Assert a few things about the result of L{eventAsJSON}, then return it.

    @param testCase: The L{TestCase} with which to perform the assertions.
    @param savedJSON: The result of L{eventAsJSON}.

    @return: C{savedJSON}

    @raise AssertionError: If any of the preconditions fail.
    ú
r   )ÚassertIsInstanceÚstrÚassertEqualÚcount)r   r   s     ú\/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/logger/test/test_json.pyÚsavedJSONInvariantsr(   !   sB   € ð ×Ò˜i­Ñ-Ô-Ð-Ø×Ò˜Ÿš¨Ñ.Ô.°Ñ2Ô2Ð2ØÐó    c                   ór   — e Zd ZdZdedefd„Zdd„Zdd„Zdd„Z	dd	„Z
dd
„Zdd„Zdd„Zdd„Zdd„Zdd„ZdS )ÚSaveLoadTestsz2
    Tests for loading and saving log events.
    Úeventr    c                 ó<   — t          | t          |¦  «        ¦  «        S )zž
        Serialize some an events, assert some things about it, and return the
        JSON.

        @param event: An event.

        @return: JSON.
        )r(   r   )Úselfr,   s     r'   ÚsavedEventJSONzSaveLoadTests.savedEventJSON6   s   € õ # 4­°UÑ);Ô);Ñ<Ô<Ð<r)   Nc                 ór   — |                       t          |                      i ¦  «        ¦  «        i ¦  «         dS )zX
        Saving and loading an empty dictionary results in an empty dictionary.
        N©r%   r   r/   ©r.   s    r'   Útest_simpleSaveLoadz!SaveLoadTests.test_simpleSaveLoadA   s6   € ð 	×Ò� t×':Ò':¸2Ñ'>Ô'>Ñ?Ô?ÀÑDÔDÐDÐDÐDr)   c           	      ó~   — |                       t          |                      dddœ¦  «        ¦  «        dddœ¦  «         dS )a  
        Saving and loading a dictionary with some simple values in it results
        in those same simple values in the output; according to JSON's rules,
        though, all dictionary keys must be L{str} and any non-L{str}
        keys will be converted.
        r   Ú4)é   Ú3©Ú1r7   Nr1   r2   s    r'   Útest_saveLoadzSaveLoadTests.test_saveLoadG   sR   € ð 	×ÒÝ˜$×-Ò-°!¸#Ð.>Ð.>Ñ?Ô?Ñ@Ô@Ø˜#ÐÐñ	
ô 	
ð 	
ð 	
ð 	
r)   c           	      óš   — |                       t          |                      dt          ¦   «         dœ¦  «        ¦  «        dddidœ¦  «         dS )zx
        Saving and loading an object which cannot be represented in JSON will
        result in a placeholder.
        r   r8   ÚunpersistableTN©r%   r   r/   Úobjectr2   s    r'   Útest_saveUnPersistablez$SaveLoadTests.test_saveUnPersistableS   s[   € ð
 	×ÒÝ˜$×-Ò-°A½F¹H¼HÐ.EÐ.EÑFÔFÑGÔGØ˜?¨DÐ1Ð2Ð2ñ	
ô 	
ð 	
ð 	
ð 	
r)   c           	      óš   — |                       t          |                      dt          ¦   «         dœ¦  «        ¦  «        dddidœ¦  «         dS )zD
        Non-ASCII keys and values can be saved and loaded.
        u   äŒ¡)u   áˆ´r7   r<   TNr=   r2   s    r'   Útest_saveNonASCIIzSaveLoadTests.test_saveNonASCII]   s[   € ð 	×ÒÝ˜$×-Ò-¸ÍÉÌÐ.QÐ.QÑRÔRÑSÔSØ ¸Ð&=Ð>Ð>ñ	
ô 	
ð 	
ð 	
ð 	
r)   c           	      ó:  — dt          t          d¦  «        ¦  «        i}|                     ddi¦  «         |                      t	          |                      |¦  «        ¦  «        dt          t          d¦  «        ¦  «                             d¦  «        i¦  «         dS )zx
        Any L{bytes} objects will be saved as if they are latin-1 so they can
        be faithfully re-loaded.
        Úhelloéÿ   s   skippedÚokayÚcharmapN)ÚbytesÚrangeÚupdater%   r   r/   Údecode)r.   Ú
inputEvents     r'   Útest_saveByteszSaveLoadTests.test_saveBytesf   s–   € ð
 �u¥U¨3¡Z¤ZÑ0Ô0Ð1ˆ
ð 	×Ò˜: vÐ.Ñ/Ô/Ð/Ø×ÒÝ˜$×-Ò-¨jÑ9Ô9Ñ:Ô:Ø•e�E #™JœJÑ'Ô'×.Ò.¨yÑ9Ô9Ð:ñ	
ô 	
ð 	
ð 	
ð 	
r)   c                 óÆ   —  G d„ d¦  «        }d |d¦  «        dœ}t          |                      |¦  «        ¦  «        }|                      t          |¦  «        d¦  «         dS )a
  
        Saving and loading an object which cannot be represented in JSON, but
        has a string representation which I{can} be saved as JSON, will result
        in the same string formatting; any extractable fields will retain their
        data types.
        c                   ó*   — e Zd Zdeddfd„Zdefd„ZdS )ú@SaveLoadTests.test_saveUnPersistableThenFormat.<locals>.ReprableÚvaluer    Nc                 ó   — || _         d S ©N©rP   )r.   rP   s     r'   Ú__init__zISaveLoadTests.test_saveUnPersistableThenFormat.<locals>.Reprable.__init__~   s   € Ø"�”
�
�
r)   c                 ó   — dS )NÚreprable© r2   s    r'   Ú__repr__zISaveLoadTests.test_saveUnPersistableThenFormat.<locals>.Reprable.__repr__�   s   € Ø!�zr)   )Ú__name__Ú
__module__Ú__qualname__r>   rT   r$   rX   rW   r)   r'   ÚReprablerO   }   sQ   € € € € € ð# fð #°ð #ð #ð #ð #ð" #ð "ð "ð "ð "ð "ð "r)   r\   z{object} {object.value}é   ©Ú
log_formatr>   z
reprable 7N)r   r/   r%   r   )r.   r\   rK   ÚoutputEvents       r'   Ú test_saveUnPersistableThenFormatz.SaveLoadTests.test_saveUnPersistableThenFormatu   s�   € ð	"ð 	"ð 	"ð 	"ð 	"ñ 	"ô 	"ð 	"ð %>ÈÈÐRSÉÌÐUÐUˆ
Ý# D×$7Ò$7¸
Ñ$CÔ$CÑDÔDˆØ×Ò� [Ñ1Ô1°<Ñ@Ô@Ð@Ð@Ð@r)   c                 óf  —  G d„ d¦  «        }t          d |¦   «         ¬¦  «        }t          |                      |¦  «        ¦  «        }|                      t	          d|¦  «        d¦  «         |                      t          t          d|¦  «         |                      t          t          d|¦  «         dS )	zs
        L{extractField} can extract fields from an object that's been saved and
        loaded from JSON.
        c                   ó   — e Zd Zdd„ZdS )ú8SaveLoadTests.test_extractingFieldsPostLoad.<locals>.Objr    Nc                 ó   — d| _         d S )NéY  rS   r2   s    r'   rT   zASaveLoadTests.test_extractingFieldsPostLoad.<locals>.Obj.__init__�   s   € Ø �”
�
�
r)   ©r    N)rY   rZ   r[   rT   rW   r)   r'   ÚObjrd   Ž   s(   € € € € € ð!ð !ð !ð !ð !ð !r)   rh   z{object.value}r^   zobject.valuerf   r>   N)Údictr   r/   r%   r   ÚassertRaisesÚKeyError)r.   rh   rK   ÚloadedEvents       r'   Útest_extractingFieldsPostLoadz+SaveLoadTests.test_extractingFieldsPostLoadˆ   s¼   € ð	!ð 	!ð 	!ð 	!ð 	!ñ 	!ô 	!ð 	!õ Ð%5¸c¸c¹e¼eÐDÑDÔDˆ
Ý# D×$7Ò$7¸
Ñ$CÔ$CÑDÔDˆØ×Ò� n°kÑBÔBÀCÑHÔHÐHð
 	×Ò�(¥L°(¸KÑHÔHÐHØ×Ò�(¥L°(¸JÑGÔGÐGÐGÐGr)   c                 ó\  — g }t          t          t          |j        ¦  «        ¬¦  «        }	 ddz   n4# t          $ r' t          ¦   «         }|                     d|¦  «         Y nw xY w|                      t          |¦  «        d¦  «         t          |  
                    |d         ¦  «        ¦  «        d         }|                      |t
          ¦  «         |                      |                     t          ¦  «        ¦  «         |                      |                     ¦   «         t          ¦  «         dS )zl
        Round-tripping a failure through L{eventAsJSON} preserves its class and
        structure.
        ©Úobserverr6   r   za message about failureÚlog_failureN)r   r
   r   ÚappendÚZeroDivisionErrorr   Úfailurer%   Úlenr   r/   r#   Ú
assertTrueÚcheckÚgetTracebackr$   )r.   Úeventsr   ÚfÚloadeds        r'   Útest_failureStructurePreservedz,SaveLoadTests.test_failureStructurePreservedœ   s  € ð
 "$ˆÝ�d¥<°´Ñ?Ô?Ð@Ñ@Ô@ˆð	6Ø�‰EˆEˆEøÝ ð 	6ð 	6ð 	6Ý‘	”	ˆAØ�KŠKÐ1°1Ñ5Ô5Ð5Ð5Ð5ð	6øøøð 	×Ò�˜V™œ aÑ(Ô(Ð(Ý˜t×2Ò2°6¸!´9Ñ=Ô=Ñ>Ô>¸}ÔMˆØ×Ò˜f¥gÑ.Ô.Ð.Ø�Š˜ŸšÕ%6Ñ7Ô7Ñ8Ô8Ð8Ø×Ò˜f×1Ò1Ñ3Ô3µSÑ9Ô9Ð9Ð9Ð9s   ¬2 ².A#Á"A#c                 óÊ   — t          t          j        ¬¦  «        }t          |                      |¦  «        ¦  «        }|                      |d         t          j        ¦  «         dS )zo
        It's important that the C{log_level} key remain a
        L{constantly.NamedConstant} object.
        ©Ú	log_levelr   N)ri   r   Úwarnr   r/   ÚassertIs)r.   rK   rl   s      r'   Útest_saveLoadLevelz SaveLoadTests.test_saveLoadLevel®   sR   € õ
 ¥H¤MÐ2Ñ2Ô2ˆ
Ý# D×$7Ò$7¸
Ñ$CÔ$CÑDÔDˆØ�Š�k +Ô.µ´Ñ>Ô>Ð>Ð>Ð>r)   c                 ól   — t          d¦  «        }|                      |t          d¬¦  «        ¦  «         dS )zž
        If a saved bit of JSON (let's say, from a future version of Twisted)
        were to persist a different log_level, it will resolve as None.
        zZ{"log_level": {"name": "other", "__class_uuid__": "02E59486-F24D-46AD-8224-3ACDF2A5732A"}}Nr~   )r   r%   ri   )r.   rl   s     r'   Útest_saveLoadUnknownLevelz'SaveLoadTests.test_saveLoadUnknownLevel·   sB   € õ
 $ðIñ
ô 
ˆð 	×Ò˜¥d°TÐ&:Ñ&:Ô&:Ñ;Ô;Ð;Ð;Ð;r)   rg   )rY   rZ   r[   Ú__doc__r   r$   r/   r3   r:   r?   rA   rL   ra   rm   r|   r‚   r„   rW   r)   r'   r+   r+   1   s  € € € € € ðð ð	= Hð 	=°ð 	=ð 	=ð 	=ð 	=ðEð Eð Eð Eð

ð 

ð 

ð 

ð
ð 
ð 
ð 
ð
ð 
ð 
ð 
ð
ð 
ð 
ð 
ðAð Að Að Að&Hð Hð Hð Hð(:ð :ð :ð :ð$?ð ?ð ?ð ?ð	<ð 	<ð 	<ð 	<ð 	<ð 	<r)   r+   c                   óD   — e Zd ZdZdd„Zddeddfd„Zdd„Zdd	„Zdd
„Z	dS )ÚFileLogObserverTestsz+
    Tests for L{jsonFileLogObserver}.
    r    Nc                 óø   — t          ¦   «         5 }t          |¦  «        }	 t          t          |¦  «         n,# t          $ r}|                      |¦  «         Y d}~nd}~ww xY wddd¦  «         dS # 1 swxY w Y   dS )zh
        A L{FileLogObserver} returned by L{jsonFileLogObserver} is an
        L{ILogObserver}.
        N)r   r   r   r   r   Úfail)r.   Ú
fileHandlerp   Úes       r'   Útest_interfacez#FileLogObserverTests.test_interfaceÈ   sÌ   € õ
 ‰ZŒZð 	˜:Ý*¨:Ñ6Ô6ˆHðÝ�\¨8Ñ4Ô4Ð4Ð4øÝ-ð ð ð Ø—	’	˜!‘”������øøøøðøøøð		ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	ð 	ð 	s7   �A/ 6µA/¶
AÁ AÁA/ÁAÁA/Á/A3Á6A3úÚrecordSeparatorc                 ó   — t          ¦   «         5 }t          ||¦  «        }t          d¬¦  «        } ||¦  «         |                      |                     ¦   «         |› d�¦  «         ddd¦  «         dS # 1 swxY w Y   dS )a!  
        Asserts that an observer created by L{jsonFileLogObserver} with the
        given arguments writes events serialized as JSON text, using the given
        record separator.

        @param recordSeparator: C{recordSeparator} argument to
            L{jsonFileLogObserver}
        r6   ©Úxz	{"x": 1}
N)r   r   ri   r%   Úgetvalue)r.   rŽ   rŠ   rp   r,   s        r'   ÚassertObserverWritesJSONz-FileLogObserverTests.assertObserverWritesJSONÔ   sÖ   € õ ‰ZŒZð 	V˜:Ý*¨:°ÑGÔGˆHÝ˜1�I‘I”IˆEØˆH�U‰OŒOˆOØ×Ò˜Z×0Ò0Ñ2Ô2°Ð4TÐ4TÐ4TÑUÔUÐUð		Vð 	Vð 	Vñ 	Vô 	Vð 	Vð 	Vð 	Vð 	Vð 	Vð 	Vð 	Vøøøð 	Vð 	Vð 	Vð 	Vð 	Vð 	Vs   �AA3Á3A7Á:A7c                 ó.   — |                       ¦   «          dS )zÏ
        A L{FileLogObserver} created by L{jsonFileLogObserver} writes events
        serialzed as JSON text to a file when it observes events.
        By default, the record separator is C{"\x1e"}.
        N©r“   r2   s    r'   Ú(test_observeWritesDefaultRecordSeparatorz=FileLogObserverTests.test_observeWritesDefaultRecordSeparatorã   s   € ð 	×%Ò%Ñ'Ô'Ð'Ð'Ð'r)   c                 ó2   — |                       d¬¦  «         dS )zÎ
        A L{FileLogObserver} created by L{jsonFileLogObserver} writes events
        serialzed as JSON text to a file when it observes events.
        This test sets the record separator to C{""}.
        Ú ©rŽ   Nr•   r2   s    r'   Ú&test_observeWritesEmptyRecordSeparatorz;FileLogObserverTests.test_observeWritesEmptyRecordSeparatorë   s!   € ð 	×%Ò%°bÐ%Ñ9Ô9Ð9Ð9Ð9r)   c                 ó4  ‡ — t          ¦   «         }t          ¦   «         }g }|                     t          t          |j        ¦  «        ¦  «         |                     t          |¦  «        ¦  «         t          |¬¦  «        }	 ddz   n%# t          $ r | 	                    d¦  «         Y nw xY wt          | 
                    ¦   «         ¦  «        }t          t          |¦  «        ¦  «        }dt          t                   ddfˆ fd„} ||¦  «          ||¦  «         dS )	z›
        A L{FileLogObserver} created by L{jsonFileLogObserver} writes failures
        serialized as JSON text to a file when it observes events.
        ro   r6   r   zfailed as expectedÚ	logEventsr    Nc                 ó�  •— ‰                      t          | ¦  «        d¦  «         | \  }‰                     d|¦  «         |d         }‰                     |t          ¦  «         |                     ¦   «         }‰                      |j        j        j         	                    d¦  «        t           	                    d¦  «        ¦  «         d S )Nr6   rq   Úco)r%   ru   ÚassertInr#   r   ÚgetTracebackObjectÚtb_frameÚf_codeÚco_filenameÚrstripÚ__file__)rœ   ÚfailureEventÚfailureObjectÚtracebackObjectr.   s       €r'   ÚcheckEventsz@FileLogObserverTests.test_failureFormatting.<locals>.checkEvents  s¶   ø€ Ø×Ò�S ™^œ^¨QÑ/Ô/Ð/Ø&‰Nˆ\Ø�MŠM˜-¨Ñ6Ô6Ð6Ø(¨Ô7ˆMØ×!Ò! -µÑ9Ô9Ð9Ø+×>Ò>Ñ@Ô@ˆOØ×ÒØÔ(Ô/Ô;×BÒBÀ4ÑHÔHÝ—’ Ñ%Ô%ñô ð ð ð r)   )r   r   ÚaddObserverr
   r   rr   r   r   ÚBaseExceptionrt   r’   Úlistr   r	   r   )r.   ÚioÚ	publisherÚloggedÚloggerÚreaderÚdeserializedr©   s   `       r'   Útest_failureFormattingz+FileLogObserverTests.test_failureFormattingó   s1  ø€ õ
 ‰ZŒZˆÝ ‘N”Nˆ	Ø!#ˆØ×Ò�d¥<°´Ñ?Ô?Ñ@Ô@Ð@Ø×ÒÕ1°"Ñ5Ô5Ñ6Ô6Ð6Ý Ð+Ñ+Ô+ˆð	1Ø�‰EˆEˆEøÝð 	1ð 	1ð 	1Ø�NŠNÐ/Ñ0Ô0Ð0Ð0Ð0ð	1øøøå˜"Ÿ+š+™-œ-Ñ(Ô(ˆÝÕ1°&Ñ9Ô9Ñ:Ô:ˆð
	¥8­HÔ#5ð 
	¸$ð 
	ð 
	ð 
	ð 
	ð 
	ð 
	ð 	ˆ�FÑÔÐØˆ�LÑ!Ô!Ð!Ð!Ð!s   Â B ÂB(Â'B(rg   )r�   )
rY   rZ   r[   r…   rŒ   r$   r“   r–   rš   r³   rW   r)   r'   r‡   r‡   Ã   sœ   € € € € € ðð ð
ð 
ð 
ð 
ðVð V¸ð VÈð Vð Vð Vð Vð(ð (ð (ð (ð:ð :ð :ð :ð"ð "ð "ð "ð "ð "r)   r‡   c            	       ó¸   — e Zd ZdZdd„Zdd„Z	 	 ddee         dee	         d	e
ddfd
„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„ZdS )ÚLogFileReaderTestsz-
    Tests for L{eventsFromJSONLogFile}.
    r    Nc                 óž   ‡ — g ‰ _         t          t          ¦  «        dt          dd fˆ fd„¦   «         }|‰ _        t          j        |¦  «         d S )Nr,   r    c                 óx   •— | d         t           j        k    r d| v r‰j                             | ¦  «         d S d S d S )NÚlog_namespaceÚrecord)ÚjsonLogÚ	namespaceÚerrorEventsrr   )r,   r.   s    €r'   rp   z*LogFileReaderTests.setUp.<locals>.observer  sK   ø€ à�_Ô%­Ô):Ò:Ð:¸xÈ5Ð?PÐ?PØÔ ×'Ò'¨Ñ.Ô.Ð.Ð.Ð.ð ;Ð:Ð?PÐ?Pr)   )r¼   r   r   r   ÚlogObserverr   rª   )r.   rp   s   ` r'   ÚsetUpzLogFileReaderTests.setUp  sk   ø€ Ø+-ˆÔå	•\Ñ	"Ô	"ð	/�Hð 	/¨ð 	/ð 	/ð 	/ð 	/ð 	/ñ 
#Ô	"ð	/ð $ˆÔåÔ& xÑ0Ô0Ð0Ð0Ð0r)   c                 ó8   — t          j        | j        ¦  «         d S rR   )r   ÚremoveObserverr½   r2   s    r'   ÚtearDownzLogFileReaderTests.tearDown&  s   € ÝÔ)¨$Ô*:Ñ;Ô;Ð;Ð;Ð;r)   é   ÚinFilerŽ   Ú
bufferSizec                 ó  — t          t          |||¦  «        ¦  «        }|                      t          |¦  «        ddi¦  «         |                      t          |¦  «        ddi¦  «         |                      t
          t          |¦  «         dS )a|  
        Test that L{eventsFromJSONLogFile} reads two pre-defined events from a
        file: C{{"x": 1}} and C{{"y": 2}}.

        @param inFile: C{inFile} argument to L{eventsFromJSONLogFile}
        @param recordSeparator: C{recordSeparator} argument to
            L{eventsFromJSONLogFile}
        @param bufferSize: C{bufferSize} argument to L{eventsFromJSONLogFile}
        r‘   r6   Úyr   N)Úiterr   r%   Únextrj   ÚStopIteration)r.   rÃ   rŽ   rÄ   ry   s        r'   Ú_readEventszLogFileReaderTests._readEvents)  s|   € õ Õ+¨F°OÀZÑPÔPÑQÔQˆà×Ò�˜f™œ¨¨Q xÑ0Ô0Ð0Ø×Ò�˜f™œ¨¨Q xÑ0Ô0Ð0Ø×Ò�-­¨vÑ6Ô6Ð6Ð6Ð6r)   c                 óÐ   — t          d¦  «        5 }|                      |¦  «         |                      t          | j        ¦  «        d¦  «         ddd¦  «         dS # 1 swxY w Y   dS )z�
        L{eventsFromJSONLogFile} reads events from a file and automatically
        detects use of C{"\x1e"} as the record separator.
        ú{"x": 1}
{"y": 2}
r   N©r   rÊ   r%   ru   r¼   ©r.   rŠ   s     r'   Ú&test_readEventsAutoWithRecordSeparatorz9LogFileReaderTests.test_readEventsAutoWithRecordSeparator>  s©   € õ
 Ð7Ñ8Ô8ð 	7¸JØ×Ò˜ZÑ(Ô(Ð(Ø×Ò�S Ô!1Ñ2Ô2°AÑ6Ô6Ð6ð	7ð 	7ð 	7ñ 	7ô 	7ð 	7ð 	7ð 	7ð 	7ð 	7ð 	7ð 	7øøøð 	7ð 	7ð 	7ð 	7ð 	7ð 	7ó   �>AÁAÁ"Ac                 óÐ   — t          d¦  «        5 }|                      |¦  «         |                      t          | j        ¦  «        d¦  «         ddd¦  «         dS # 1 swxY w Y   dS )z‹
        L{eventsFromJSONLogFile} reads events from a file and automatically
        detects use of C{""} as the record separator.
        z{"x": 1}
{"y": 2}
r   NrÍ   rÎ   s     r'   Ú'test_readEventsAutoEmptyRecordSeparatorz:LogFileReaderTests.test_readEventsAutoEmptyRecordSeparatorG  s©   € õ
 Ð/Ñ0Ô0ð 	7°JØ×Ò˜ZÑ(Ô(Ð(Ø×Ò�S Ô!1Ñ2Ô2°AÑ6Ô6Ð6ð	7ð 	7ð 	7ñ 	7ô 	7ð 	7ð 	7ð 	7ð 	7ð 	7ð 	7ð 	7øøøð 	7ð 	7ð 	7ð 	7ð 	7ð 	7rÐ   c                 óÔ   — t          d¦  «        5 }|                      |d¬¦  «         |                      t          | j        ¦  «        d¦  «         ddd¦  «         dS # 1 swxY w Y   dS )z{
        L{eventsFromJSONLogFile} reads events from a file and is told to use
        a specific record separator.
        z{"x": 1}
{"y": 2}
úr™   r   NrÍ   rÎ   s     r'   Ú&test_readEventsExplicitRecordSeparatorz9LogFileReaderTests.test_readEventsExplicitRecordSeparatorP  s®   € õ Ð7Ñ8Ô8ð 	7¸JØ×Ò˜Z¸ÐÑ@Ô@Ð@Ø×Ò�S Ô!1Ñ2Ô2°AÑ6Ô6Ð6ð	7ð 	7ð 	7ñ 	7ô 	7ð 	7ð 	7ð 	7ð 	7ð 	7ð 	7ð 	7øøøð 	7ð 	7ð 	7ð 	7ð 	7ð 	7ó   �A AÁA!Á$A!c                 óÔ   — t          d¦  «        5 }|                      |d¬¦  «         |                      t          | j        ¦  «        d¦  «         ddd¦  «         dS # 1 swxY w Y   dS )zM
        L{eventsFromJSONLogFile} handles buffering a partial event.
        rÌ   r6   ©rÄ   r   NrÍ   rÎ   s     r'   Útest_readEventsPartialBufferz/LogFileReaderTests.test_readEventsPartialBufferZ  s®   € õ Ð7Ñ8Ô8ð 	7¸Jà×Ò˜Z°AÐÑ6Ô6Ð6Ø×Ò�S Ô!1Ñ2Ô2°AÑ6Ô6Ð6ð	7ð 	7ð 	7ñ 	7ô 	7ð 	7ð 	7ð 	7ð 	7ð 	7ð 	7ð 	7øøøð 	7ð 	7ð 	7ð 	7ð 	7ð 	7rÖ   c                 ó  — t          d¦  «        5 }t          t          |¦  «        ¦  «        }|                      t	          |¦  «        ddi¦  «         |                      t          t          |¦  «         |                      t          | j        ¦  «        d¦  «         |                      | j        d         d         d¦  «         |                      | j        d         d         d	¦  «         d
d
d
¦  «         d
S # 1 swxY w Y   d
S )zF
        If the JSON text for a record is truncated, skip it.
        z{"x": 1{"y": 2}
rÆ   r   r6   r   r_   z0Unable to read truncated JSON record: {record!r}r¹   s   {"x": 1N©	r   rÇ   r   r%   rÈ   rj   rÉ   ru   r¼   ©r.   rŠ   ry   s      r'   Útest_readTruncatedz%LogFileReaderTests.test_readTruncatedc  sH  € õ Ð4Ñ5Ô5ð 	H¸ÝÕ/°
Ñ;Ô;Ñ<Ô<ˆFà×Ò�T &™\œ\¨C°¨8Ñ4Ô4Ð4Ø×Ò�m­T°6Ñ:Ô:Ð:ð ×Ò�S Ô!1Ñ2Ô2°AÑ6Ô6Ð6Ø×ÒØÔ  Ô# LÔ1ØBñô ð ð ×Ò˜TÔ-¨aÔ0°Ô:¸JÑGÔGÐGð	Hð 	Hð 	Hñ 	Hô 	Hð 	Hð 	Hð 	Hð 	Hð 	Hð 	Hð 	Høøøð 	Hð 	Hð 	Hð 	Hð 	Hð 	Hó   �CC6Ã6C:Ã=C:c                 ój  — t          d¦  «        5 }t          t          |¦  «        ¦  «        }|                      t	          |¦  «        ddi¦  «         |                      t          t          |¦  «         |                      t          | j        ¦  «        d¦  «         ddd¦  «         dS # 1 swxY w Y   dS )zc
        If the file being read from vends L{str}, strings decode from JSON
        as-is.
        u   {"currency": "â‚¬"}
Úcurrencyõ   â‚¬r   NrÛ   rÜ   s      r'   Útest_readUnicodez#LogFileReaderTests.test_readUnicodeu  sä   € õ Ð4Ñ5Ô5ð 	7¸ÝÕ/°
Ñ;Ô;Ñ<Ô<ˆFà×Ò�T &™\œ\¨J¸Ð+AÑBÔBÐBØ×Ò�m­T°6Ñ:Ô:Ð:Ø×Ò�S Ô!1Ñ2Ô2°AÑ6Ô6Ð6ð	7ð 	7ð 	7ñ 	7ô 	7ð 	7ð 	7ð 	7ð 	7ð 	7ð 	7ð 	7øøøð 	7ð 	7ð 	7ð 	7ð 	7ð 	7ó   �BB(Â(B,Â/B,c                 ój  — t          d¦  «        5 }t          t          |¦  «        ¦  «        }|                      t	          |¦  «        ddi¦  «         |                      t          t          |¦  «         |                      t          | j        ¦  «        d¦  «         ddd¦  «         dS # 1 swxY w Y   dS )zh
        If the file being read from vends L{bytes}, strings decode from JSON as
        UTF-8.
        s   {"currency": "â‚¬"}
rà   rá   r   N©	r   rÇ   r   r%   rÈ   rj   rÉ   ru   r¼   rÜ   s      r'   Útest_readUTF8Bytesz%LogFileReaderTests.test_readUTF8Bytes‚  sæ   € õ Ð:Ñ;Ô;ð 	7¸zÝÕ/°
Ñ;Ô;Ñ<Ô<ˆFð ×Ò�T &™\œ\¨J¸Ð+AÑBÔBÐBØ×Ò�m­T°6Ñ:Ô:Ð:Ø×Ò�S Ô!1Ñ2Ô2°AÑ6Ô6Ð6ð	7ð 	7ð 	7ñ 	7ô 	7ð 	7ð 	7ð 	7ð 	7ð 	7ð 	7ð 	7øøøð 	7ð 	7ð 	7ð 	7ð 	7ð 	7rã   c                 ón  — t          d¦  «        5 }t          t          |d¬¦  «        ¦  «        }|                      t	          |¦  «        ddi¦  «         |                      t          t          |¦  «         |                      t          | j        ¦  «        d¦  «         ddd¦  «         dS # 1 swxY w Y   dS )zä
        If the JSON text for a record is truncated in the middle of a two-byte
        Unicode codepoint, we don't want to see a codec exception and the
        stream is read properly when the additional data arrives.
        s   {"x": "â‚¬"}
é   rØ   r‘   rá   r   Nrå   rÜ   s      r'   Útest_readTruncatedUTF8Bytesz.LogFileReaderTests.test_readTruncatedUTF8Bytes�  sè   € õ Ð3Ñ4Ô4ð 	7¸
ÝÕ/°
ÀqÐIÑIÔIÑJÔJˆFà×Ò�T &™\œ\¨C°¨?Ñ;Ô;Ð;Ø×Ò�m­T°6Ñ:Ô:Ð:Ø×Ò�S Ô!1Ñ2Ô2°AÑ6Ô6Ð6ð	7ð 	7ð 	7ñ 	7ô 	7ð 	7ð 	7ð 	7ð 	7ð 	7ð 	7ð 	7øøøð 	7ð 	7ð 	7ð 	7ð 	7ð 	7s   �BB*Â*B.Â1B.c                 ó  — t          d¦  «        5 }t          t          |¦  «        ¦  «        }|                      t	          |¦  «        ddi¦  «         |                      t          t          |¦  «         |                      t          | j        ¦  «        d¦  «         |                      | j        d         d         d¦  «         |                      | j        d         d         d	¦  «         d
d
d
¦  «         d
S # 1 swxY w Y   d
S )zh
        If the JSON text for a record contains invalid UTF-8 text, ignore that
        record.
        s   {"x": "â¬"}
{"y": 2}
rÆ   r   r6   r   r_   z2Unable to decode UTF-8 for JSON record: {record!r}r¹   s   {"x": "â¬"}
Nrå   rÜ   s      r'   Útest_readInvalidUTF8Bytesz,LogFileReaderTests.test_readInvalidUTF8BytesŸ  sI  € õ ÐAÑBÔBð 	TÀjÝÕ/°
Ñ;Ô;Ñ<Ô<ˆFà×Ò�T &™\œ\¨C°¨8Ñ4Ô4Ð4Ø×Ò�m­T°6Ñ:Ô:Ð:ð ×Ò�S Ô!1Ñ2Ô2°AÑ6Ô6Ð6Ø×ÒØÔ  Ô# LÔ1ØDñô ð ð ×Ò˜TÔ-¨aÔ0°Ô:Ð<RÑSÔSÐSð	Tð 	Tð 	Tñ 	Tô 	Tð 	Tð 	Tð 	Tð 	Tð 	Tð 	Tð 	Tøøøð 	Tð 	Tð 	Tð 	Tð 	Tð 	TrÞ   c                 ó  — t          d¦  «        5 }t          t          |¦  «        ¦  «        }|                      t	          |¦  «        ddi¦  «         |                      t          t          |¦  «         |                      t          | j        ¦  «        d¦  «         |                      | j        d         d         d¦  «         |                      | j        d         d         d	¦  «         d
d
d
¦  «         d
S # 1 swxY w Y   d
S )zD
        If the JSON text for a record is invalid, skip it.
        z{"x": }
{"y": 2}
rÆ   r   r6   r   r_   ú&Unable to read JSON record: {record!r}r¹   s   {"x": }
NrÛ   rÜ   s      r'   Útest_readInvalidJSONz'LogFileReaderTests.test_readInvalidJSON³  sH  € õ Ð6Ñ7Ô7ð 	J¸:ÝÕ/°
Ñ;Ô;Ñ<Ô<ˆFà×Ò�T &™\œ\¨C°¨8Ñ4Ô4Ð4Ø×Ò�m­T°6Ñ:Ô:Ð:ð ×Ò�S Ô!1Ñ2Ô2°AÑ6Ô6Ð6Ø×ÒØÔ  Ô# LÔ1Ø8ñô ð ð ×Ò˜TÔ-¨aÔ0°Ô:¸LÑIÔIÐIð	Jð 	Jð 	Jñ 	Jô 	Jð 	Jð 	Jð 	Jð 	Jð 	Jð 	Jð 	Jøøøð 	Jð 	Jð 	Jð 	Jð 	Jð 	JrÞ   c                 ó¢  — t          d¦  «        5 }t          |¦  «        }|                      t          t          |¦  «         |                      t          | j        ¦  «        d¦  «         |                      | j        d         d         d¦  «         |                      | j        d         d         d¦  «         ddd¦  «         dS # 1 swxY w Y   dS )	zI
        Multiple events without a record separator are skipped.
        z{"x": 1}
{"y": 2}
r6   r   r_   rí   r¹   s   {"x": 1}
{"y": 2}
N)r   r   rj   rÉ   rÈ   r%   ru   r¼   rÜ   s      r'   Útest_readUnseparatedz'LogFileReaderTests.test_readUnseparatedÅ  s   € õ Ð3Ñ4Ô4ð 	U¸
Ý*¨:Ñ6Ô6ˆFà×Ò�m­T°6Ñ:Ô:Ð:ð ×Ò�S Ô!1Ñ2Ô2°AÑ6Ô6Ð6Ø×ÒØÔ  Ô# LÔ1Ø8ñô ð ð ×Ò˜TÔ-¨aÔ0°Ô:Ð<SÑTÔTÐTð	Uð 	Uð 	Uñ 	Uô 	Uð 	Uð 	Uð 	Uð 	Uð 	Uð 	Uð 	Uøøøð 	Uð 	Uð 	Uð 	Uð 	Uð 	Us   �B'CÃCÃCc                 óˆ  — t          d¬¦  «        }t          ¦   «         5 }t          |¦  «        } ||¦  «         |                     d¦  «         t	          |¦  «        }|                      t          |¦  «        |f¦  «         |                      t          | j        ¦  «        d¦  «         ddd¦  «         dS # 1 swxY w Y   dS )z¡
        Data written by a L{FileLogObserver} returned by L{jsonFileLogObserver}
        and read by L{eventsFromJSONLogFile} is reconstructed properly.
        r6   r�   r   N)	ri   r   r   Úseekr   r%   Útupleru   r¼   )r.   r,   rŠ   rp   ry   s        r'   Útest_roundTripz!LogFileReaderTests.test_roundTripÖ  sô   € õ
 �q�	‘	”	ˆå‰ZŒZð 	7˜:Ý*¨:Ñ6Ô6ˆHØˆH�U‰OŒOˆOà�OŠO˜AÑÔÐÝ*¨:Ñ6Ô6ˆFà×Ò�U 6™]œ]¨U¨HÑ5Ô5Ð5Ø×Ò�S Ô!1Ñ2Ô2°AÑ6Ô6Ð6ð	7ð 	7ð 	7ñ 	7ô 	7ð 	7ð 	7ð 	7ð 	7ð 	7ð 	7ð 	7øøøð 	7ð 	7ð 	7ð 	7ð 	7ð 	7s   ŸBB7Â7B;Â>B;rg   )NrÂ   )rY   rZ   r[   r…   r¾   rÁ   r   r   r   r$   ÚintrÊ   rÏ   rÒ   rÕ   rÙ   rÝ   râ   ræ   ré   rë   rî   rð   rô   rW   r)   r'   rµ   rµ     s•  € € € € € ðð ð
1ð 
1ð 
1ð 
1ð<ð <ð <ð <ð *.Øð	7ð 7à�3”ð7ð " #œð7ð ð	7ð
 
ð7ð 7ð 7ð 7ð*7ð 7ð 7ð 7ð7ð 7ð 7ð 7ð7ð 7ð 7ð 7ð7ð 7ð 7ð 7ðHð Hð Hð Hð$7ð 7ð 7ð 7ð7ð 7ð 7ð 7ð7ð 7ð 7ð 7ðTð Tð Tð Tð(Jð Jð Jð Jð$Uð Uð Uð Uð"7ð 7ð 7ð 7ð 7ð 7r)   rµ   N)0r…   r­   r   r   Útypingr   r   r   r   r	   r
   Úzope.interfacer   Úzope.interface.exceptionsr   Úzope.interface.verifyr   Útwisted.python.failurer   Útwisted.trial.unittestr   Ú_flattenr   Ú_formatr   Ú_globalr   Ú_interfacesr   r   Ú_jsonr   r   r   r   r   rº   Ú_levelsr   Ú_loggerr   Ú	_observerr   r$   r(   r+   r‡   rµ   rW   r)   r'   ú<module>r     sL  ððð ð !Ð  Ð  Ð  Ð  Ð  Ð  Ð  Ø :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :à &Ð &Ð &Ð &Ð &Ð &Ø @Ð @Ð @Ð @Ð @Ð @Ø .Ð .Ð .Ð .Ð .Ð .à *Ð *Ð *Ð *Ð *Ð *Ø +Ð +Ð +Ð +Ð +Ð +Ø #Ð #Ð #Ð #Ð #Ð #Ø !Ð !Ð !Ð !Ð !Ð !Ø (Ð (Ð (Ð (Ð (Ð (Ø 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0ðð ð ð ð ð ð ð ð ð ð ð ð ð ð Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø $Ð $Ð $Ð $Ð $Ð $ð (ð °sð ¸sð ð ð ð ð O<ð O<ð O<ð O<ð O<�Hñ O<ô O<ð O<ðdO"ð O"ð O"ð O"ð O"˜8ñ O"ô O"ð O"ðdP7ð P7ð P7ð P7ð P7˜ñ P7ô P7ð P7ð P7ð P7r)   