
    tf                         d Z ddlmZmZ ddlmZmZmZmZ	m
Z
mZ ddlmZ ddlmZ ddlmZ ddlmZ  G d	 d
e          Z G d de          ZdS )z1
Tests for L{twisted.protocols.haproxy._parser}.
    )TypeUnion)TCP4ServerEndpointTCP6ServerEndpointUNIXServerEndpoint_parse_WrapperServerEndpointserverFromString)MemoryReactor)SynchronousTestCase   )unparseEndpoint)HAProxyWrappingFactoryc                   R    e Zd ZdZdeddfdZddZddZddZdd	Z	dd
Z
ddZdS )UnparseEndpointTestszg
    Tests to ensure that un-parsing an endpoint string round trips through
    escaping properly.
    inputreturnNc                 Z    |                      t          t          |           |           dS )aA  
        Check that the input unparses into the output, raising an assertion
        error if it doesn't.

        @param input: an input in endpoint-string-description format.  (To
            ensure determinism, keyword arguments should be in alphabetical
            order.)
        @type input: native L{str}
        N)assertEqualr   parseEndpoint)selfr   s     i/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/protocols/haproxy/test/test_parser.pycheckzUnparseEndpointTests.check   s-     	-*>*>?GGGGG    c                 0    |                      d           dS )z%
        An individual word.
        wordNr   r   s    r   test_basicUnparsez&UnparseEndpointTests.test_basicUnparse)   s     	

6r   c                 0    |                      d           dS )z%
        Multiple arguments.
        zone:twoNr   r   s    r   test_multipleArgumentsz+UnparseEndpointTests.test_multipleArguments/   s     	

9r   c                 0    |                      d           dS )z$
        Keyword arguments.
        zaleph=one:bet=twoNr   r   s    r   test_keywordsz"UnparseEndpointTests.test_keywords5   s     	

&'''''r   c                 0    |                      d           dS )z
        Escaped ":".
        zhello\:colon\:worldNr   r   s    r   test_colonInArgumentz)UnparseEndpointTests.test_colonInArgument;   s     	

*+++++r   c                 0    |                      d           dS )z/
        Escaped ":" in keyword value.
        zhello=\:Nr   r   s    r   test_colonInKeywordValuez-UnparseEndpointTests.test_colonInKeywordValueA        	

;r   c                 0    |                      d           dS )z.
        Escaped ":" in keyword name.
        z\:=helloNr   r   s    r   test_colonInKeywordNamez,UnparseEndpointTests.test_colonInKeywordNameG   r(   r   r   N)__name__
__module____qualname____doc__strr   r   r!   r#   r%   r'   r*    r   r   r   r      s         

H3 
H4 
H 
H 
H 
H      ( ( ( (, , , ,                  r   r   c                   t    e Zd ZdZdedeee         ee         ee	         f         de
fdZd
dZd
dZd
d	ZdS )HAProxyServerParserTestsz@
    Tests that the parser generates the correct endpoints.
    descriptionexpectedClassr   c                    t                      }t          ||          }|                     |t                     t	          |t                    sJ |                     |j        |           |                     |j        t                     |S )a%  
        Test the C{haproxy} enpdoint prefix against one sub-endpoint type.

        @param description: A string endpoint description beginning with
            C{haproxy}.
        @type description: native L{str}

        @param expectedClass: the expected sub-endpoint class given the
            description.
        @type expectedClass: L{type}

        @return: the parsed endpoint
        @rtype: L{IStreamServerEndpoint}

        @raise twisted.trial.unittest.Failtest: if the parsed endpoint doesn't
            match expectations.
        )	r   r
   assertIsInstancer	   
isinstance_wrappedEndpointassertIs_wrapperFactoryr   )r   r4   r5   reactorendpoints        r   	onePrefixz"HAProxyServerParserTests.onePrefixS   s    4  //#G[99h(>???($:;;;;;h7GGGh.0FGGGr   Nc                 <    |                      dt                     dS )zG
        Test if the parser generates a wrapped TCP4 endpoint.
        zhaproxy:tcp:8080N)r>   r   r   s    r   	test_tcp4z"HAProxyServerParserTests.test_tcp4u   s      	)+=>>>>>r   c                 <    |                      dt                     dS )zG
        Test if the parser generates a wrapped TCP6 endpoint.
        zhaproxy:tcp6:8080N)r>   r   r   s    r   	test_tcp6z"HAProxyServerParserTests.test_tcp6{   s      	*,>?????r   c                 <    |                      dt                     dS )zG
        Test if the parser generates a wrapped UNIX endpoint.
        z haproxy:unix:address=/tmp/socketN)r>   r   r   s    r   	test_unixz"HAProxyServerParserTests.test_unix   s      	9;MNNNNNr   r+   )r,   r-   r.   r/   r0   r   r   r   r   r   r	   r>   r@   rB   rD   r1   r   r   r3   r3   N   s            #$#$#$&
  
        D? ? ? ?@ @ @ @O O O O O Or   r3   N)r/   typingr   r   twisted.internet.endpointsr   r   r   r   r   r	   r
   twisted.internet.testingr   twisted.trial.unittestr   TestCase_parserr   _wrapperr   r   r3   r1   r   r   <module>rL      s,                           3 2 2 2 2 2 B B B B B B % % % % % % - - - - - -4  4  4  4  4 8 4  4  4 n7O 7O 7O 7O 7Ox 7O 7O 7O 7O 7Or   