ó
[³XMc           @   s‚   d  Z  d d l m Z d d l m Z d d l m Z d e j f d „  ƒ  YZ d d d „  ƒ  YZ	 d	 e	 e j f d
 „  ƒ  YZ
 d S(   s2   
Test cases for twisted.protocols.postfix module.
iÿÿÿÿ(   t   unittest(   t   postfix(   t   StringTransportt   PostfixTCPMapQuoteTestCasec        	   B   s,   e  Z d d d d d d d g Z d „  Z RS(   t   foos   foo bars	   foo%20bars   foo	bars	   foo%09bars   foo
bars	   foo%0Abars	   foo%0abars   foo
bars   foo%0D%0Abars   foo%0D%0abars   foo%0d%0Abars   foo%0d%0abars   foo s   foo%20s    foos   %20fooc         C   ss   xl |  j  D]a } | d } | d } |  j t j | ƒ | d ƒ x' | D] } |  j t j | ƒ | ƒ qH Wq
 Wd  S(   Ni    i   (   t   datat   assertEqualsR   t   quotet   unquote(   t   selft   entryt   rawt   quotedt   q(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_postfix.pyt   testData   s    

(   R   R   (   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   %20foo(   t   __name__t
   __module__R   R   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_postfix.pyR      s   	t   PostfixTCPMapServerTestCasec           B   s&   e  Z i  Z g  Z d  „  Z d „  Z RS(   c         C   s´   t  j |  j ƒ } t ƒ  } t  j ƒ  } | | _ | | _ | j | ƒ xZ |  j D]O \ } } | j	 | ƒ |  j
 | j ƒ  | d | | | j ƒ  f ƒ | j ƒ  qP W| j d ƒ d S(   sÑ   
        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}.
        s   For %r, expected %r but got %rN(   R   t   PostfixTCPMapDictServerFactoryR   R   t   PostfixTCPMapServert   servicet   factoryt   makeConnectiont   chatt   lineReceivedR   t   valuet   cleart
   setTimeoutt   None(   R	   R   t	   transportt   protocolt   inputt   expected_output(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_postfix.pyt	   test_chat+   s    			c         C   s´   t  j |  j ƒ } t ƒ  } t  j ƒ  } | | _ | | _ | j | ƒ xZ |  j D]O \ } } | j	 | ƒ |  j
 | j ƒ  | d | | | j ƒ  f ƒ | j ƒ  qP W| j d ƒ d S(   sÚ   
        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}.
        s   For %r, expected %r but got %rN(   R   t'   PostfixTCPMapDeferringDictServerFactoryR   R   R   R   R   R   R   R   R   R   R   R   R   (   R	   R   R   R   R   R    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_postfix.pyt   test_deferredChatC   s    			(   R   R   R   R   R!   R#   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_postfix.pyR   "   s   	t   Validc           B   s@   e  Z i d  d 6d d 6Z d d d d d d d d d d g
 Z RS(   s
   ThisIs FooR   s    bar really is found
t   bart   gets&   400 Command 'get' takes 1 parameters.
s   get foo bars   500 
t   puts&   400 Command 'put' takes 2 parameters.
s   put foos   put foo bar bazs    500 put is not implemented yet.
s   put foo bars   get foos   200 ThisIs%20Foo
s   get bars'   200 %20bar%20really%20is%20found%0D%0A
s   get bazs   400 unknown command
(   s   gets&   400 Command 'get' takes 1 parameters.
(   s   get foo bars   500 
(   R'   s&   400 Command 'put' takes 2 parameters.
(   s   put foos&   400 Command 'put' takes 2 parameters.
(   s   put foo bar bazs    500 put is not implemented yet.
(   s   put foo bars    500 put is not implemented yet.
(   s   get foos   200 ThisIs%20Foo
(   s   get bars'   200 %20bar%20really%20is%20found%0D%0A
(   s   get bazs   500 
(   s   foos   400 unknown command
(   R   R   R   R   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_postfix.pyR$   \   s   
N(    (   t   __doc__t   twisted.trialR    t   twisted.protocolsR   t   twisted.test.proto_helpersR   t   TestCaseR   R   R$   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_postfix.pyt   <module>   s   :