ó
[³XMc           @   sœ   d  Z  d d l m Z d d l m Z d d l m Z d d l m Z d d l m	 Z	 d d l
 m Z m Z d e f d	 „  ƒ  YZ d
 e f d „  ƒ  YZ d S(   s,   
Tests for L{twisted.application.strports}.
iÿÿÿÿ(   t   TestCase(   t   strports(   t   internet(   t   ParserTestCase(   t   Factory(   t   TCP4ServerEndpointt   UNIXServerEndpointt   DeprecatedParseTestCasec           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s€   
    L{strports.parse} is deprecated.  It's an alias for a method that is now
    private in L{twisted.internet.endpoints}.
    c         O   sY   t  j | | Ž  } |  j |  j g ƒ } |  j t | ƒ d ƒ |  j | d d d ƒ | S(   Ni   i    t   messages|   twisted.application.strports.parse was deprecated in Twisted 10.2.0: in favor of twisted.internet.endpoints.serverFromString(   R   t   parset   flushWarningst   assertEqualst   len(   t   selft   at   kwt   resultt   warnings(    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_strports.pyR	      s    c         C   sC   |  j  |  j d |  j ƒ d d |  j f i d d 6d d 6f ƒ d S(	   s=   
        Base numeric ports should be parsed as TCP.
        t   80t   TCPiP   t    t	   interfacei2   t   backlogN(   R   R	   t   f(   R   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_strports.pyt   test_simpleNumeric"   s    c         C   sC   |  j  |  j d |  j ƒ d d |  j f i d d 6d d 6f ƒ d S(	   s   
        A collection of keyword arguments with no prefixed type, like 'port=80',
        will be parsed as keyword arguments to 'tcp'.
        s   port=80R   iP   R   R   i2   R   N(   R   R	   R   (   R   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_strports.pyt   test_allKeywords*   s    (   t   __name__t
   __module__t   __doc__R	   R   R   (    (    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_strports.pyR      s   		t   ServiceTestCasec           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   s(   
    Tests for L{strports.service}.
    c         C   s¶   t  ƒ  } t ƒ  } d } t j d t | ƒ | d | ƒ} |  j | t j ƒ |  j | j	 t
 ƒ |  j | j t ƒ |  j | j j | ƒ |  j | j | ƒ |  j | j j | ƒ d S(   s¾   
        L{strports.service} returns a L{StreamServerEndpointService}
        constructed with an endpoint produced from
        L{endpoint.serverFromString}, using the same syntax.
        i9  s   tcp:t   reactorN(   t   objectR   R   t   servicet   strt   assertIsInstanceR   t   StreamServerEndpointServiceR   t   _raiseSynchronouslyt   Truet   endpointR   t   _portt   assertIdenticalt   factoryt   _reactor(   R   R   t   aFactoryt	   aGoodPortt   svc(    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_strports.pyt   test_service9   s    		c         C   s<   d d l  m } t j d d ƒ } |  j | j j | ƒ d S(   sp   
        L{strports.service} will use the default reactor when none is provided
        as an argument.
        iÿÿÿÿ(   R   s   tcp:80N(   t   twisted.internetR   R   R    t   NoneR(   R&   R*   (   R   t   globalReactort   aService(    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_strports.pyt   test_serviceDefaultReactorP   s    c         C   s
  t  j d d
 d ƒ } |  j | j t ƒ |  j |  j g ƒ } |  j | d d t	 ƒ |  j | d d d ƒ |  j t
 | ƒ d ƒ t  j d d
 d
 ƒ } |  j | j t ƒ |  j |  j g ƒ } |  j | d d t	 ƒ |  j | d d d	 ƒ |  j t
 | ƒ d ƒ d
 S(   sÜ   
        L{strports.service} still accepts a 'default' argument, which will
        affect the parsing of 'default' (i.e. 'not containing a colon')
        endpoint descriptions, but this behavior is deprecated.
        t   8080t   unixi    t   categoryR   sx   The 'default' parameter was deprecated in Twisted 10.2.0.  Use qualified endpoint descriptions; for example, 'tcp:8080'.i   s   tcp:8080s9   The 'default' parameter was deprecated in Twisted 10.2.0.N(   R   R    R0   R"   R&   R   R
   t   test_serviceDeprecatedDefaultR   t   DeprecationWarningR   R   (   R   R-   R   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_strports.pyR7   Z   s     c         C   s„   t  j d d ƒ } |  j | j t ƒ |  j |  j g ƒ } |  j | d d t	 ƒ |  j | d d d ƒ |  j t
 | ƒ d ƒ d S(   sP   
        Unqualified strport descriptions, i.e. "8080", are deprecated.
        R4   i    R6   R   sq   Unqualified strport description passed to 'service'.Use qualified endpoint descriptions; for example, 'tcp:8080'.i   N(   R   R    R0   R"   R&   R   R
   t!   test_serviceDeprecatedUnqualifiedR   R8   R   (   R   R-   R   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_strports.pyR9   v   s    (   R   R   R   R.   R3   R7   R9   (    (    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_strports.pyR   4   s
   		
	N(   R   t   twisted.trial.unittestR    t   twisted.applicationR   R   t$   twisted.internet.test.test_endpointsR   t   twisted.internet.protocolR   t   twisted.internet.endpointsR   R   R   R   (    (    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_strports.pyt   <module>   s   #