+
    üÐj×  ã                   ód   € R t ^ RIt^ RIHtHt ^ RIHt ^ RIHt  ! R R4      t	 ! R R]4      t
R# )	z&
Test code for basic Factory classes.
N)ÚProtocolÚReconnectingClientFactory)ÚClock)ÚTestCasec                   ó0   a € ] tR t^t o RtR tR tRtV tR# )ÚFakeConnectorzH
A fake connector class, to be used to mock connections failed or lost.
c                ó   € R # ©N© ©Úselfs   &Ú=/usr/lib/python3/dist-packages/twisted/test/test_factories.pyÚstopConnectingÚFakeConnector.stopConnecting   ó   € Ùó    c                ó   € R # r	   r
   r   s   &r   ÚconnectÚFakeConnector.connect   r   r   r
   N)	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   Ú__static_attributes__Ú__classdictcell__©Ú__classdict__s   @r   r   r      s   ø‡ € ñò÷ð r   r   c                   óH   a € ] tR t^t o RtR tR tR tR tR t	R t
RtV tR	# )
ÚReconnectingFactoryTestsz)
Tests for L{ReconnectingClientFactory}.
c                óê   €  ! R R4      p\        4       p\        Vn        VP                  R4       VP	                  4        VP                  V! 4       R4       V P                  VP                  4       R# )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                   ó,   a € ] tR t^(t o R tR tRtV tR# )ÚQReconnectingFactoryTests.test_stopTryingWhenConnected.<locals>.NoConnectConnectorc                ó   € \        R 4      h)z%Shouldn't be called, we're connected.©ÚRuntimeErrorr   s   &r   r   Ú`ReconnectingFactoryTests.test_stopTryingWhenConnected.<locals>.NoConnectConnector.stopConnecting)   s   € Ü"Ð#JÓKÐKr   c                ó   € \        R 4      h)z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   s   @r   ÚNoConnectConnectorr"   (   s   ø‡ € òL÷Að 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                ó2  a€  ! V3R lR\         4      p\        4       o\        4       Sn        V! 4       Sn        SP                  4        V P                  SP                  P                  4       V P                  SP                  P                  4       4       R# )zg
Calling stopTrying on a L{ReconnectingClientFactory} doesn't attempt a
retry on any active connector.
c                   ó8   <a € ] tR t^>t o RtV3R ltR tRtV tR# )Ú[ReconnectingFactoryTests.test_stopTryingDoesNotReconnect.<locals>.FactoryAwareFakeConnectorFc                ó,   <€ SP                  V R4       R# )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                ó   € RV n         R# )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   )r   r8   s   @€r   ÚFactoryAwareFakeConnectorr5   >   s   ù‡ € Ø"ˆNõ5÷+ð +r   r>   N)	r   r   r   ÚclockÚ	connectorr,   r.   r<   ÚgetDelayedCalls)r   r>   r8   s   & @r   Útest_stopTryingDoesNotReconnectÚ8ReconnectingFactoryTests.test_stopTryingDoesNotReconnect8   sl   ø€ ÷	+¬ô 	+ô" &Ó'ˆÜ“'ˆŒñ 0Ó1ˆŒØ	�‰Œð 	×Ñ˜Ÿ™×3Ñ3Ô4Ø×Ñ˜Ÿ™×0Ñ0Ó2Ö3r   c                óº   € \        4       p\        P                  ! \        P                  ! V4      4      pV P	                  VP
                  VP
                  4       R# )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                óÄ   € \        4       p\        4       pWn        \        P                  ! \        P
                  ! V4      4      pV P                  VP                  4       R# )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   r?   rE   rF   rG   ÚassertIsNone)r   r?   rJ   rK   s   &   r   Útest_serializeWithClockÚ0ReconnectingFactoryTests.test_serializeWithClockd   sC   € ô
 “ˆÜ,Ó.ˆØŒÜŸš¤V§\¢\°(Ó%;Ó<ˆØ×Ñ˜-×-Ñ-Ö.r   c                ó  € \        4       pVP                  \        4       R4       V P                  VP                  4       \
        P                  ! V4      p\
        P                  ! V4      pV P                  VP                  4       V P                  VP                  4       V P                  VP                  ^ 4       V P                  VP                  VP                  4       V P                  VP                   4       R# )zœ
A L{ReconnectingClientFactory} which is unpickled does not have an
L{IConnector} and has its reconnecting timing parameters reset to their
initial values.
N)r   r7   r   Ú
addCleanupr,   rE   rG   rF   rO   r@   Ú_callIDrH   ÚretriesÚdelayÚinitialDelayÚ
assertTruer/   )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                ó¸   € \        4       p\        4       pWn        VP                  \	        4       R4       V P                  \        VP                  4      ^4       R# )zq
The clock used by L{ReconnectingClientFactory} can be parametrized, so
that one can cleanly test reconnections.
N)r   r   r?   r-   r   rH   ÚlenÚcalls)r   r?   rY   s   &  r   Útest_parametrizedClockÚ/ReconnectingFactoryTests.test_parametrizedClock�   sC   € ô
 “ˆÜ+Ó-ˆØŒà×$Ñ$¤]£_°dÔ;Ø×Ñœ˜UŸ[™[Ó)¨1Ö-r   r
   N)r   r   r   r   r   r1   rB   rL   rP   r\   ra   r   r   r   s   @r   r   r      s/   ø‡ € ñò+ò.!4òFDò	/ò5÷$
.ð 
.r   r   )r   rE   Útwisted.internet.protocolr   r   Útwisted.internet.taskr   Útwisted.trial.unittestr   r   r   r
   r   r   Ú<module>rf      s0   ðñó
 ç IÝ 'Ý +÷	ñ 	ôo.˜xö o.r   