ó
    ×›‘h×  ã                   ób   • S r SSKrSSKJrJr  SSKJr  SSKJr   " S S5      r	 " S S	\5      r
g)
z&
Test code for basic Factory classes.
é    N)ÚProtocolÚReconnectingClientFactory)ÚClock)ÚTestCasec                   ó$   • \ rS rSrSrS rS rSrg)ÚFakeConnectoré   zH
A fake connector class, to be used to mock connections failed or lost.
c                 ó   • g ©N© ©Úselfs    Ú_C:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/test/test_factories.pyÚstopConnectingÚFakeConnector.stopConnecting   ó   € Øó    c                 ó   • g r   r   r   s    r   ÚconnectÚFakeConnector.connect   r   r   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   Ú__static_attributes__r   r   r   r   r      s   † ñòõr   r   c                   ó<   • \ rS rSrSrS rS rS rS rS r	S r
S	rg
)ÚReconnectingFactoryTestsé   z)
Tests for L{ReconnectingClientFactory}.
c                 óè   •  " S S5      n[        5       n[        Ul        UR                  S5        UR	                  5         UR                  U" 5       S5        U R                  UR                  5        g)z¢
If a L{ReconnectingClientFactory} has C{stopTrying} called while it is
connected, it does not subsequently attempt to reconnect if the
connection is later lost.
c                   ó    • \ rS rSrS rS rSrg)ÚQReconnectingFactoryTests.test_stopTryingWhenConnected.<locals>.NoConnectConnectoré(   c                 ó   • [        S5      e)Nz%Shouldn't be called, we're connected.©ÚRuntimeErrorr   s    r   r   Ú`ReconnectingFactoryTests.test_stopTryingWhenConnected.<locals>.NoConnectConnector.stopConnecting)   s   € Ü"Ð#JÓKÐKr   c                 ó   • [        S5      e)NzShouldn't be reconnecting.r%   r   s    r   r   ÚYReconnectingFactoryTests.test_stopTryingWhenConnected.<locals>.NoConnectConnector.connect,   s   € Ü"Ð#?Ó@Ð@r   r   N)r   r   r   r   r   r   r   r   r   r   ÚNoConnectConnectorr"   (   s   † òLõAr   r*   N)r   r   ÚprotocolÚbuildProtocolÚ
stopTryingÚclientConnectionLostÚassertFalseÚcontinueTrying)r   r*   Úcs      r   Útest_stopTryingWhenConnectedÚ5ReconnectingFactoryTests.test_stopTryingWhenConnected!   s\   € ÷	Añ 	Aô &Ó'ˆÜˆŒ
à	�‰˜Ôà	�‰ŒØ	×ÑÑ1Ó3°TÔ:Ø×Ñ˜×)Ñ)Õ*r   c                 ó0  ^•  " U4S jS[         5      n[        5       m[        5       Tl        U" 5       Tl        TR                  5         U R                  TR                  R                  5        U R                  TR                  R                  5       5        g)zg
Calling stopTrying on a L{ReconnectingClientFactory} doesn't attempt a
retry on any active connector.
c                   ó,   >• \ rS rSrSrU 4S jrS rSrg)Ú[ReconnectingFactoryTests.test_stopTryingDoesNotReconnect.<locals>.FactoryAwareFakeConnectoré>   Fc                 ó*   >• TR                  U S5        g)z`
Behave as though an ongoing connection attempt has now
failed, and notify the factory of this.
N)ÚclientConnectionFailed)r   Úfs    €r   r   ÚjReconnectingFactoryTests.test_stopTryingDoesNotReconnect.<locals>.FactoryAwareFakeConnector.stopConnectingA   s   ø€ ð
 ×(Ñ(¨¨tÕ4r   c                 ó   • SU l         g)zL
Record an attempt to reconnect, since this is what we
are trying to avoid.
TN©ÚattemptedRetryr   s    r   r   ÚcReconnectingFactoryTests.test_stopTryingDoesNotReconnect.<locals>.FactoryAwareFakeConnector.connectH   s   € ð
 '+�Õ#r   r=   N)r   r   r   r   r>   r   r   r   )r:   s   €r   ÚFactoryAwareFakeConnectorr6   >   s   ø† Ø"ˆNõ5õ+r   r@   N)	r   r   r   ÚclockÚ	connectorr-   r/   r>   ÚgetDelayedCalls)r   r@   r:   s     @r   Útest_stopTryingDoesNotReconnectÚ8ReconnectingFactoryTests.test_stopTryingDoesNotReconnect8   sl   ø€ ÷	+¬ô 	+ô" &Ó'ˆÜ“'ˆŒñ 0Ó1ˆŒØ	�‰Œð 	×Ñ˜Ÿ™×3Ñ3Ô4Ø×Ñ˜Ÿ™×0Ñ0Ó2Õ3r   c                 ó¸   • [        5       n[        R                  " [        R                  " U5      5      nU R	                  UR
                  UR
                  5        g)z�
A L{ReconnectingClientFactory} which hasn't been used for anything
can be pickled and unpickled and end up with the same state.
N)r   ÚpickleÚloadsÚdumpsÚassertEqualÚ__dict__)r   ÚoriginalÚreconstituteds      r   Útest_serializeUnusedÚ-ReconnectingFactoryTests.test_serializeUnused[   s?   € ô
 -Ó.ˆÜŸš¤V§\¢\°(Ó%;Ó<ˆØ×Ñ˜×*Ñ*¨M×,BÑ,BÕCr   c                 óÂ   • [        5       n[        5       nXl        [        R                  " [        R
                  " U5      5      nU R                  UR                  5        g)zŠ
The clock attribute of L{ReconnectingClientFactory} is not serialized,
and the restored value sets it to the default value, the reactor.
N)r   r   rA   rG   rH   rI   ÚassertIsNone)r   rA   rL   rM   s       r   Útest_serializeWithClockÚ0ReconnectingFactoryTests.test_serializeWithClockd   sC   € ô
 “ˆÜ,Ó.ˆØŒÜŸš¤V§\¢\°(Ó%;Ó<ˆØ×Ñ˜-×-Ñ-Õ.r   c                 ó   • [        5       nUR                  [        5       S5        U R                  UR                  5        [
        R                  " U5      n[
        R                  " U5      nU R                  UR                  5        U R                  UR                  5        U R                  UR                  S5        U R                  UR                  UR                  5        U R                  UR                   5        g)zœ
A L{ReconnectingClientFactory} which is unpickled does not have an
L{IConnector} and has its reconnecting timing parameters reset to their
initial values.
Nr   )r   r9   r   Ú
addCleanupr-   rG   rI   rH   rQ   rB   Ú_callIDrJ   ÚretriesÚdelayÚinitialDelayÚ
assertTruer0   )r   ÚfactoryÚ
serializedÚunserializeds       r   Ú$test_deserializationResetsParametersÚ=ReconnectingFactoryTests.test_deserializationResetsParameterso   s¸   € ô ,Ó-ˆØ×&Ñ&¤}£¸Ô=Ø�‰˜×*Ñ*Ô+ä—\’\ 'Ó*ˆ
Ü—|’| JÓ/ˆØ×Ñ˜,×0Ñ0Ô1Ø×Ñ˜,×.Ñ.Ô/Ø×Ñ˜×-Ñ-¨qÔ1Ø×Ñ˜×+Ñ+¨W×-AÑ-AÔBØ�‰˜×3Ñ3Õ4r   c                 ó¶   • [        5       n[        5       nXl        UR                  [	        5       S5        U R                  [        UR                  5      S5        g)zq
The clock used by L{ReconnectingClientFactory} can be parametrized, so
that one can cleanly test reconnections.
Né   )r   r   rA   r.   r   rJ   ÚlenÚcalls)r   rA   r[   s      r   Útest_parametrizedClockÚ/ReconnectingFactoryTests.test_parametrizedClock�   sC   € ô
 “ˆÜ+Ó-ˆØŒà×$Ñ$¤]£_°dÔ;Ø×Ñœ˜UŸ[™[Ó)¨1Õ-r   r   N)r   r   r   r   r   r2   rD   rN   rR   r^   rd   r   r   r   r   r   r      s'   † ñò+ò.!4òFDò	/ò5õ$
.r   r   )r   rG   Útwisted.internet.protocolr   r   Útwisted.internet.taskr   Útwisted.trial.unittestr   r   r   r   r   r   Ú<module>ri      s0   ðñó
 ç IÝ 'Ý +÷	ñ 	ôo.˜xõ o.r   