ϪfIdZddlmZmZmZddlmZddlmZddl m Z Gdde jZ Gdd Z Gd d e e jZy ) z2 Test cases for twisted.protocols.postfix module. )DictListTuple)StringTransport)postfix)unittestceZdZgdZdZy)PostfixTCPMapQuoteTests))foor )sfoo bars foo%20bar)sfoo bars foo%09bar)sfoo bars foo%0Abars foo%0abar)sfoo bars foo%0D%0Abars foo%0D%0abars foo%0d%0Abars foo%0d%0abar)sfoo sfoo%20)s foos%20fooc|jD]`}|d}|dd}|jtj||d|D]'}|jtj||)by)Nr)data assertEqualrquoteunquote)selfentryrawquotedqs ;/usr/lib/python3/dist-packages/twisted/test/test_postfix.pytestDataz PostfixTCPMapQuoteTests.testData!snYY :E(C12YF   W]]3/ ; :  !3S9 :  :N)__name__ __module__ __qualname__rrrrr r s D":rr cVeZdZUiZeeefed<gZee eefed<dZ dZ dZ y)PostfixTCPMapServerTestCaserchatc tj|j}t}tj}||_||_|j||jD]^\}}|j||j|j|d|d|d|j|j`|jdy)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}. zFor z , expected z but got N)rPostfixTCPMapDictServerFactoryrrPostfixTCPMapServerservicefactorymakeConnectionr lineReceivedrvalueclear setTimeoutrr% transportprotocolinputexpected_outputs r test_chatz%PostfixTCPMapServerTestCase.test_chat4s 88C#% ..0"" *&*ii  "E?  ! !% (   !/9??+<>  OO   D!rc tj|j}t}tj}||_||_|j||jD]f\}}|j||j|j|dj|||j|jh|jdy)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'PostfixTCPMapDeferringDictServerFactoryrrr#r$r%r&r r'rr(formatr)r*r+s rtest_deferredChatz-PostfixTCPMapServerTestCase.test_deferredChatMs AA$))L#% ..0"" *&*ii  "E?  ! !% (   !6==?IOO,=  OO   D!rcGdd}tj}||_t|_|j d|j |jjdy)z^ If the factory throws an exception, error code 400 must be returned. ceZdZdZdZy)CPostfixTCPMapServerTestCase.test_getException..ErrorFactoryzE Factory that raises an error on key lookup. ctd)NzThis is a test error) Exception)rkeys rgetzGPostfixTCPMapServerTestCase.test_getException..ErrorFactory.getrs 677rN)rrr__doc__r;rrr ErrorFactoryr7ms   8rr=s get examples400 This is a test error N)rr#r%rr,r'rr()rr=servers rtest_getExceptionz-PostfixTCPMapServerTestCase.test_getExceptiongs^  8 8,,.%*,N+ ))//13PQrN) rrrrrbytes__annotations__r rrr0r4r?rrrrr+sE D$ue| 'D$uUE\" #"2"4RrrceZdZdddZgdZy) ValidTestss ThisIs Foos bar really is found )r sbar) )sgets&400 Command 'get' takes 1 parameters. )s get foo bar500 )sput&400 Command 'put' takes 2 parameters. )sput foorE)sput foo bar baz 500 put is not implemented yet. )s put foo barrF)sget foos200 ThisIs%20Foo )sget bars'200 %20bar%20really%20is%20found%0D%0A )sget bazrD)r s400 unknown command N)rrrrr rrrrCrC|s+ D DrrCN)r<typingrrrtwisted.internet.testingrtwisted.protocolsr twisted.trialrTestCaser rrCrrrrLsQ%$4%":h//:8NRNRb,h.?.?r