HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/twisted/protocols/haproxy/test/__pycache__/test_parser.cpython-310.pyc
o

�b�@s�dZddlmZmZddlmZmZmZmZ	m
Z
mZddlm
Z
ddlmZddlmZddlmZGd	d
�d
e�ZGdd�de�Zd
S)z1
Tests for L{twisted.protocols.haproxy._parser}.
�)�Type�Union)�TCP4ServerEndpoint�TCP6ServerEndpoint�UNIXServerEndpoint�_parse�_WrapperServerEndpoint�serverFromString)�
MemoryReactor)�SynchronousTestCase�)�unparseEndpoint)�HAProxyWrappingFactoryc@s^eZdZdZdeddfdd�Zddd�Zdd	d
�Zddd�Zdd
d�Z	ddd�Z
ddd�ZdS)�UnparseEndpointTestszg
    Tests to ensure that un-parsing an endpoint string round trips through
    escaping properly.
    �input�returnNcCs|�tt|��|�dS)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�r�L/usr/lib/python3/dist-packages/twisted/protocols/haproxy/test/test_parser.py�checks
zUnparseEndpointTests.checkcC�|�d�dS)z%
        An individual word.
        �wordN�r�rrrr�test_basicUnparse)�z&UnparseEndpointTests.test_basicUnparsecCr)z%
        Multiple arguments.
        zone:twoNrrrrr�test_multipleArguments/rz+UnparseEndpointTests.test_multipleArgumentscCr)z$
        Keyword arguments.
        zaleph=one:bet=twoNrrrrr�
test_keywords5rz"UnparseEndpointTests.test_keywordscCr)z
        Escaped ":".
        zhello\:colon\:worldNrrrrr�test_colonInArgument;rz)UnparseEndpointTests.test_colonInArgumentcCr)z/
        Escaped ":" in keyword value.
        zhello=\:Nrrrrr�test_colonInKeywordValueArz-UnparseEndpointTests.test_colonInKeywordValuecCr)z.
        Escaped ":" in keyword name.
        z\:=helloNrrrrr�test_colonInKeywordNameGrz,UnparseEndpointTests.test_colonInKeywordName�rN)�__name__�
__module__�__qualname__�__doc__�strrrrrr r!r"rrrrrs




rc@sZeZdZdZdedeeeeeee	fde
fdd�Zddd	�Zdd
d�Z
ddd
�ZdS)�HAProxyServerParserTestsz@
    Tests that the parser generates the correct endpoints.
    �description�
expectedClassrcCsJt�}t||�}|�|t�t|t�sJ�|�|j|�|�|jt�|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)rr*r+�reactor�endpointrrr�	onePrefixSs
z"HAProxyServerParserTests.onePrefixNcC�|�dt�dS)zG
        Test if the parser generates a wrapped TCP4 endpoint.
        zhaproxy:tcp:8080N)r3rrrrr�	test_tcp4u�z"HAProxyServerParserTests.test_tcp4cCr4)zG
        Test if the parser generates a wrapped TCP6 endpoint.
        zhaproxy:tcp6:8080N)r3rrrrr�	test_tcp6{r6z"HAProxyServerParserTests.test_tcp6cCr4)zG
        Test if the parser generates a wrapped UNIX endpoint.
        z haproxy:unix:address=/tmp/socketN)r3rrrrr�	test_unix�r6z"HAProxyServerParserTests.test_unixr#)r$r%r&r'r(rrrrrrr3r5r7r8rrrrr)Ns"����
�
"
r)N)r'�typingrr�twisted.internet.endpointsrrrrrrr	�twisted.test.proto_helpersr
�twisted.trial.unittestr�TestCase�_parserr
�_wrapperrrr)rrrr�<module>s 7