Ë
    ojI  ã                   óª   — d Z ddlmZmZmZ ddlmZ ddlmZ ddl	m
Z
  G d„ de
j                  «      Z G d„ d	«      Z G d
„ dee
j                  «      Zy)z2
Test cases for twisted.protocols.postfix module.
é    )ÚDictÚListÚTuple)ÚStringTransport)Úpostfix)Úunittestc                   ó   — e Zd Zg d¢Zd„ Zy)ÚPostfixTCPMapQuoteTests))ó   foor   )s   foo bars	   foo%20bar)s   foo	bars	   foo%09bar)s   foo
bars	   foo%0Abars	   foo%0abar)s   foo
bars   foo%0D%0Abars   foo%0D%0abars   foo%0d%0Abars   foo%0d%0abar)s   foo s   foo%20)s    foos   %20fooc                 óâ   — | j                   D ]`  }|d   }|dd  }| j                  t        j                  |«      |d   «       |D ]'  }| j                  t        j                  |«      |«       Œ) Œb y )Nr   é   )ÚdataÚassertEqualr   ÚquoteÚunquote)ÚselfÚentryÚrawÚquotedÚqs        ú;/usr/lib/python3/dist-packages/twisted/test/test_postfix.pyÚtestDataz PostfixTCPMapQuoteTests.testData!   sn   € Ø—Y‘Yò 	:ˆEØ˜‘(ˆCØ˜1˜2�YˆFà×ÑœWŸ]™]¨3Ó/°¸±Ô;Øò :�Ø× Ñ ¤§¡°Ó!3°SÕ9ñ:ñ	:ó    N)Ú__name__Ú
__module__Ú__qualname__r   r   © r   r   r
   r
      s   „ ò€Dó":r   r
   c                   óV   — e Zd ZU i Zeeef   ed<   g Zee	eef      ed<   d„ Z
d„ Zd„ Zy)ÚPostfixTCPMapServerTestCaser   Úchatc                 ó¸  — t        j                  | j                  «      }t        «       }t        j                  «       }||_        ||_        |j                  |«       | j                  D ]^  \  }}|j                  |«       | j                  |j                  «       |d|›d|›d|j                  «       ›�«       |j                  «        Œ` |j                  d«       y)zÑ
        Test that I{get} and I{put} commands are responded to correctly by
        L{postfix.PostfixTCPMapServer} when its factory is an instance of
        L{postifx.PostfixTCPMapDictServerFactory}.
        zFor z, expected z	 but got N)r   ÚPostfixTCPMapDictServerFactoryr   r   ÚPostfixTCPMapServerÚserviceÚfactoryÚmakeConnectionr    ÚlineReceivedr   ÚvalueÚclearÚ
setTimeout©r   r%   Ú	transportÚprotocolÚinputÚexpected_outputs         r   Ú	test_chatz%PostfixTCPMapServerTestCase.test_chat4   s¼   € ô ×8Ñ8¸¿¹ÓCˆÜ#Ó%ˆ	ä×.Ñ.Ó0ˆØ"ˆÔØ"ˆÔØ×Ñ 	Ô*à&*§i¡iò 	Ñ"ˆE�?Ø×!Ñ! %Ô(Ø×ÑØ—‘Ó!Ùâš/¨9¯?©?Ô+<ð>ôð �O‰OÕð	ð 	×Ñ˜DÕ!r   c                 óÈ  — t        j                  | j                  «      }t        «       }t        j                  «       }||_        ||_        |j                  |«       | j                  D ]f  \  }}|j                  |«       | j                  |j                  «       |dj                  |||j                  «       «      «       |j                  «        Œh |j                  d«       y)zÚ
        Test that I{get} and I{put} commands are responded to correctly by
        L{postfix.PostfixTCPMapServer} when its factory is an instance of
        L{postifx.PostfixTCPMapDeferringDictServerFactory}.
        z$For {!r}, expected {!r} but got {!r}N)r   Ú'PostfixTCPMapDeferringDictServerFactoryr   r   r#   r$   r%   r&   r    r'   r   r(   Úformatr)   r*   r+   s         r   Útest_deferredChatz-PostfixTCPMapServerTestCase.test_deferredChatM   sÅ   € ô ×AÑAÀ$Ç)Á)ÓLˆÜ#Ó%ˆ	ä×.Ñ.Ó0ˆØ"ˆÔØ"ˆÔØ×Ñ 	Ô*à&*§i¡iò 		Ñ"ˆE�?Ø×!Ñ! %Ô(Ø×ÑØ—‘Ó!ØØ6×=Ñ=Ø˜?¨I¯O©OÓ,=óôð �O‰OÕð		ð 	×Ñ˜DÕ!r   c                 óì   —  G d„ d«      }t        j                  «       } |«       |_        t        «       |_        |j                  d«       | j                  |j                  j                  «       d«       y)z^
        If the factory throws an exception,
        error code 400 must be returned.
        c                   ó   — e Zd ZdZd„ Zy)úCPostfixTCPMapServerTestCase.test_getException.<locals>.ErrorFactoryzE
            Factory that raises an error on key lookup.
            c                 ó   — t        d«      ‚)NzThis is a test error)Ú	Exception)r   Úkeys     r   ÚgetzGPostfixTCPMapServerTestCase.test_getException.<locals>.ErrorFactory.getr   s   € ÜÐ 6Ó7Ð7r   N)r   r   r   Ú__doc__r;   r   r   r   ÚErrorFactoryr7   m   s   „ ñó8r   r=   s   get examples   400 This is a test error
N)r   r#   r%   r   r,   r'   r   r(   )r   r=   Úservers      r   Útest_getExceptionz-PostfixTCPMapServerTestCase.test_getExceptiong   s^   € ÷	8ñ 	8ô ×,Ñ,Ó.ˆÙ%›ˆŒÜ*Ó,ˆÔØ×Ñ˜NÔ+Ø×Ñ˜×)Ñ)×/Ñ/Ó1Ð3PÕQr   N)r   r   r   r   r   ÚbytesÚ__annotations__r    r   r   r0   r4   r?   r   r   r   r   r   +   sE   … ð €Dˆ$ˆu�eˆ|Ñ
ó ð'€Dˆ$ˆu�U˜E�\Ñ"Ñ
#ó ò"ò2"ó4Rr   r   c                   ó   — e Zd ZdddœZg d¢Zy)Ú
ValidTestss
   ThisIs Foos    bar really is found
)r   s   bar)
)s   gets&   400 Command 'get' takes 1 parameters.
)s   get foo baró   500 
)s   putó&   400 Command 'put' takes 2 parameters.
)s   put foorE   )s   put foo bar bazó    500 put is not implemented yet.
)s   put foo barrF   )s   get foos   200 ThisIs%20Foo
)s   get bars'   200 %20bar%20really%20is%20found%0D%0A
)s   get bazrD   )r   s   400 unknown command
N)r   r   r   r   r    r   r   r   rC   rC   |   s   „ àØ+ñ€Dò�Dr   rC   N)r<   Útypingr   r   r   Útwisted.internet.testingr   Útwisted.protocolsr   Útwisted.trialr   ÚTestCaser
   r   rC   r   r   r   ú<module>rL      sQ   ðñ÷ %Ñ $å 4Ý %Ý "ô:˜h×/Ñ/ô :÷8NRñ NRôbÐ,¨h×.?Ñ.?õ r   