§
    Étºf±  ã                   óø   — d Z ddlmZ ddlmZ ddlmZ ddlmZm	Z	m
Z
  G d„ dej        ¦  «        Z G d„ d	ej        e	j        ¦  «        Z G d
„ dej        ¦  «        Z G d„ de¦  «        Z G d„ de¦  «        ZdS )z,
Tests for L{twisted.words.xish.xmlstream}.
é    )Úprotocol)Úfailure)Úunittest)ÚdomishÚutilityÚ	xmlstreamc                   ó2   — e Zd Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ ZdS )ÚXmlStreamTestsc                 ó    — d| _         g | _        t          j        ¦   «         | _        | | j        _        | j        j        | j        j        _        d S )Nz	no reason)ÚconnectionLostMsgÚoutlistr   Ú	XmlStreamÚ	transportÚappendÚwrite©Úselfs    ú`/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/words/test/test_xmlstream.pyÚsetUpzXmlStreamTests.setUp   sC   € Ø!,ˆÔØˆŒÝ"Ô,Ñ.Ô.ˆŒØ#'ˆŒÔ Ø)-¬Ô)<ˆŒÔ Ô&Ð&Ð&ó    c                 ó‚   — | j                              t          j        t	          | j        ¦  «        ¦  «        ¦  «         dS )zA
        Stub loseConnection because we are a transport.
        N)r   ÚconnectionLostr   ÚFailureÚ	Exceptionr   r   s    r   ÚloseConnectionzXmlStreamTests.loseConnection   s@   € ð 	Œ×%Ò%ÝŒO�I dÔ&<Ñ=Ô=Ñ>Ô>ñ	
ô 	
ð 	
ð 	
ð 	
r   c                 ó®   — | j                              ¦   «          | j                              d¦  «         |                      | j        d         d¦  «         dS )zq
        Calling L{xmlstream.XmlStream.send} results in the data being written
        to the transport.
        s   <root>r   N)r   ÚconnectionMadeÚsendÚassertEqualr   r   s    r   Ú	test_sendzXmlStreamTests.test_send   sP   € ð
 	Œ×%Ò%Ñ'Ô'Ð'ØŒ×Ò˜IÑ&Ô&Ð&Ø×Ò˜œ aœ¨)Ñ4Ô4Ð4Ð4Ð4r   c                 ó  ‡— g Šˆfd„}| j                              t           j        |¦  «         | j                              ¦   «          | j                              d¦  «         |                      dt          ‰¦  «        ¦  «         dS )zU
        Receiving the starttag of the root element results in stream start.
        c                 ó2   •— ‰                      d ¦  «         d S ©N©r   )ÚrootelemÚstreamStarteds    €r   ÚstreamStartEventz9XmlStreamTests.test_receiveRoot.<locals>.streamStartEvent.   s   ø€ Ø× Ò  Ñ&Ô&Ð&Ð&Ð&r   ú<root>é   N)r   ÚaddObserverÚSTREAM_START_EVENTr   ÚdataReceivedr   Úlen)r   r'   r&   s     @r   Útest_receiveRootzXmlStreamTests.test_receiveRoot(   s�   ø€ ð ˆð	'ð 	'ð 	'ð 	'ð 	'ð 	Œ×"Ò"¥9Ô#?ÐAQÑRÔRÐRØŒ×%Ò%Ñ'Ô'Ð'ØŒ×#Ò# HÑ-Ô-Ð-Ø×Ò˜�C Ñ.Ô.Ñ/Ô/Ð/Ð/Ð/r   c                 óÜ  ‡‡— g Šg Šˆfd„}ˆfd„}| j                              t           j        |¦  «         | j                              t           j        |¦  «         | j                              ¦   «          | j                              d¦  «         |                      dt          ‰¦  «        ¦  «         |                      dt          ‰¦  «        ¦  «         | j                              d¦  «         |                      dt          ‰¦  «        ¦  «         |                      ‰d          	                    t          j        ¦  «        ¦  «         |                      dt          ‰¦  «        ¦  «         dS )zN
        Receiving malformed XML results in an L{STREAM_ERROR_EVENT}.
        c                 ó2   •— ‰                      | ¦  «         d S r#   r$   )ÚreasonÚstreamErrors    €r   ÚstreamErrorEventz;XmlStreamTests.test_receiveBadXML.<locals>.streamErrorEvent=   s   ø€ Ø×Ò˜vÑ&Ô&Ð&Ð&Ð&r   c                 ó2   •— ‰                      d ¦  «         d S r#   r$   )Ú_Ú	streamEnds    €r   ÚstreamEndEventz9XmlStreamTests.test_receiveBadXML.<locals>.streamEndEvent@   s   ø€ Ø×Ò˜TÑ"Ô"Ð"Ð"Ð"r   r(   r   z<child><unclosed></child>r)   N)r   r*   ÚSTREAM_ERROR_EVENTÚSTREAM_END_EVENTr   r,   r   r-   Ú
assertTrueÚcheckr   ÚParserError)r   r3   r7   r6   r2   s      @@r   Útest_receiveBadXMLz!XmlStreamTests.test_receiveBadXML6   s]  øø€ ð ˆØˆ	ð	'ð 	'ð 	'ð 	'ð 	'ð	#ð 	#ð 	#ð 	#ð 	#ð 	Œ×"Ò"¥9Ô#?ÐAQÑRÔRÐRØŒ×"Ò"¥9Ô#=¸~ÑNÔNÐNØŒ×%Ò%Ñ'Ô'Ð'àŒ×#Ò# HÑ-Ô-Ð-Ø×Ò˜�C Ñ,Ô,Ñ-Ô-Ð-Ø×Ò˜�C 	™NœNÑ+Ô+Ð+àŒ×#Ò#Ð$?Ñ@Ô@Ð@Ø×Ò˜�C Ñ,Ô,Ñ-Ô-Ð-Ø�Š˜ Aœ×,Ò,­VÔ-?Ñ@Ô@ÑAÔAÐAØ×Ò˜�C 	™NœNÑ+Ô+Ð+Ð+Ð+r   c                 ó²  ‡— g Šˆfd„}| j                              t           j        |¦  «         | j                              ¦   «          |                      ¦   «          |                      dt          ‰¦  «        ¦  «         |                      ‰d         t          j	        ¦  «         |                      ‰d          
                    ¦   «         | j        ¦  «         dS )z@
        Ending the stream fires a L{STREAM_END_EVENT}.
        c                 ó2   •— ‰                      | ¦  «         d S r#   r$   )r1   r6   s    €r   r7   z5XmlStreamTests.test_streamEnd.<locals>.streamEndEventV   s   ø€ Ø×Ò˜VÑ$Ô$Ð$Ð$Ð$r   r)   r   N)r   r*   r9   r   r   r   r-   ÚassertIsInstancer   r   ÚgetErrorMessager   )r   r7   r6   s     @r   Útest_streamEndzXmlStreamTests.test_streamEndP   sÍ   ø€ ð ˆ	ð	%ð 	%ð 	%ð 	%ð 	%ð 	Œ×"Ò"¥9Ô#=¸~ÑNÔNÐNØŒ×%Ò%Ñ'Ô'Ð'Ø×ÒÑÔÐØ×Ò˜�C 	™NœNÑ+Ô+Ð+Ø×Ò˜i¨œl­G¬OÑ<Ô<Ð<Ø×Ò˜ 1œ×5Ò5Ñ7Ô7¸Ô9OÑPÔPÐPÐPÐPr   N)	Ú__name__Ú
__module__Ú__qualname__r   r   r    r.   r=   rB   © r   r   r
   r
      ss   € € € € € ð=ð =ð =ð
ð 
ð 
ð5ð 5ð 5ð0ð 0ð 0ð,ð ,ð ,ð4Qð Qð Qð Qð Qr   r
   c                   ó   — e Zd ZdZd„ ZdS )ÚDummyProtocolzÝ
    I am a protocol with an event dispatcher without further processing.

    This protocol is only used for testing XmlStreamFactoryMixin to make
    sure the bootstrap observers are added to the protocol instance.
    c                 ón   — || _         || _        g | _        t          j                             | ¦  «         d S r#   )ÚargsÚkwargsÚ	observersr   ÚEventDispatcherÚ__init__)r   rJ   rK   s      r   rN   zDummyProtocol.__init__i   s4   € ØˆŒ	ØˆŒØˆŒåÔ×(Ò(¨Ñ.Ô.Ð.Ð.Ð.r   N)rC   rD   rE   Ú__doc__rN   rF   r   r   rH   rH   a   s-   € € € € € ðð ð/ð /ð /ð /ð /r   rH   c                   ó$   — e Zd ZdZd„ Zd„ Zd„ ZdS )ÚBootstrapMixinTestszq
    Tests for L{xmlstream.BootstrapMixin}.

    @ivar factory: Instance of the factory or mixin under test.
    c                 ó6   — t          j        ¦   «         | _        d S r#   )r   ÚBootstrapMixinÚfactoryr   s    r   r   zBootstrapMixinTests.setUpx   s   € Ý Ô/Ñ1Ô1ˆŒˆˆr   c                 ó  ‡— g Šˆfd„}t          ¦   «         }| j                             d|¦  «         | j                             |¦  «         |                     dd¦  «         |                      dt          ‰¦  «        ¦  «         dS )zL
        Dispatching an event fires registered bootstrap observers.
        c                 ó2   •— ‰                      | ¦  «         d S r#   r$   ©ÚdataÚcalleds    €r   Úcbz6BootstrapMixinTests.test_installBootstraps.<locals>.cb�   ó   ø€ Ø�MŠM˜$ÑÔÐÐÐr   ú//event/myeventNr)   )rH   rT   ÚaddBootstrapÚinstallBootstrapsÚdispatchr   r-   ©r   rZ   Ú
dispatcherrY   s      @r   Útest_installBootstrapsz*BootstrapMixinTests.test_installBootstraps{   s–   ø€ ð ˆð	 ð 	 ð 	 ð 	 ð 	 õ #‘_”_ˆ
ØŒ×!Ò!Ð"3°RÑ8Ô8Ð8ØŒ×&Ò& zÑ2Ô2Ð2à×Ò˜DÐ"3Ñ4Ô4Ð4Ø×Ò˜�C ™KœKÑ(Ô(Ð(Ð(Ð(r   c                 ó(  ‡— g Šˆfd„}| j                              d|¦  «         | j                              d|¦  «         t          ¦   «         }| j                              |¦  «         |                     dd¦  «         |                      ‰¦  «         dS )zI
        Test addition and removal of a bootstrap event handler.
        c                 ó2   •— ‰                      | ¦  «         d S r#   r$   rW   s    €r   rZ   z:BootstrapMixinTests.test_addAndRemoveBootstrap.<locals>.cb’   r[   r   r\   N)rT   r]   ÚremoveBootstraprH   r^   r_   ÚassertFalser`   s      @r   Útest_addAndRemoveBootstrapz.BootstrapMixinTests.test_addAndRemoveBootstrap‹   s§   ø€ ð
 ˆð	 ð 	 ð 	 ð 	 ð 	 ð 	Œ×!Ò!Ð"3°RÑ8Ô8Ð8ØŒ×$Ò$Ð%6¸Ñ;Ô;Ð;å"‘_”_ˆ
ØŒ×&Ò& zÑ2Ô2Ð2à×Ò˜DÐ"3Ñ4Ô4Ð4Ø×Ò˜Ñ Ô Ð Ð Ð r   N)rC   rD   rE   rO   r   rb   rg   rF   r   r   rQ   rQ   q   sK   € € € € € ðð ð2ð 2ð 2ð)ð )ð )ð !ð !ð !ð !ð !r   rQ   c                   ó$   — e Zd ZdZd„ Zd„ Zd„ ZdS )Ú!GenericXmlStreamFactoryTestsMixinz3
    Generic tests for L{XmlStream} factories.
    c                 ó6   — t          j        ¦   «         | _        d S r#   )r   ÚXmlStreamFactoryrT   r   s    r   r   z'GenericXmlStreamFactoryTestsMixin.setUp¤   s   € Ý Ô1Ñ3Ô3ˆŒˆˆr   c                 óò   ‡— g Šˆfd„}| j                              d|¦  «         | j                              d¦  «        }|                     dd¦  «         |                      dt          ‰¦  «        ¦  «         dS )zY
        The protocol factory installs bootstrap event handlers on the protocol.
        c                 ó2   •— ‰                      | ¦  «         d S r#   r$   rW   s    €r   rZ   zRGenericXmlStreamFactoryTestsMixin.test_buildProtocolInstallsBootstraps.<locals>.cb­   r[   r   r\   Nr)   )rT   r]   ÚbuildProtocolr_   r   r-   )r   rZ   ÚxsrY   s      @r   Ú$test_buildProtocolInstallsBootstrapszFGenericXmlStreamFactoryTestsMixin.test_buildProtocolInstallsBootstraps§   sŠ   ø€ ð ˆð	 ð 	 ð 	 ð 	 ð 	 ð 	Œ×!Ò!Ð"3°RÑ8Ô8Ð8àŒ\×'Ò'¨Ñ-Ô-ˆØ
�Š�DÐ+Ñ,Ô,Ð,à×Ò˜�C ™KœKÑ(Ô(Ð(Ð(Ð(r   c                 óz   — | j                              d¦  «        }|                      | j         |j         ¦  «         dS )z@
        The protocol factory is saved in the protocol.
        N)rT   rn   ÚassertIdentical©r   ro   s     r   Útest_buildProtocolStoresFactoryzAGenericXmlStreamFactoryTestsMixin.test_buildProtocolStoresFactory·   s9   € ð Œ\×'Ò'¨Ñ-Ô-ˆØ×Ò˜Tœ\¨2¬:Ñ6Ô6Ð6Ð6Ð6r   N)rC   rD   rE   rO   r   rp   rt   rF   r   r   ri   ri   Ÿ   sK   € € € € € ðð ð4ð 4ð 4ð)ð )ð )ð 7ð 7ð 7ð 7ð 7r   ri   c                   ó   — e Zd ZdZd„ Zd„ ZdS )ÚXmlStreamFactoryMixinTestsz7
    Tests for L{xmlstream.XmlStreamFactoryMixin}.
    c                 ó^   — t          j        d d ¬¦  «        | _        t          | j        _        d S )N)Útest)r   ÚXmlStreamFactoryMixinrT   rH   r   r   s    r   r   z XmlStreamFactoryMixinTests.setUpÄ   s)   € Ý Ô6°tÀ$ÐGÑGÔGˆŒÝ -ˆŒÔÐÐr   c                 óª   — | j                              d¦  «        }|                      d|j        ¦  «         |                      ddi|j        ¦  «         dS )zb
        Arguments passed to the factory are passed to protocol on
        instantiation.
        Nr#   rx   )rT   rn   r   rJ   rK   rs   s     r   Ú"test_buildProtocolFactoryArgumentsz=XmlStreamFactoryMixinTests.test_buildProtocolFactoryArgumentsÈ   sS   € ð
 Œ\×'Ò'¨Ñ-Ô-ˆà×Ò˜ "¤'Ñ*Ô*Ð*Ø×Ò˜& $˜¨¬Ñ3Ô3Ð3Ð3Ð3r   N)rC   rD   rE   rO   r   r{   rF   r   r   rv   rv   ¿   s<   € € € € € ðð ð.ð .ð .ð4ð 4ð 4ð 4ð 4r   rv   N)rO   Útwisted.internetr   Útwisted.pythonr   Útwisted.trialr   Útwisted.words.xishr   r   r   ÚTestCaser
   ÚProtocolrM   rH   rQ   ri   rv   rF   r   r   ú<module>r‚      sd  ððð ð
 &Ð %Ð %Ð %Ð %Ð %Ø "Ð "Ð "Ð "Ð "Ð "Ø "Ð "Ð "Ð "Ð "Ð "Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9ðOQð OQð OQð OQð OQ�XÔ&ñ OQô OQð OQðd/ð /ð /ð /ð /�HÔ% wÔ'>ñ /ô /ð /ð +!ð +!ð +!ð +!ð +!˜(Ô+ñ +!ô +!ð +!ð\7ð 7ð 7ð 7ð 7Ð(;ñ 7ô 7ð 7ð@4ð 4ð 4ð 4ð 4Ð!Bñ 4ô 4ð 4ð 4ð 4r   