ϪfdZddlmZmZddlmZmZmZmZ m Z m Z ddl m Z ddlmZddlmZddlmZGd d eZGd d eZy )z1 Tests for L{twisted.protocols.haproxy._parser}. )TypeUnion)TCP4ServerEndpointTCP6ServerEndpointUNIXServerEndpoint_parse_WrapperServerEndpointserverFromString) MemoryReactor)SynchronousTestCase)unparseEndpoint)HAProxyWrappingFactorycPeZdZdZdeddfdZd dZd dZd dZd d Z d d Z d d Z y) UnparseEndpointTestszg Tests to ensure that un-parsing an endpoint string round trips through escaping properly. inputreturnNcF|jtt||y)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)selfrs L/usr/lib/python3/dist-packages/twisted/protocols/haproxy/test/test_parser.pycheckzUnparseEndpointTests.checks -*>?Gc&|jdy)z% An individual word. wordNrrs rtest_basicUnparsez&UnparseEndpointTests.test_basicUnparse)s 6rc&|jdy)z% Multiple arguments. zone:twoNrrs rtest_multipleArgumentsz+UnparseEndpointTests.test_multipleArguments/s 9rc&|jdy)z$ Keyword arguments. zaleph=one:bet=twoNrrs r test_keywordsz"UnparseEndpointTests.test_keywords5s &'rc&|jdy)z Escaped ":". zhello\:colon\:worldNrrs rtest_colonInArgumentz)UnparseEndpointTests.test_colonInArgument;s *+rc&|jdy)z/ Escaped ":" in keyword value. zhello=\:Nrrs rtest_colonInKeywordValuez-UnparseEndpointTests.test_colonInKeywordValueA ;rc&|jdy)z. Escaped ":" in keyword name. z\:=helloNrrs rtest_colonInKeywordNamez,UnparseEndpointTests.test_colonInKeywordNameGr(rrN) __name__ __module__ __qualname____doc__strrrr!r#r%r'r*rrrrs; H3 H4 H  ( ,   rrcZeZdZdZdedeeeeeee fde fdZ d dZ d dZ d d Zy) HAProxyServerParserTestsz@ Tests that the parser generates the correct endpoints. description expectedClassrct}t||}|j|tt |tsJ|j|j ||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_wrappedEndpointassertIs_wrapperFactoryr)rr4r5reactorendpoints r onePrefixz"HAProxyServerParserTests.onePrefixSsi4 /#G[9 h(>?($:;;; h77G h..0FGrNc0|jdty)zG Test if the parser generates a wrapped TCP4 endpoint. zhaproxy:tcp:8080N)r>rrs r test_tcp4z"HAProxyServerParserTests.test_tcp4us )+=>rc0|jdty)zG Test if the parser generates a wrapped TCP6 endpoint. zhaproxy:tcp6:8080N)r>rrs r test_tcp6z"HAProxyServerParserTests.test_tcp6{s *,>?rc0|jdty)zG Test if the parser generates a wrapped UNIX endpoint. z haproxy:unix:address=/tmp/socketN)r>rrs r test_unixz"HAProxyServerParserTests.test_unixs 9;MNrr+)r,r-r.r/r0rrrrrr r>r@rBrDr1rrr3r3Ns_   # $ # $ # $ &    D? @ Orr3N)r/typingrrtwisted.internet.endpointsrrrrrr r twisted.internet.testingr twisted.trial.unittestr TestCase_parserr_wrapperrrr3r1rrrLsB3B%-4 84 n7Ox7Or