<s> """<STR_LIT>""" <EOL> import sys <EOL> if sys . version > '<STR_LIT:3>' : <EOL> xrange = range <EOL> if sys . version_info < ( <NUM_LIT:2> , <NUM_LIT:7> ) : <EOL> import unittest2 as unittest <EOL> else : <EOL> import unittest <EOL> if sys . version > '<STR_LIT:3>' : <EOL> from urllib . parse import urlsplit , quote , quote_plus , unquote , unquote_plus <EOL> else : <EOL> from urlparse import urlsplit <EOL> from urllib import quote , quote_plus , unquote , unquote_plus <EOL> import os <EOL> import time <EOL> import tempfile <EOL> import shutil <EOL> import socket <EOL> import errno <EOL> try : <EOL> import simplejson as json <EOL> except ImportError : <EOL> import json <EOL> from ioflo . aid . sixing import * <EOL> from ioflo . aid . timing import Timer , StoreTimer <EOL> from ioflo . aid . odicting import odict <EOL> from ioflo . aid . consoling import getConsole <EOL> from ioflo . base import storing <EOL> from ioflo . aio import wiring , tcp <EOL> from ioflo . aio . http import httping , clienting , serving <EOL> console = getConsole ( ) <EOL> def setUpModule ( ) : <EOL> pass <EOL> def tearDownModule ( ) : <EOL> pass <EOL> class BasicTestCase ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> """<STR_LIT:U+0020>""" <EOL> console . reinit ( verbosity = console . Wordage . profuse ) <EOL> def tearDown ( self ) : <EOL> """<STR_LIT:U+0020>""" <EOL> console . reinit ( verbosity = console . Wordage . concise ) <EOL> def testNonBlockingRequestEcho ( self ) : <EOL> """<STR_LIT>""" <EOL> console . terse ( "<STR_LIT>" . format ( self . testNonBlockingRequestEcho . __doc__ ) ) <EOL> wireLogAlpha = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogAlpha . reopen ( ) <EOL> wireLogBeta = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogBeta . reopen ( ) <EOL> alpha = tcp . Server ( port = <NUM_LIT> , bufsize = <NUM_LIT> , wlog = wireLogAlpha ) <EOL> self . assertIs ( alpha . reopen ( ) , True ) <EOL> self . assertEqual ( alpha . ha , ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEqual ( alpha . eha , ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> beta = tcp . Client ( ha = alpha . eha , bufsize = <NUM_LIT> , wlog = wireLogBeta ) <EOL> self . assertIs ( beta . reopen ( ) , True ) <EOL> self . assertIs ( beta . accepted , False ) <EOL> self . assertIs ( beta . connected , False ) <EOL> self . assertIs ( beta . cutoff , False ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> while True : <EOL> beta . serviceConnect ( ) <EOL> alpha . serviceConnects ( ) <EOL> if beta . connected and beta . ca in alpha . ixes : <EOL> break <EOL> time . sleep ( <NUM_LIT> ) <EOL> self . assertIs ( beta . accepted , True ) <EOL> self . assertIs ( beta . connected , True ) <EOL> self . assertIs ( beta . cutoff , False ) <EOL> self . assertEqual ( beta . ca , beta . cs . getsockname ( ) ) <EOL> self . assertEqual ( beta . ha , beta . cs . getpeername ( ) ) <EOL> self . assertEqual ( alpha . eha , beta . ha ) <EOL> ixBeta = alpha . ixes [ beta . ca ] <EOL> self . assertIsNotNone ( ixBeta . ca ) <EOL> self . assertIsNotNone ( ixBeta . cs ) <EOL> self . assertEqual ( ixBeta . cs . getsockname ( ) , beta . cs . getpeername ( ) ) <EOL> self . assertEqual ( ixBeta . cs . getpeername ( ) , beta . cs . getsockname ( ) ) <EOL> self . assertEqual ( ixBeta . ca , beta . ca ) <EOL> self . assertEqual ( ixBeta . ha , beta . ha ) <EOL> console . terse ( "<STR_LIT>" . format ( "<STR_LIT>" ) ) <EOL> host = u'<STR_LIT:127.0.0.1>' <EOL> port = <NUM_LIT> <EOL> method = u'<STR_LIT:GET>' <EOL> path = u'<STR_LIT>' <EOL> console . terse ( "<STR_LIT>" . format ( method , host , port , path ) ) <EOL> headers = odict ( [ ( u'<STR_LIT>' , u'<STR_LIT:application/json>' ) ] ) <EOL> request = clienting . Requester ( hostname = host , <EOL> port = port , <EOL> method = method , <EOL> path = path , <EOL> headers = headers ) <EOL> msgOut = request . build ( ) <EOL> lines = [ <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> ] <EOL> for i , line in enumerate ( lines ) : <EOL> self . assertEqual ( line , request . lines [ i ] ) <EOL> self . assertEqual ( request . head , b'<STR_LIT>' ) <EOL> self . assertEqual ( msgOut , b'<STR_LIT>' ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> beta . tx ( msgOut ) <EOL> while beta . txes and not ixBeta . rxbs : <EOL> beta . serviceTxes ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> alpha . serviceReceivesAllIx ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> msgIn = bytes ( ixBeta . rxbs ) <EOL> self . assertEqual ( msgIn , msgOut ) <EOL> ixBeta . clearRxbs ( ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> msgOut = b'<STR_LIT>' <EOL> ixBeta . tx ( msgOut ) <EOL> while ixBeta . txes or not beta . rxbs : <EOL> alpha . serviceTxesAllIx ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . serviceReceives ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> msgIn = bytes ( beta . rxbs ) <EOL> self . assertEqual ( msgIn , msgOut ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> response = clienting . Respondent ( msg = beta . rxbs , method = method ) <EOL> while response . parser : <EOL> response . parse ( ) <EOL> response . dictify ( ) <EOL> self . assertEqual ( bytes ( response . body ) , b'<STR_LIT>' ) <EOL> self . assertEqual ( response . data , { '<STR_LIT:action>' : None , <EOL> '<STR_LIT:content>' : None , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT:url>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' } ) <EOL> self . assertEqual ( len ( beta . rxbs ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( response . headers . items ( ) , [ ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT:application/json>' ) , <EOL> ( '<STR_LIT:date>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) ] ) <EOL> alpha . close ( ) <EOL> beta . close ( ) <EOL> wireLogAlpha . close ( ) <EOL> wireLogBeta . close ( ) <EOL> def testNonBlockingRequestStream ( self ) : <EOL> """<STR_LIT>""" <EOL> console . terse ( "<STR_LIT>" . format ( self . testNonBlockingRequestStream . __doc__ ) ) <EOL> wireLogAlpha = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogAlpha . reopen ( ) <EOL> wireLogBeta = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogBeta . reopen ( ) <EOL> alpha = tcp . Server ( port = <NUM_LIT> , bufsize = <NUM_LIT> , wlog = wireLogAlpha ) <EOL> self . assertIs ( alpha . reopen ( ) , True ) <EOL> self . assertEqual ( alpha . ha , ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEqual ( alpha . eha , ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> beta = tcp . Client ( ha = alpha . eha , bufsize = <NUM_LIT> , wlog = wireLogBeta ) <EOL> self . assertIs ( beta . reopen ( ) , True ) <EOL> self . assertIs ( beta . accepted , False ) <EOL> self . assertIs ( beta . connected , False ) <EOL> self . assertIs ( beta . cutoff , False ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> while True : <EOL> beta . serviceConnect ( ) <EOL> alpha . serviceConnects ( ) <EOL> if beta . connected and beta . ca in alpha . ixes : <EOL> break <EOL> time . sleep ( <NUM_LIT> ) <EOL> self . assertIs ( beta . accepted , True ) <EOL> self . assertIs ( beta . connected , True ) <EOL> self . assertIs ( beta . cutoff , False ) <EOL> self . assertEqual ( beta . ca , beta . cs . getsockname ( ) ) <EOL> self . assertEqual ( beta . ha , beta . cs . getpeername ( ) ) <EOL> self . assertEqual ( alpha . eha , beta . ha ) <EOL> ixBeta = alpha . ixes [ beta . ca ] <EOL> self . assertIsNotNone ( ixBeta . ca ) <EOL> self . assertIsNotNone ( ixBeta . cs ) <EOL> self . assertEqual ( ixBeta . cs . getsockname ( ) , beta . cs . getpeername ( ) ) <EOL> self . assertEqual ( ixBeta . cs . getpeername ( ) , beta . cs . getsockname ( ) ) <EOL> self . assertEqual ( ixBeta . ca , beta . ca ) <EOL> self . assertEqual ( ixBeta . ha , beta . ha ) <EOL> console . terse ( "<STR_LIT>" . format ( "<STR_LIT>" ) ) <EOL> host = u'<STR_LIT:127.0.0.1>' <EOL> port = <NUM_LIT> <EOL> method = u'<STR_LIT:GET>' <EOL> path = u'<STR_LIT>' <EOL> console . terse ( "<STR_LIT>" . format ( method , host , port , path ) ) <EOL> headers = odict ( [ ( u'<STR_LIT>' , u'<STR_LIT:application/json>' ) ] ) <EOL> request = clienting . Requester ( hostname = host , <EOL> port = port , <EOL> method = method , <EOL> path = path , <EOL> headers = headers ) <EOL> msgOut = request . build ( ) <EOL> lines = [ <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> ] <EOL> for i , line in enumerate ( lines ) : <EOL> self . assertEqual ( line , request . lines [ i ] ) <EOL> self . assertEqual ( request . head , b'<STR_LIT>' ) <EOL> self . assertEqual ( msgOut , request . head ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> beta . tx ( msgOut ) <EOL> while beta . txes and not ixBeta . rxbs : <EOL> beta . serviceTxes ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> alpha . serviceReceivesAllIx ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> msgIn = bytes ( ixBeta . rxbs ) <EOL> self . assertEqual ( msgIn , msgOut ) <EOL> ixBeta . clearRxbs ( ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> lines = [ <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> ] <EOL> msgOut = b'<STR_LIT>' . join ( lines ) <EOL> ixBeta . tx ( msgOut ) <EOL> while ixBeta . txes or not beta . rxbs : <EOL> alpha . serviceTxesAllIx ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . serviceReceives ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> msgIn = bytes ( beta . rxbs ) <EOL> self . assertEqual ( msgIn , msgOut ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> response = clienting . Respondent ( msg = beta . rxbs , method = method ) <EOL> lines = [ <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> ] <EOL> msgOut = b'<STR_LIT>' . join ( lines ) <EOL> ixBeta . tx ( msgOut ) <EOL> timer = Timer ( duration = <NUM_LIT:0.5> ) <EOL> while response . parser and not timer . expired : <EOL> alpha . serviceTxesAllIx ( ) <EOL> response . parse ( ) <EOL> beta . serviceReceives ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> if response . parser : <EOL> response . parser . close ( ) <EOL> response . parser = None <EOL> response . dictify ( ) <EOL> self . assertEqual ( len ( beta . rxbs ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( response . eventSource . retry , <NUM_LIT:1000> ) <EOL> self . assertEqual ( response . retry , response . eventSource . retry ) <EOL> self . assertEqual ( response . eventSource . leid , None ) <EOL> self . assertEqual ( response . leid , response . eventSource . leid ) <EOL> self . assertTrue ( len ( response . events ) > <NUM_LIT:2> ) <EOL> event = response . events . popleft ( ) <EOL> self . assertEqual ( event , { '<STR_LIT:id>' : None , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:data>' : '<STR_LIT>' } ) <EOL> event = response . events . popleft ( ) <EOL> self . assertEqual ( event , { '<STR_LIT:id>' : None , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:data>' : '<STR_LIT:1>' } ) <EOL> event = response . events . popleft ( ) <EOL> self . assertEqual ( event , { '<STR_LIT:id>' : None , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:data>' : '<STR_LIT:2>' } ) <EOL> self . assertTrue ( len ( response . body ) == <NUM_LIT:0> ) <EOL> self . assertTrue ( len ( response . eventSource . raw ) == <NUM_LIT:0> ) <EOL> alpha . close ( ) <EOL> beta . close ( ) <EOL> wireLogAlpha . close ( ) <EOL> wireLogBeta . close ( ) <EOL> def testNonBlockingRequestStreamChunked ( self ) : <EOL> """<STR_LIT>""" <EOL> console . terse ( "<STR_LIT>" . format ( self . testNonBlockingRequestStreamChunked . __doc__ ) ) <EOL> wireLogAlpha = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogAlpha . reopen ( ) <EOL> wireLogBeta = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogBeta . reopen ( ) <EOL> alpha = tcp . Server ( port = <NUM_LIT> , bufsize = <NUM_LIT> , wlog = wireLogAlpha ) <EOL> self . assertIs ( alpha . reopen ( ) , True ) <EOL> self . assertEqual ( alpha . ha , ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEqual ( alpha . eha , ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> beta = tcp . Client ( ha = alpha . eha , bufsize = <NUM_LIT> , wlog = wireLogBeta ) <EOL> self . assertIs ( beta . reopen ( ) , True ) <EOL> self . assertIs ( beta . accepted , False ) <EOL> self . assertIs ( beta . connected , False ) <EOL> self . assertIs ( beta . cutoff , False ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> while True : <EOL> beta . serviceConnect ( ) <EOL> alpha . serviceConnects ( ) <EOL> if beta . connected and beta . ca in alpha . ixes : <EOL> break <EOL> time . sleep ( <NUM_LIT> ) <EOL> self . assertIs ( beta . accepted , True ) <EOL> self . assertIs ( beta . connected , True ) <EOL> self . assertIs ( beta . cutoff , False ) <EOL> self . assertEqual ( beta . ca , beta . cs . getsockname ( ) ) <EOL> self . assertEqual ( beta . ha , beta . cs . getpeername ( ) ) <EOL> self . assertEqual ( alpha . eha , beta . ha ) <EOL> ixBeta = alpha . ixes [ beta . ca ] <EOL> self . assertIsNotNone ( ixBeta . ca ) <EOL> self . assertIsNotNone ( ixBeta . cs ) <EOL> self . assertEqual ( ixBeta . cs . getsockname ( ) , beta . cs . getpeername ( ) ) <EOL> self . assertEqual ( ixBeta . cs . getpeername ( ) , beta . cs . getsockname ( ) ) <EOL> self . assertEqual ( ixBeta . ca , beta . ca ) <EOL> self . assertEqual ( ixBeta . ha , beta . ha ) <EOL> console . terse ( "<STR_LIT>" . format ( "<STR_LIT>" ) ) <EOL> host = u'<STR_LIT:127.0.0.1>' <EOL> port = <NUM_LIT> <EOL> method = u'<STR_LIT:GET>' <EOL> path = u'<STR_LIT>' <EOL> console . terse ( "<STR_LIT>" . format ( method , host , port , path ) ) <EOL> headers = odict ( [ ( u'<STR_LIT>' , u'<STR_LIT:application/json>' ) ] ) <EOL> request = clienting . Requester ( hostname = host , <EOL> port = port , <EOL> method = method , <EOL> path = path , <EOL> headers = headers ) <EOL> msgOut = request . build ( ) <EOL> lines = [ <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> ] <EOL> for i , line in enumerate ( lines ) : <EOL> self . assertEqual ( line , request . lines [ i ] ) <EOL> self . assertEqual ( request . head , b'<STR_LIT>' ) <EOL> self . assertEqual ( msgOut , request . head ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> beta . tx ( msgOut ) <EOL> while beta . txes and not ixBeta . rxbs : <EOL> beta . serviceTxes ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> alpha . serviceReceivesAllIx ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> msgIn = bytes ( ixBeta . rxbs ) <EOL> self . assertEqual ( msgIn , msgOut ) <EOL> ixBeta . clearRxbs ( ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> lines = [ <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> ] <EOL> msgOut = b'<STR_LIT>' . join ( lines ) <EOL> ixBeta . tx ( msgOut ) <EOL> while ixBeta . txes or not beta . rxbs : <EOL> alpha . serviceTxesAllIx ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . serviceReceives ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> msgIn = bytes ( beta . rxbs ) <EOL> self . assertEqual ( msgIn , msgOut ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> response = clienting . Respondent ( msg = beta . rxbs , method = method ) <EOL> lines = [ <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> ] <EOL> msgOut = b'<STR_LIT>' . join ( lines ) <EOL> ixBeta . tx ( msgOut ) <EOL> timer = Timer ( duration = <NUM_LIT:0.5> ) <EOL> while response . parser and not timer . expired : <EOL> alpha . serviceTxesAllIx ( ) <EOL> response . parse ( ) <EOL> beta . serviceReceives ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> if response . parser : <EOL> response . parser . close ( ) <EOL> response . parser = None <EOL> response . dictify ( ) <EOL> self . assertEqual ( len ( beta . rxbs ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( response . eventSource . retry , <NUM_LIT:1000> ) <EOL> self . assertEqual ( response . retry , response . eventSource . retry ) <EOL> self . assertEqual ( response . eventSource . leid , None ) <EOL> self . assertEqual ( response . leid , response . eventSource . leid ) <EOL> self . assertTrue ( len ( response . events ) > <NUM_LIT:2> ) <EOL> event = response . events . popleft ( ) <EOL> self . assertEqual ( event , { '<STR_LIT:id>' : None , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:data>' : '<STR_LIT>' } ) <EOL> event = response . events . popleft ( ) <EOL> self . assertEqual ( event , { '<STR_LIT:id>' : None , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:data>' : '<STR_LIT:1>' } ) <EOL> event = response . events . popleft ( ) <EOL> self . assertEqual ( event , { '<STR_LIT:id>' : None , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:data>' : '<STR_LIT:2>' } ) <EOL> self . assertTrue ( len ( response . body ) == <NUM_LIT:0> ) <EOL> self . assertTrue ( len ( response . eventSource . raw ) == <NUM_LIT:0> ) <EOL> alpha . close ( ) <EOL> beta . close ( ) <EOL> wireLogAlpha . close ( ) <EOL> wireLogBeta . close ( ) <EOL> def testNonBlockingRequestStreamFancy ( self ) : <EOL> """<STR_LIT>""" <EOL> console . terse ( "<STR_LIT>" . format ( self . testNonBlockingRequestStreamFancy . __doc__ ) ) <EOL> wireLogAlpha = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogAlpha . reopen ( ) <EOL> wireLogBeta = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogBeta . reopen ( ) <EOL> alpha = tcp . Server ( port = <NUM_LIT> , bufsize = <NUM_LIT> , wlog = wireLogAlpha ) <EOL> self . assertIs ( alpha . reopen ( ) , True ) <EOL> self . assertEqual ( alpha . ha , ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEqual ( alpha . eha , ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> beta = tcp . Client ( ha = alpha . eha , bufsize = <NUM_LIT> , wlog = wireLogBeta ) <EOL> self . assertIs ( beta . reopen ( ) , True ) <EOL> self . assertIs ( beta . accepted , False ) <EOL> self . assertIs ( beta . connected , False ) <EOL> self . assertIs ( beta . cutoff , False ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> while True : <EOL> beta . serviceConnect ( ) <EOL> alpha . serviceConnects ( ) <EOL> if beta . connected and beta . ca in alpha . ixes : <EOL> break <EOL> time . sleep ( <NUM_LIT> ) <EOL> self . assertIs ( beta . accepted , True ) <EOL> self . assertIs ( beta . connected , True ) <EOL> self . assertIs ( beta . cutoff , False ) <EOL> self . assertEqual ( beta . ca , beta . cs . getsockname ( ) ) <EOL> self . assertEqual ( beta . ha , beta . cs . getpeername ( ) ) <EOL> self . assertEqual ( alpha . eha , beta . ha ) <EOL> ixBeta = alpha . ixes [ beta . ca ] <EOL> self . assertIsNotNone ( ixBeta . ca ) <EOL> self . assertIsNotNone ( ixBeta . cs ) <EOL> self . assertEqual ( ixBeta . cs . getsockname ( ) , beta . cs . getpeername ( ) ) <EOL> self . assertEqual ( ixBeta . cs . getpeername ( ) , beta . cs . getsockname ( ) ) <EOL> self . assertEqual ( ixBeta . ca , beta . ca ) <EOL> self . assertEqual ( ixBeta . ha , beta . ha ) <EOL> console . terse ( "<STR_LIT>" . format ( "<STR_LIT>" ) ) <EOL> host = u'<STR_LIT:127.0.0.1>' <EOL> port = <NUM_LIT> <EOL> method = u'<STR_LIT:GET>' <EOL> path = u'<STR_LIT>' <EOL> console . terse ( "<STR_LIT>" . format ( method , host , port , path ) ) <EOL> headers = odict ( [ ( u'<STR_LIT>' , u'<STR_LIT:application/json>' ) ] ) <EOL> request = clienting . Requester ( hostname = host , <EOL> port = port , <EOL> method = method , <EOL> path = path , <EOL> headers = headers ) <EOL> msgOut = request . build ( ) <EOL> lines = [ <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> ] <EOL> for i , line in enumerate ( lines ) : <EOL> self . assertEqual ( line , request . lines [ i ] ) <EOL> self . assertEqual ( request . head , b'<STR_LIT>' ) <EOL> self . assertEqual ( msgOut , request . head ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> beta . tx ( msgOut ) <EOL> while beta . txes and not ixBeta . rxbs : <EOL> beta . serviceTxes ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> alpha . serviceReceivesAllIx ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> msgIn = bytes ( ixBeta . rxbs ) <EOL> self . assertEqual ( msgIn , msgOut ) <EOL> ixBeta . clearRxbs ( ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> lines = [ <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> ] <EOL> msgOut = b'<STR_LIT>' . join ( lines ) <EOL> ixBeta . tx ( msgOut ) <EOL> while ixBeta . txes or not beta . rxbs : <EOL> alpha . serviceTxesAllIx ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . serviceReceives ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> msgIn = bytes ( beta . rxbs ) <EOL> self . assertEqual ( msgIn , msgOut ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> response = clienting . Respondent ( msg = beta . rxbs , method = method ) <EOL> lines = [ <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> ] <EOL> msgOut = b'<STR_LIT>' . join ( lines ) <EOL> ixBeta . tx ( msgOut ) <EOL> timer = Timer ( duration = <NUM_LIT:0.5> ) <EOL> while response . parser and not timer . expired : <EOL> alpha . serviceTxesAllIx ( ) <EOL> response . parse ( ) <EOL> beta . serviceReceives ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> if response . parser : <EOL> response . parser . close ( ) <EOL> response . parser = None <EOL> response . dictify ( ) <EOL> self . assertEqual ( len ( beta . rxbs ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( response . eventSource . retry , <NUM_LIT:1000> ) <EOL> self . assertEqual ( response . retry , response . eventSource . retry ) <EOL> self . assertTrue ( int ( response . eventSource . leid ) >= <NUM_LIT:2> ) <EOL> self . assertEqual ( response . leid , response . eventSource . leid ) <EOL> self . assertTrue ( len ( response . events ) > <NUM_LIT:2> ) <EOL> event = response . events . popleft ( ) <EOL> self . assertEqual ( event , { '<STR_LIT:id>' : '<STR_LIT:0>' , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:data>' : '<STR_LIT>' } ) <EOL> event = response . events . popleft ( ) <EOL> self . assertEqual ( event , { '<STR_LIT:id>' : '<STR_LIT:1>' , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:data>' : '<STR_LIT>' } ) <EOL> event = response . events . popleft ( ) <EOL> self . assertEqual ( event , { '<STR_LIT:id>' : '<STR_LIT:2>' , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:data>' : '<STR_LIT>' } ) <EOL> self . assertTrue ( len ( response . body ) == <NUM_LIT:0> ) <EOL> self . assertTrue ( len ( response . eventSource . raw ) == <NUM_LIT:0> ) <EOL> alpha . close ( ) <EOL> beta . close ( ) <EOL> wireLogAlpha . close ( ) <EOL> wireLogBeta . close ( ) <EOL> def testNonBlockingRequestStreamFancyChunked ( self ) : <EOL> """<STR_LIT>""" <EOL> console . terse ( "<STR_LIT>" . format ( self . testNonBlockingRequestStreamFancyChunked . __doc__ ) ) <EOL> wireLogAlpha = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogAlpha . reopen ( ) <EOL> wireLogBeta = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogBeta . reopen ( ) <EOL> alpha = tcp . Server ( port = <NUM_LIT> , bufsize = <NUM_LIT> , wlog = wireLogAlpha ) <EOL> self . assertIs ( alpha . reopen ( ) , True ) <EOL> self . assertEqual ( alpha . ha , ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEqual ( alpha . eha , ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> beta = tcp . Client ( ha = alpha . eha , bufsize = <NUM_LIT> , wlog = wireLogBeta ) <EOL> self . assertIs ( beta . reopen ( ) , True ) <EOL> self . assertIs ( beta . accepted , False ) <EOL> self . assertIs ( beta . connected , False ) <EOL> self . assertIs ( beta . cutoff , False ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> while True : <EOL> beta . serviceConnect ( ) <EOL> alpha . serviceConnects ( ) <EOL> if beta . connected and beta . ca in alpha . ixes : <EOL> break <EOL> time . sleep ( <NUM_LIT> ) <EOL> self . assertIs ( beta . accepted , True ) <EOL> self . assertIs ( beta . connected , True ) <EOL> self . assertIs ( beta . cutoff , False ) <EOL> self . assertEqual ( beta . ca , beta . cs . getsockname ( ) ) <EOL> self . assertEqual ( beta . ha , beta . cs . getpeername ( ) ) <EOL> self . assertEqual ( alpha . eha , beta . ha ) <EOL> ixBeta = alpha . ixes [ beta . ca ] <EOL> self . assertIsNotNone ( ixBeta . ca ) <EOL> self . assertIsNotNone ( ixBeta . cs ) <EOL> self . assertEqual ( ixBeta . cs . getsockname ( ) , beta . cs . getpeername ( ) ) <EOL> self . assertEqual ( ixBeta . cs . getpeername ( ) , beta . cs . getsockname ( ) ) <EOL> self . assertEqual ( ixBeta . ca , beta . ca ) <EOL> self . assertEqual ( ixBeta . ha , beta . ha ) <EOL> console . terse ( "<STR_LIT>" . format ( "<STR_LIT>" ) ) <EOL> host = u'<STR_LIT:127.0.0.1>' <EOL> port = <NUM_LIT> <EOL> method = u'<STR_LIT:GET>' <EOL> path = u'<STR_LIT>' <EOL> console . terse ( "<STR_LIT>" . format ( method , host , port , path ) ) <EOL> headers = odict ( [ ( u'<STR_LIT>' , u'<STR_LIT:application/json>' ) ] ) <EOL> request = clienting . Requester ( hostname = host , <EOL> port = port , <EOL> method = method , <EOL> path = path , <EOL> headers = headers ) <EOL> msgOut = request . build ( ) <EOL> lines = [ <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> ] <EOL> for i , line in enumerate ( lines ) : <EOL> self . assertEqual ( line , request . lines [ i ] ) <EOL> self . assertEqual ( request . head , b'<STR_LIT>' ) <EOL> self . assertEqual ( msgOut , request . head ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> beta . tx ( msgOut ) <EOL> while beta . txes and not ixBeta . rxbs : <EOL> beta . serviceTxes ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> alpha . serviceReceivesAllIx ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> msgIn = bytes ( ixBeta . rxbs ) <EOL> self . assertEqual ( msgIn , msgOut ) <EOL> ixBeta . clearRxbs ( ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> lines = [ <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> ] <EOL> msgOut = b'<STR_LIT>' . join ( lines ) <EOL> ixBeta . tx ( msgOut ) <EOL> while ixBeta . txes or not beta . rxbs : <EOL> alpha . serviceTxesAllIx ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . serviceReceives ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> msgIn = bytes ( beta . rxbs ) <EOL> self . assertEqual ( msgIn , msgOut ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> response = clienting . Respondent ( msg = beta . rxbs , method = method ) <EOL> lines = [ <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> ] <EOL> msgOut = b'<STR_LIT>' . join ( lines ) <EOL> ixBeta . tx ( msgOut ) <EOL> timer = Timer ( duration = <NUM_LIT:0.5> ) <EOL> while response . parser and not timer . expired : <EOL> alpha . serviceTxesAllIx ( ) <EOL> response . parse ( ) <EOL> beta . serviceReceives ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> if response . parser : <EOL> response . parser . close ( ) <EOL> response . parser = None <EOL> response . dictify ( ) <EOL> self . assertEqual ( len ( beta . rxbs ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( response . eventSource . retry , <NUM_LIT:1000> ) <EOL> self . assertEqual ( response . retry , response . eventSource . retry ) <EOL> self . assertTrue ( int ( response . eventSource . leid ) >= <NUM_LIT:2> ) <EOL> self . assertEqual ( response . leid , response . eventSource . leid ) <EOL> self . assertTrue ( len ( response . events ) > <NUM_LIT:2> ) <EOL> event = response . events . popleft ( ) <EOL> self . assertEqual ( event , { '<STR_LIT:id>' : '<STR_LIT:0>' , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:data>' : '<STR_LIT>' } ) <EOL> event = response . events . popleft ( ) <EOL> self . assertEqual ( event , { '<STR_LIT:id>' : '<STR_LIT:1>' , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:data>' : '<STR_LIT>' } ) <EOL> event = response . events . popleft ( ) <EOL> self . assertEqual ( event , { '<STR_LIT:id>' : '<STR_LIT:2>' , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:data>' : '<STR_LIT>' } ) <EOL> self . assertTrue ( len ( response . body ) == <NUM_LIT:0> ) <EOL> self . assertTrue ( len ( response . eventSource . raw ) == <NUM_LIT:0> ) <EOL> alpha . close ( ) <EOL> beta . close ( ) <EOL> wireLogAlpha . close ( ) <EOL> wireLogBeta . close ( ) <EOL> def testNonBlockingRequestStreamFancyJson ( self ) : <EOL> """<STR_LIT>""" <EOL> console . terse ( "<STR_LIT>" . format ( self . testNonBlockingRequestStreamFancyJson . __doc__ ) ) <EOL> wireLogAlpha = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogAlpha . reopen ( ) <EOL> wireLogBeta = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogBeta . reopen ( ) <EOL> alpha = tcp . Server ( port = <NUM_LIT> , bufsize = <NUM_LIT> , wlog = wireLogAlpha ) <EOL> self . assertIs ( alpha . reopen ( ) , True ) <EOL> self . assertEqual ( alpha . ha , ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEqual ( alpha . eha , ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> beta = tcp . Client ( ha = alpha . eha , bufsize = <NUM_LIT> , wlog = wireLogBeta ) <EOL> self . assertIs ( beta . reopen ( ) , True ) <EOL> self . assertIs ( beta . accepted , False ) <EOL> self . assertIs ( beta . connected , False ) <EOL> self . assertIs ( beta . cutoff , False ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> while True : <EOL> beta . serviceConnect ( ) <EOL> alpha . serviceConnects ( ) <EOL> if beta . connected and beta . ca in alpha . ixes : <EOL> break <EOL> time . sleep ( <NUM_LIT> ) <EOL> self . assertIs ( beta . accepted , True ) <EOL> self . assertIs ( beta . connected , True ) <EOL> self . assertIs ( beta . cutoff , False ) <EOL> self . assertEqual ( beta . ca , beta . cs . getsockname ( ) ) <EOL> self . assertEqual ( beta . ha , beta . cs . getpeername ( ) ) <EOL> self . assertEqual ( alpha . eha , beta . ha ) <EOL> ixBeta = alpha . ixes [ beta . ca ] <EOL> self . assertIsNotNone ( ixBeta . ca ) <EOL> self . assertIsNotNone ( ixBeta . cs ) <EOL> self . assertEqual ( ixBeta . cs . getsockname ( ) , beta . cs . getpeername ( ) ) <EOL> self . assertEqual ( ixBeta . cs . getpeername ( ) , beta . cs . getsockname ( ) ) <EOL> self . assertEqual ( ixBeta . ca , beta . ca ) <EOL> self . assertEqual ( ixBeta . ha , beta . ha ) <EOL> console . terse ( "<STR_LIT>" . format ( "<STR_LIT>" ) ) <EOL> host = u'<STR_LIT:127.0.0.1>' <EOL> port = <NUM_LIT> <EOL> method = u'<STR_LIT:GET>' <EOL> path = u'<STR_LIT>' <EOL> console . terse ( "<STR_LIT>" . format ( method , host , port , path ) ) <EOL> headers = odict ( [ ( u'<STR_LIT>' , u'<STR_LIT:application/json>' ) ] ) <EOL> request = clienting . Requester ( hostname = host , <EOL> port = port , <EOL> method = method , <EOL> path = path , <EOL> headers = headers ) <EOL> msgOut = request . build ( ) <EOL> lines = [ <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> ] <EOL> for i , line in enumerate ( lines ) : <EOL> self . assertEqual ( line , request . lines [ i ] ) <EOL> self . assertEqual ( request . head , b'<STR_LIT>' ) <EOL> self . assertEqual ( msgOut , request . head ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> beta . tx ( msgOut ) <EOL> while beta . txes and not ixBeta . rxbs : <EOL> beta . serviceTxes ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> alpha . serviceReceivesAllIx ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> msgIn = bytes ( ixBeta . rxbs ) <EOL> self . assertEqual ( msgIn , msgOut ) <EOL> ixBeta . clearRxbs ( ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> lines = [ <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> ] <EOL> msgOut = b'<STR_LIT>' . join ( lines ) <EOL> ixBeta . tx ( msgOut ) <EOL> while ixBeta . txes or not beta . rxbs : <EOL> alpha . serviceTxesAllIx ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . serviceReceives ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> msgIn = bytes ( beta . rxbs ) <EOL> self . assertEqual ( msgIn , msgOut ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> response = clienting . Respondent ( msg = beta . rxbs , <EOL> method = method , <EOL> dictable = True , <EOL> ) <EOL> lines = [ <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> ] <EOL> msgOut = b'<STR_LIT>' . join ( lines ) <EOL> ixBeta . tx ( msgOut ) <EOL> timer = Timer ( duration = <NUM_LIT:0.5> ) <EOL> while response . parser and not timer . expired : <EOL> alpha . serviceTxesAllIx ( ) <EOL> response . parse ( ) <EOL> beta . serviceReceives ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> if response . parser : <EOL> response . parser . close ( ) <EOL> response . parser = None <EOL> self . assertEqual ( len ( beta . rxbs ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( response . eventSource . retry , <NUM_LIT:1000> ) <EOL> self . assertEqual ( response . retry , response . eventSource . retry ) <EOL> self . assertTrue ( int ( response . eventSource . leid ) >= <NUM_LIT:2> ) <EOL> self . assertEqual ( response . leid , response . eventSource . leid ) <EOL> self . assertTrue ( len ( response . events ) > <NUM_LIT:2> ) <EOL> event = response . events . popleft ( ) <EOL> self . assertEqual ( event , { '<STR_LIT:id>' : '<STR_LIT:0>' , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:data>' : '<STR_LIT>' } ) <EOL> event = response . events . popleft ( ) <EOL> self . assertEqual ( event , { '<STR_LIT:id>' : '<STR_LIT:1>' , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:data>' : { '<STR_LIT:count>' : <NUM_LIT:1> } } ) <EOL> event = response . events . popleft ( ) <EOL> self . assertEqual ( event , { '<STR_LIT:id>' : '<STR_LIT:2>' , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:data>' : { '<STR_LIT:count>' : <NUM_LIT:2> } } ) <EOL> self . assertTrue ( len ( response . body ) == <NUM_LIT:0> ) <EOL> self . assertTrue ( len ( response . eventSource . raw ) == <NUM_LIT:0> ) <EOL> alpha . close ( ) <EOL> beta . close ( ) <EOL> wireLogAlpha . close ( ) <EOL> wireLogBeta . close ( ) <EOL> def testNonBlockingRequestStreamFancyJsonChunked ( self ) : <EOL> """<STR_LIT>""" <EOL> console . terse ( "<STR_LIT>" . format ( self . testNonBlockingRequestStreamFancyJsonChunked . __doc__ ) ) <EOL> wireLogAlpha = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogAlpha . reopen ( ) <EOL> wireLogBeta = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogBeta . reopen ( ) <EOL> alpha = tcp . Server ( port = <NUM_LIT> , bufsize = <NUM_LIT> , wlog = wireLogAlpha ) <EOL> self . assertIs ( alpha . reopen ( ) , True ) <EOL> self . assertEqual ( alpha . ha , ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEqual ( alpha . eha , ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> beta = tcp . Client ( ha = alpha . eha , bufsize = <NUM_LIT> , wlog = wireLogBeta ) <EOL> self . assertIs ( beta . reopen ( ) , True ) <EOL> self . assertIs ( beta . accepted , False ) <EOL> self . assertIs ( beta . connected , False ) <EOL> self . assertIs ( beta . cutoff , False ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> while True : <EOL> beta . serviceConnect ( ) <EOL> alpha . serviceConnects ( ) <EOL> if beta . accepted and beta . ca in alpha . ixes : <EOL> break <EOL> time . sleep ( <NUM_LIT> ) <EOL> self . assertIs ( beta . accepted , True ) <EOL> self . assertIs ( beta . connected , True ) <EOL> self . assertIs ( beta . cutoff , False ) <EOL> self . assertEqual ( beta . ca , beta . cs . getsockname ( ) ) <EOL> self . assertEqual ( beta . ha , beta . cs . getpeername ( ) ) <EOL> self . assertEqual ( alpha . eha , beta . ha ) <EOL> ixBeta = alpha . ixes [ beta . ca ] <EOL> self . assertIsNotNone ( ixBeta . ca ) <EOL> self . assertIsNotNone ( ixBeta . cs ) <EOL> self . assertEqual ( ixBeta . cs . getsockname ( ) , beta . cs . getpeername ( ) ) <EOL> self . assertEqual ( ixBeta . cs . getpeername ( ) , beta . cs . getsockname ( ) ) <EOL> self . assertEqual ( ixBeta . ca , beta . ca ) <EOL> self . assertEqual ( ixBeta . ha , beta . ha ) <EOL> console . terse ( "<STR_LIT>" . format ( "<STR_LIT>" ) ) <EOL> host = u'<STR_LIT:127.0.0.1>' <EOL> port = <NUM_LIT> <EOL> method = u'<STR_LIT:GET>' <EOL> path = u'<STR_LIT>' <EOL> console . terse ( "<STR_LIT>" . format ( method , host , port , path ) ) <EOL> headers = odict ( [ ( u'<STR_LIT>' , u'<STR_LIT:application/json>' ) ] ) <EOL> request = clienting . Requester ( hostname = host , <EOL> port = port , <EOL> method = method , <EOL> path = path , <EOL> headers = headers ) <EOL> msgOut = request . build ( ) <EOL> lines = [ <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> ] <EOL> for i , line in enumerate ( lines ) : <EOL> self . assertEqual ( line , request . lines [ i ] ) <EOL> self . assertEqual ( request . head , b'<STR_LIT>' ) <EOL> self . assertEqual ( msgOut , request . head ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> beta . tx ( msgOut ) <EOL> while beta . txes and not ixBeta . rxbs : <EOL> beta . serviceTxes ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> alpha . serviceReceivesAllIx ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> msgIn = bytes ( ixBeta . rxbs ) <EOL> self . assertEqual ( msgIn , msgOut ) <EOL> ixBeta . clearRxbs ( ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> lines = [ <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> ] <EOL> msgOut = b'<STR_LIT>' . join ( lines ) <EOL> ixBeta . tx ( msgOut ) <EOL> while ixBeta . txes or not beta . rxbs : <EOL> alpha . serviceTxesAllIx ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . serviceReceives ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> msgIn = bytes ( beta . rxbs ) <EOL> self . assertEqual ( msgIn , msgOut ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> response = clienting . Respondent ( msg = beta . rxbs , <EOL> method = method , <EOL> dictable = True ) <EOL> lines = [ <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> ] <EOL> msgOut = b'<STR_LIT>' . join ( lines ) <EOL> ixBeta . tx ( msgOut ) <EOL> timer = Timer ( duration = <NUM_LIT:0.5> ) <EOL> while response . parser and not timer . expired : <EOL> alpha . serviceTxesAllIx ( ) <EOL> response . parse ( ) <EOL> beta . serviceReceives ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> if response . parser : <EOL> response . parser . close ( ) <EOL> response . parser = None <EOL> response . dictify ( ) <EOL> self . assertEqual ( len ( beta . rxbs ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( response . eventSource . retry , <NUM_LIT:1000> ) <EOL> self . assertEqual ( response . retry , response . eventSource . retry ) <EOL> self . assertTrue ( int ( response . eventSource . leid ) >= <NUM_LIT:2> ) <EOL> self . assertEqual ( response . leid , response . eventSource . leid ) <EOL> self . assertTrue ( len ( response . events ) > <NUM_LIT:2> ) <EOL> event = response . events . popleft ( ) <EOL> self . assertEqual ( event , { '<STR_LIT:id>' : '<STR_LIT:0>' , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:data>' : '<STR_LIT>' } ) <EOL> event = response . events . popleft ( ) <EOL> self . assertEqual ( event , { '<STR_LIT:id>' : '<STR_LIT:1>' , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:data>' : { '<STR_LIT:count>' : <NUM_LIT:1> } } ) <EOL> event = response . events . popleft ( ) <EOL> self . assertEqual ( event , { '<STR_LIT:id>' : '<STR_LIT:2>' , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:data>' : { '<STR_LIT:count>' : <NUM_LIT:2> } } ) <EOL> self . assertTrue ( len ( response . body ) == <NUM_LIT:0> ) <EOL> self . assertTrue ( len ( response . eventSource . raw ) == <NUM_LIT:0> ) <EOL> alpha . close ( ) <EOL> beta . close ( ) <EOL> wireLogAlpha . close ( ) <EOL> wireLogBeta . close ( ) <EOL> def testNonBlockingRequestEchoTLS ( self ) : <EOL> """<STR_LIT>""" <EOL> console . terse ( "<STR_LIT>" . format ( self . testNonBlockingRequestEchoTLS . __doc__ ) ) <EOL> wireLogAlpha = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogAlpha . reopen ( ) <EOL> wireLogBeta = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogBeta . reopen ( ) <EOL> serverKeypath = '<STR_LIT>' <EOL> serverCertpath = '<STR_LIT>' <EOL> clientCafilepath = '<STR_LIT>' <EOL> clientKeypath = '<STR_LIT>' <EOL> clientCertpath = '<STR_LIT>' <EOL> serverCafilepath = '<STR_LIT>' <EOL> alpha = tcp . ServerTls ( host = '<STR_LIT:localhost>' , <EOL> port = <NUM_LIT> , <EOL> bufsize = <NUM_LIT> , <EOL> wlog = wireLogAlpha , <EOL> context = None , <EOL> version = None , <EOL> certify = None , <EOL> keypath = serverKeypath , <EOL> certpath = serverCertpath , <EOL> cafilepath = clientCafilepath , <EOL> ) <EOL> self . assertIs ( alpha . reopen ( ) , True ) <EOL> self . assertEqual ( alpha . ha , ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> self . assertEqual ( alpha . eha , ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> serverCertCommonName = '<STR_LIT:localhost>' <EOL> beta = tcp . ClientTls ( ha = alpha . ha , <EOL> bufsize = <NUM_LIT> , <EOL> wlog = wireLogBeta , <EOL> context = None , <EOL> version = None , <EOL> certify = None , <EOL> hostify = None , <EOL> certedhost = serverCertCommonName , <EOL> keypath = clientKeypath , <EOL> certpath = clientCertpath , <EOL> cafilepath = serverCafilepath , <EOL> ) <EOL> self . assertIs ( beta . reopen ( ) , True ) <EOL> self . assertIs ( beta . accepted , False ) <EOL> self . assertIs ( beta . connected , False ) <EOL> self . assertIs ( beta . cutoff , False ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> while True : <EOL> beta . serviceConnect ( ) <EOL> alpha . serviceConnects ( ) <EOL> if beta . connected and len ( alpha . ixes ) >= <NUM_LIT:1> : <EOL> break <EOL> time . sleep ( <NUM_LIT> ) <EOL> self . assertIs ( beta . accepted , True ) <EOL> self . assertIs ( beta . connected , True ) <EOL> self . assertIs ( beta . cutoff , False ) <EOL> self . assertEqual ( beta . ca , beta . cs . getsockname ( ) ) <EOL> self . assertEqual ( beta . ha , beta . cs . getpeername ( ) ) <EOL> self . assertIs ( beta . connected , True ) <EOL> ixBeta = alpha . ixes [ beta . ca ] <EOL> self . assertIsNotNone ( ixBeta . ca ) <EOL> self . assertIsNotNone ( ixBeta . cs ) <EOL> self . assertEqual ( ixBeta . cs . getsockname ( ) , beta . cs . getpeername ( ) ) <EOL> self . assertEqual ( ixBeta . cs . getpeername ( ) , beta . cs . getsockname ( ) ) <EOL> self . assertEqual ( ixBeta . ca , beta . ca ) <EOL> self . assertEqual ( ixBeta . ha , beta . ha ) <EOL> console . terse ( "<STR_LIT>" . format ( "<STR_LIT>" ) ) <EOL> host = u'<STR_LIT:127.0.0.1>' <EOL> port = <NUM_LIT> <EOL> method = u'<STR_LIT:GET>' <EOL> path = u'<STR_LIT>' <EOL> console . terse ( "<STR_LIT>" . format ( method , host , port , path ) ) <EOL> headers = odict ( [ ( u'<STR_LIT>' , u'<STR_LIT:application/json>' ) ] ) <EOL> request = clienting . Requester ( hostname = host , <EOL> port = port , <EOL> method = method , <EOL> path = path , <EOL> headers = headers ) <EOL> msgOut = request . build ( ) <EOL> lines = [ <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> ] <EOL> for i , line in enumerate ( lines ) : <EOL> self . assertEqual ( line , request . lines [ i ] ) <EOL> self . assertEqual ( request . head , b'<STR_LIT>' ) <EOL> self . assertEqual ( msgOut , b'<STR_LIT>' ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> beta . tx ( msgOut ) <EOL> while beta . txes and not ixBeta . rxbs : <EOL> beta . serviceTxes ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> alpha . serviceReceivesAllIx ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> msgIn = bytes ( ixBeta . rxbs ) <EOL> self . assertEqual ( msgIn , msgOut ) <EOL> ixBeta . clearRxbs ( ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> msgOut = b'<STR_LIT>' <EOL> ixBeta . tx ( msgOut ) <EOL> while ixBeta . txes or not beta . rxbs : <EOL> alpha . serviceTxesAllIx ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . serviceReceives ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> msgIn = bytes ( beta . rxbs ) <EOL> self . assertEqual ( msgIn , msgOut ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> response = clienting . Respondent ( msg = beta . rxbs , method = method ) <EOL> while response . parser : <EOL> response . parse ( ) <EOL> response . dictify ( ) <EOL> self . assertEqual ( bytes ( response . body ) , b'<STR_LIT>' ) <EOL> self . assertEqual ( response . data , { '<STR_LIT:action>' : None , <EOL> '<STR_LIT:content>' : None , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT:url>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' } <EOL> ) <EOL> self . assertEqual ( len ( beta . rxbs ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( response . headers . items ( ) , [ ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT:application/json>' ) , <EOL> ( '<STR_LIT:date>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) ] ) <EOL> alpha . close ( ) <EOL> beta . close ( ) <EOL> wireLogAlpha . close ( ) <EOL> wireLogBeta . close ( ) <EOL> def testPatronRequestEcho ( self ) : <EOL> """<STR_LIT>""" <EOL> console . terse ( "<STR_LIT>" . format ( self . testPatronRequestEcho . __doc__ ) ) <EOL> wireLogAlpha = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogAlpha . reopen ( ) <EOL> alpha = tcp . Server ( port = <NUM_LIT> , bufsize = <NUM_LIT> , wlog = wireLogAlpha ) <EOL> self . assertIs ( alpha . reopen ( ) , True ) <EOL> self . assertEqual ( alpha . ha , ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEqual ( alpha . eha , ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> console . terse ( "<STR_LIT>" . format ( "<STR_LIT>" ) ) <EOL> wireLogBeta = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogBeta . reopen ( ) <EOL> host = alpha . eha [ <NUM_LIT:0> ] <EOL> port = alpha . eha [ <NUM_LIT:1> ] <EOL> method = u'<STR_LIT:GET>' <EOL> path = u'<STR_LIT>' <EOL> headers = odict ( [ ( u'<STR_LIT>' , u'<STR_LIT:application/json>' ) ] ) <EOL> beta = clienting . Patron ( bufsize = <NUM_LIT> , <EOL> wlog = wireLogBeta , <EOL> hostname = host , <EOL> port = port , <EOL> method = method , <EOL> path = path , <EOL> headers = headers , <EOL> ) <EOL> self . assertIs ( beta . connector . reopen ( ) , True ) <EOL> self . assertIs ( beta . connector . accepted , False ) <EOL> self . assertIs ( beta . connector . connected , False ) <EOL> self . assertIs ( beta . connector . cutoff , False ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> while True : <EOL> beta . connector . serviceConnect ( ) <EOL> alpha . serviceConnects ( ) <EOL> if beta . connector . connected and beta . connector . ca in alpha . ixes : <EOL> break <EOL> time . sleep ( <NUM_LIT> ) <EOL> self . assertIs ( beta . connector . accepted , True ) <EOL> self . assertIs ( beta . connector . connected , True ) <EOL> self . assertIs ( beta . connector . cutoff , False ) <EOL> self . assertEqual ( beta . connector . ca , beta . connector . cs . getsockname ( ) ) <EOL> self . assertEqual ( beta . connector . ha , beta . connector . cs . getpeername ( ) ) <EOL> self . assertEqual ( alpha . eha , beta . connector . ha ) <EOL> ixBeta = alpha . ixes [ beta . connector . ca ] <EOL> self . assertIsNotNone ( ixBeta . ca ) <EOL> self . assertIsNotNone ( ixBeta . cs ) <EOL> self . assertEqual ( ixBeta . cs . getsockname ( ) , beta . connector . cs . getpeername ( ) ) <EOL> self . assertEqual ( ixBeta . cs . getpeername ( ) , beta . connector . cs . getsockname ( ) ) <EOL> self . assertEqual ( ixBeta . ca , beta . connector . ca ) <EOL> self . assertEqual ( ixBeta . ha , beta . connector . ha ) <EOL> msgOut = beta . requester . build ( ) <EOL> lines = [ <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> ] <EOL> for i , line in enumerate ( lines ) : <EOL> self . assertEqual ( line , beta . requester . lines [ i ] ) <EOL> self . assertEqual ( beta . requester . head , b'<STR_LIT>' ) <EOL> self . assertEqual ( msgOut , b'<STR_LIT>' ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> console . terse ( "<STR_LIT>" . format ( method , host , port , path ) ) <EOL> beta . connector . tx ( msgOut ) <EOL> while beta . connector . txes and not ixBeta . rxbs : <EOL> beta . connector . serviceTxes ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> alpha . serviceReceivesAllIx ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> msgIn = bytes ( ixBeta . rxbs ) <EOL> self . assertEqual ( msgIn , msgOut ) <EOL> ixBeta . clearRxbs ( ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> msgOut = b'<STR_LIT>' <EOL> ixBeta . tx ( msgOut ) <EOL> while ixBeta . txes or not beta . connector . rxbs : <EOL> alpha . serviceTxesAllIx ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . connector . serviceReceives ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> msgIn = bytes ( beta . connector . rxbs ) <EOL> self . assertEqual ( msgIn , msgOut ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> while beta . respondent . parser : <EOL> beta . respondent . parse ( ) <EOL> beta . respondent . dictify ( ) <EOL> self . assertEqual ( bytes ( beta . respondent . body ) , b'<STR_LIT>' ) <EOL> self . assertEqual ( beta . respondent . data , { '<STR_LIT:action>' : None , <EOL> '<STR_LIT:content>' : None , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT:url>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' } <EOL> ) <EOL> self . assertEqual ( len ( beta . connector . rxbs ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( beta . respondent . headers . items ( ) , [ ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT:application/json>' ) , <EOL> ( '<STR_LIT:date>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) ] ) <EOL> alpha . close ( ) <EOL> beta . connector . close ( ) <EOL> wireLogAlpha . close ( ) <EOL> wireLogBeta . close ( ) <EOL> def testPatronServiceEcho ( self ) : <EOL> """<STR_LIT>""" <EOL> console . terse ( "<STR_LIT>" . format ( self . testPatronServiceEcho . __doc__ ) ) <EOL> wireLogAlpha = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogAlpha . reopen ( ) <EOL> alpha = tcp . Server ( port = <NUM_LIT> , bufsize = <NUM_LIT> , wlog = wireLogAlpha ) <EOL> self . assertIs ( alpha . reopen ( ) , True ) <EOL> self . assertEqual ( alpha . ha , ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEqual ( alpha . eha , ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> console . terse ( "<STR_LIT>" . format ( "<STR_LIT>" ) ) <EOL> wireLogBeta = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogBeta . reopen ( ) <EOL> host = alpha . eha [ <NUM_LIT:0> ] <EOL> port = alpha . eha [ <NUM_LIT:1> ] <EOL> method = u'<STR_LIT:GET>' <EOL> path = u'<STR_LIT>' <EOL> headers = odict ( [ ( u'<STR_LIT>' , u'<STR_LIT:application/json>' ) ] ) <EOL> beta = clienting . Patron ( bufsize = <NUM_LIT> , <EOL> wlog = wireLogBeta , <EOL> hostname = host , <EOL> port = port , <EOL> method = method , <EOL> path = path , <EOL> headers = headers , <EOL> ) <EOL> self . assertIs ( beta . connector . reopen ( ) , True ) <EOL> self . assertIs ( beta . connector . accepted , False ) <EOL> self . assertIs ( beta . connector . connected , False ) <EOL> self . assertIs ( beta . connector . cutoff , False ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> while True : <EOL> beta . connector . serviceConnect ( ) <EOL> alpha . serviceConnects ( ) <EOL> if beta . connector . connected and beta . connector . ca in alpha . ixes : <EOL> break <EOL> time . sleep ( <NUM_LIT> ) <EOL> self . assertIs ( beta . connector . accepted , True ) <EOL> self . assertIs ( beta . connector . connected , True ) <EOL> self . assertIs ( beta . connector . cutoff , False ) <EOL> self . assertEqual ( beta . connector . ca , beta . connector . cs . getsockname ( ) ) <EOL> self . assertEqual ( beta . connector . ha , beta . connector . cs . getpeername ( ) ) <EOL> self . assertEqual ( alpha . eha , beta . connector . ha ) <EOL> ixBeta = alpha . ixes [ beta . connector . ca ] <EOL> self . assertIsNotNone ( ixBeta . ca ) <EOL> self . assertIsNotNone ( ixBeta . cs ) <EOL> self . assertEqual ( ixBeta . cs . getsockname ( ) , beta . connector . cs . getpeername ( ) ) <EOL> self . assertEqual ( ixBeta . cs . getpeername ( ) , beta . connector . cs . getsockname ( ) ) <EOL> self . assertEqual ( ixBeta . ca , beta . connector . ca ) <EOL> self . assertEqual ( ixBeta . ha , beta . connector . ha ) <EOL> beta . transmit ( ) <EOL> lines = [ <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> ] <EOL> for i , line in enumerate ( lines ) : <EOL> self . assertEqual ( line , beta . requester . lines [ i ] ) <EOL> msgOut = beta . connector . txes [ <NUM_LIT:0> ] <EOL> self . assertEqual ( beta . requester . head , b'<STR_LIT>' ) <EOL> self . assertEqual ( msgOut , b'<STR_LIT>' ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> console . terse ( "<STR_LIT>" . format ( method , host , port , path ) ) <EOL> while beta . connector . txes and not ixBeta . rxbs : <EOL> beta . serviceAll ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> alpha . serviceReceivesAllIx ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> msgIn = bytes ( ixBeta . rxbs ) <EOL> self . assertEqual ( msgIn , msgOut ) <EOL> ixBeta . clearRxbs ( ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> msgOut = b'<STR_LIT>' <EOL> ixBeta . tx ( msgOut ) <EOL> while ixBeta . txes or not beta . respondent . ended : <EOL> alpha . serviceTxesAllIx ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . serviceAll ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> self . assertEqual ( len ( beta . connector . rxbs ) , <NUM_LIT:0> ) <EOL> self . assertIs ( beta . waited , False ) <EOL> self . assertIs ( beta . respondent . ended , True ) <EOL> self . assertEqual ( len ( beta . responses ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( bytes ( beta . respondent . body ) , b'<STR_LIT>' ) <EOL> self . assertEqual ( beta . respondent . data , { '<STR_LIT:action>' : None , <EOL> '<STR_LIT:content>' : None , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT:url>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' } <EOL> ) <EOL> self . assertEqual ( len ( beta . connector . rxbs ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( beta . respondent . headers . items ( ) , [ ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT:application/json>' ) , <EOL> ( '<STR_LIT:date>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) ] ) <EOL> alpha . close ( ) <EOL> beta . connector . close ( ) <EOL> wireLogAlpha . close ( ) <EOL> wireLogBeta . close ( ) <EOL> def testPatronPipelineEcho ( self ) : <EOL> """<STR_LIT>""" <EOL> console . terse ( "<STR_LIT>" . format ( self . testPatronPipelineEcho . __doc__ ) ) <EOL> wireLogAlpha = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogAlpha . reopen ( ) <EOL> alpha = tcp . Server ( port = <NUM_LIT> , bufsize = <NUM_LIT> , wlog = wireLogAlpha ) <EOL> self . assertIs ( alpha . reopen ( ) , True ) <EOL> self . assertEqual ( alpha . ha , ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEqual ( alpha . eha , ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> console . terse ( "<STR_LIT>" . format ( "<STR_LIT>" ) ) <EOL> wireLogBeta = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogBeta . reopen ( ) <EOL> host = alpha . eha [ <NUM_LIT:0> ] <EOL> port = alpha . eha [ <NUM_LIT:1> ] <EOL> beta = clienting . Patron ( bufsize = <NUM_LIT> , <EOL> wlog = wireLogBeta , <EOL> hostname = host , <EOL> port = port , <EOL> reconnectable = True , <EOL> ) <EOL> self . assertIs ( beta . connector . reopen ( ) , True ) <EOL> self . assertIs ( beta . connector . accepted , False ) <EOL> self . assertIs ( beta . connector . connected , False ) <EOL> self . assertIs ( beta . connector . cutoff , False ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> while True : <EOL> beta . connector . serviceConnect ( ) <EOL> alpha . serviceConnects ( ) <EOL> if beta . connector . connected and beta . connector . ca in alpha . ixes : <EOL> break <EOL> time . sleep ( <NUM_LIT> ) <EOL> self . assertIs ( beta . connector . accepted , True ) <EOL> self . assertIs ( beta . connector . connected , True ) <EOL> self . assertIs ( beta . connector . cutoff , False ) <EOL> self . assertEqual ( beta . connector . ca , beta . connector . cs . getsockname ( ) ) <EOL> self . assertEqual ( beta . connector . ha , beta . connector . cs . getpeername ( ) ) <EOL> self . assertEqual ( alpha . eha , beta . connector . ha ) <EOL> ixBeta = alpha . ixes [ beta . connector . ca ] <EOL> self . assertIsNotNone ( ixBeta . ca ) <EOL> self . assertIsNotNone ( ixBeta . cs ) <EOL> self . assertEqual ( ixBeta . cs . getsockname ( ) , beta . connector . cs . getpeername ( ) ) <EOL> self . assertEqual ( ixBeta . cs . getpeername ( ) , beta . connector . cs . getsockname ( ) ) <EOL> self . assertEqual ( ixBeta . ca , beta . connector . ca ) <EOL> self . assertEqual ( ixBeta . ha , beta . connector . ha ) <EOL> request = odict ( [ ( '<STR_LIT>' , u'<STR_LIT:GET>' ) , <EOL> ( '<STR_LIT:path>' , u'<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , odict ( ) ) , <EOL> ( '<STR_LIT>' , u'<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , odict ( [ ( '<STR_LIT>' , '<STR_LIT:application/json>' ) ] ) ) , <EOL> ( '<STR_LIT:body>' , None ) , <EOL> ] ) <EOL> beta . requests . append ( request ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> console . terse ( "<STR_LIT>" . format ( beta . connector . ha [ <NUM_LIT:0> ] , <EOL> beta . connector . ha [ <NUM_LIT:1> ] , <EOL> request [ '<STR_LIT>' ] , <EOL> request [ '<STR_LIT:path>' ] ) ) <EOL> while ( beta . requests or beta . connector . txes ) and not ixBeta . rxbs : <EOL> beta . serviceAll ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> alpha . serviceReceivesAllIx ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> msgIn = bytes ( ixBeta . rxbs ) <EOL> msgOut = b'<STR_LIT>' <EOL> self . assertEqual ( msgIn , msgOut ) <EOL> ixBeta . clearRxbs ( ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> msgOut = b'<STR_LIT>' <EOL> ixBeta . tx ( msgOut ) <EOL> while ixBeta . txes or not beta . respondent . ended : <EOL> alpha . serviceTxesAllIx ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . serviceAll ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> self . assertEqual ( len ( beta . connector . rxbs ) , <NUM_LIT:0> ) <EOL> self . assertIs ( beta . waited , False ) <EOL> self . assertIs ( beta . respondent . ended , True ) <EOL> self . assertEqual ( len ( beta . responses ) , <NUM_LIT:1> ) <EOL> response = beta . responses . popleft ( ) <EOL> self . assertEqual ( response , { '<STR_LIT:version>' : ( <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> '<STR_LIT:status>' : <NUM_LIT:200> , <EOL> '<STR_LIT>' : '<STR_LIT:OK>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:application/json>' , <EOL> '<STR_LIT:date>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT:body>' : bytearray ( b'<STR_LIT>' ) , <EOL> '<STR_LIT:data>' : { '<STR_LIT:action>' : None , <EOL> '<STR_LIT:content>' : None , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT:url>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' } , <EOL> '<STR_LIT:error>' : None , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT:host>' : '<STR_LIT:127.0.0.1>' , <EOL> '<STR_LIT:port>' : <NUM_LIT> , <EOL> '<STR_LIT>' : '<STR_LIT:http>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' , <EOL> '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT:application/json>' } , <EOL> '<STR_LIT:body>' : b'<STR_LIT>' , <EOL> '<STR_LIT:data>' : None , <EOL> '<STR_LIT>' : None , <EOL> } <EOL> } ) <EOL> beta . requests . append ( request ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> console . terse ( "<STR_LIT>" . format ( beta . connector . ha [ <NUM_LIT:0> ] , <EOL> beta . connector . ha [ <NUM_LIT:1> ] , <EOL> request [ '<STR_LIT>' ] , <EOL> request [ '<STR_LIT:path>' ] ) ) <EOL> while ( beta . requests or beta . connector . txes ) and not ixBeta . rxbs : <EOL> beta . serviceAll ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> alpha . serviceReceivesAllIx ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> msgIn = bytes ( ixBeta . rxbs ) <EOL> msgOut = b'<STR_LIT>' <EOL> self . assertEqual ( msgIn , msgOut ) <EOL> ixBeta . clearRxbs ( ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> msgOut = b'<STR_LIT>' <EOL> ixBeta . tx ( msgOut ) <EOL> while ixBeta . txes or not beta . respondent . ended : <EOL> alpha . serviceTxesAllIx ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . serviceAll ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> self . assertEqual ( len ( beta . connector . rxbs ) , <NUM_LIT:0> ) <EOL> self . assertIs ( beta . waited , False ) <EOL> self . assertIs ( beta . respondent . ended , True ) <EOL> self . assertEqual ( len ( beta . responses ) , <NUM_LIT:1> ) <EOL> response = beta . responses . popleft ( ) <EOL> self . assertEqual ( response , { '<STR_LIT:version>' : ( <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> '<STR_LIT:status>' : <NUM_LIT:200> , <EOL> '<STR_LIT>' : '<STR_LIT:OK>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:application/json>' , <EOL> '<STR_LIT:date>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT:body>' : bytearray ( b'<STR_LIT>' ) , <EOL> '<STR_LIT:data>' : { '<STR_LIT:action>' : None , <EOL> '<STR_LIT:content>' : None , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT:url>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' } , <EOL> '<STR_LIT:error>' : None , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : { '<STR_LIT:host>' : '<STR_LIT:127.0.0.1>' , <EOL> '<STR_LIT:port>' : <NUM_LIT> , <EOL> '<STR_LIT>' : '<STR_LIT:http>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' , <EOL> '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT:application/json>' } , <EOL> '<STR_LIT:body>' : b'<STR_LIT>' , <EOL> '<STR_LIT:data>' : None , <EOL> '<STR_LIT>' : None , <EOL> } <EOL> } ) <EOL> alpha . close ( ) <EOL> beta . connector . close ( ) <EOL> wireLogAlpha . close ( ) <EOL> wireLogBeta . close ( ) <EOL> def mockEchoService ( self , server ) : <EOL> """<STR_LIT>""" <EOL> server . serviceConnects ( ) <EOL> if server . ixes : <EOL> server . serviceReceivesAllIx ( ) <EOL> ixClient = server . ixes . values ( ) [ <NUM_LIT:0> ] <EOL> msgIn = bytes ( ixClient . rxbs ) <EOL> if msgIn == b'<STR_LIT>' : <EOL> ixClient . clearRxbs ( ) <EOL> msgOut = b'<STR_LIT>' <EOL> ixClient . tx ( msgOut ) <EOL> msgIn = b'<STR_LIT>' <EOL> msgOut = b'<STR_LIT>' <EOL> server . serviceTxesAllIx ( ) <EOL> def testPatronPipelineEchoSimple ( self ) : <EOL> """<STR_LIT>""" <EOL> console . terse ( "<STR_LIT>" . format ( self . testPatronPipelineEchoSimple . __doc__ ) ) <EOL> wireLogAlpha = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogAlpha . reopen ( ) <EOL> alpha = tcp . Server ( port = <NUM_LIT> , bufsize = <NUM_LIT> , wlog = wireLogAlpha ) <EOL> self . assertIs ( alpha . reopen ( ) , True ) <EOL> self . assertEqual ( alpha . ha , ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEqual ( alpha . eha , ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> console . terse ( "<STR_LIT>" . format ( "<STR_LIT>" ) ) <EOL> wireLogBeta = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogBeta . reopen ( ) <EOL> host = alpha . eha [ <NUM_LIT:0> ] <EOL> port = alpha . eha [ <NUM_LIT:1> ] <EOL> beta = clienting . Patron ( bufsize = <NUM_LIT> , <EOL> wlog = wireLogBeta , <EOL> hostname = host , <EOL> port = port , <EOL> reconnectable = True , <EOL> ) <EOL> self . assertIs ( beta . connector . reopen ( ) , True ) <EOL> self . assertIs ( beta . connector . accepted , False ) <EOL> self . assertIs ( beta . connector . connected , False ) <EOL> self . assertIs ( beta . connector . cutoff , False ) <EOL> request = odict ( [ ( '<STR_LIT>' , u'<STR_LIT:GET>' ) , <EOL> ( '<STR_LIT:path>' , u'<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , odict ( ) ) , <EOL> ( '<STR_LIT>' , u'<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , odict ( [ ( '<STR_LIT>' , '<STR_LIT:application/json>' ) ] ) ) , <EOL> ( '<STR_LIT:body>' , None ) , <EOL> ] ) <EOL> beta . requests . append ( request ) <EOL> while ( not alpha . ixes or beta . requests or <EOL> beta . connector . txes or not beta . respondent . ended ) : <EOL> self . mockEchoService ( alpha ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . serviceAll ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> self . assertEqual ( len ( beta . connector . rxbs ) , <NUM_LIT:0> ) <EOL> self . assertIs ( beta . waited , False ) <EOL> self . assertIs ( beta . respondent . ended , True ) <EOL> self . assertEqual ( len ( beta . responses ) , <NUM_LIT:1> ) <EOL> response = beta . responses . popleft ( ) <EOL> self . assertEqual ( response , { '<STR_LIT:version>' : ( <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> '<STR_LIT:status>' : <NUM_LIT:200> , <EOL> '<STR_LIT>' : '<STR_LIT:OK>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:application/json>' , <EOL> '<STR_LIT:date>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT:body>' : bytearray ( b'<STR_LIT>' ) , <EOL> '<STR_LIT:data>' : { '<STR_LIT:action>' : None , <EOL> '<STR_LIT:content>' : None , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT:url>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' } , <EOL> '<STR_LIT:error>' : None , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT:host>' : '<STR_LIT:127.0.0.1>' , <EOL> '<STR_LIT:port>' : <NUM_LIT> , <EOL> '<STR_LIT>' : '<STR_LIT:http>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' , <EOL> '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT:application/json>' } , <EOL> '<STR_LIT:body>' : b'<STR_LIT>' , <EOL> '<STR_LIT:data>' : None , <EOL> '<STR_LIT>' : None , <EOL> } <EOL> } ) <EOL> beta . requests . append ( request ) <EOL> while ( not alpha . ixes or beta . requests or <EOL> beta . connector . txes or not beta . respondent . ended ) : <EOL> self . mockEchoService ( alpha ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . serviceAll ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> self . assertEqual ( len ( beta . connector . rxbs ) , <NUM_LIT:0> ) <EOL> self . assertIs ( beta . waited , False ) <EOL> self . assertIs ( beta . respondent . ended , True ) <EOL> self . assertEqual ( len ( beta . responses ) , <NUM_LIT:1> ) <EOL> response = beta . responses . popleft ( ) <EOL> self . assertEqual ( response , { '<STR_LIT:version>' : ( <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> '<STR_LIT:status>' : <NUM_LIT:200> , <EOL> '<STR_LIT>' : '<STR_LIT:OK>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:application/json>' , <EOL> '<STR_LIT:date>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT:body>' : bytearray ( b'<STR_LIT>' ) , <EOL> '<STR_LIT:data>' : { '<STR_LIT:action>' : None , <EOL> '<STR_LIT:content>' : None , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT:url>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' } , <EOL> '<STR_LIT:error>' : None , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT:host>' : '<STR_LIT:127.0.0.1>' , <EOL> '<STR_LIT:port>' : <NUM_LIT> , <EOL> '<STR_LIT>' : '<STR_LIT:http>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' , <EOL> '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT:application/json>' } , <EOL> '<STR_LIT:body>' : b'<STR_LIT>' , <EOL> '<STR_LIT:data>' : None , <EOL> '<STR_LIT>' : None , <EOL> } <EOL> } ) <EOL> alpha . close ( ) <EOL> beta . connector . close ( ) <EOL> wireLogAlpha . close ( ) <EOL> wireLogBeta . close ( ) <EOL> def mockEchoServicePath ( self , server ) : <EOL> """<STR_LIT>""" <EOL> server . serviceConnects ( ) <EOL> if server . ixes : <EOL> server . serviceReceivesAllIx ( ) <EOL> ixClient = server . ixes . values ( ) [ <NUM_LIT:0> ] <EOL> msgIn = bytes ( ixClient . rxbs ) <EOL> if msgIn == b'<STR_LIT>' : <EOL> ixClient . clearRxbs ( ) <EOL> msgOut = b'<STR_LIT>' <EOL> ixClient . tx ( msgOut ) <EOL> msgIn = b'<STR_LIT>' <EOL> msgOut = b'<STR_LIT>' <EOL> server . serviceTxesAllIx ( ) <EOL> def testPatronPipelineEchoSimplePath ( self ) : <EOL> """<STR_LIT>""" <EOL> console . terse ( "<STR_LIT>" . format ( self . testPatronPipelineEchoSimplePath . __doc__ ) ) <EOL> wireLogAlpha = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogAlpha . reopen ( ) <EOL> alpha = tcp . Server ( port = <NUM_LIT> , bufsize = <NUM_LIT> , wlog = wireLogAlpha ) <EOL> self . assertIs ( alpha . reopen ( ) , True ) <EOL> self . assertEqual ( alpha . ha , ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEqual ( alpha . eha , ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> console . terse ( "<STR_LIT>" . format ( "<STR_LIT>" ) ) <EOL> wireLogBeta = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogBeta . reopen ( ) <EOL> path = "<STR_LIT>" . format ( '<STR_LIT:localhost>' , alpha . eha [ <NUM_LIT:1> ] ) <EOL> beta = clienting . Patron ( bufsize = <NUM_LIT> , <EOL> wlog = wireLogBeta , <EOL> path = path , <EOL> reconnectable = True , <EOL> ) <EOL> self . assertIs ( beta . connector . reopen ( ) , True ) <EOL> self . assertIs ( beta . connector . accepted , False ) <EOL> self . assertIs ( beta . connector . connected , False ) <EOL> self . assertIs ( beta . connector . cutoff , False ) <EOL> request = odict ( [ ( '<STR_LIT>' , u'<STR_LIT:GET>' ) , <EOL> ( '<STR_LIT:path>' , u'<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , odict ( ) ) , <EOL> ( '<STR_LIT>' , u'<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , odict ( [ ( '<STR_LIT>' , '<STR_LIT:application/json>' ) ] ) ) , <EOL> ( '<STR_LIT:body>' , None ) , <EOL> ] ) <EOL> beta . requests . append ( request ) <EOL> while ( not alpha . ixes or beta . requests or <EOL> beta . connector . txes or not beta . respondent . ended ) : <EOL> self . mockEchoServicePath ( alpha ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . serviceAll ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> self . assertEqual ( len ( beta . connector . rxbs ) , <NUM_LIT:0> ) <EOL> self . assertIs ( beta . waited , False ) <EOL> self . assertIs ( beta . respondent . ended , True ) <EOL> self . assertEqual ( len ( beta . responses ) , <NUM_LIT:1> ) <EOL> response = beta . responses . popleft ( ) <EOL> self . assertEqual ( response , { '<STR_LIT:version>' : ( <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> '<STR_LIT:status>' : <NUM_LIT:200> , <EOL> '<STR_LIT>' : '<STR_LIT:OK>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:application/json>' , <EOL> '<STR_LIT:date>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT:body>' : bytearray ( b'<STR_LIT>' ) , <EOL> '<STR_LIT:data>' : { '<STR_LIT:action>' : None , <EOL> '<STR_LIT:content>' : None , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT:url>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' } , <EOL> '<STR_LIT:error>' : None , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT:host>' : '<STR_LIT:localhost>' , <EOL> '<STR_LIT:port>' : <NUM_LIT> , <EOL> '<STR_LIT>' : '<STR_LIT:http>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' , <EOL> '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT:application/json>' } , <EOL> '<STR_LIT:body>' : b'<STR_LIT>' , <EOL> '<STR_LIT:data>' : None , <EOL> '<STR_LIT>' : None , <EOL> } <EOL> } ) <EOL> beta . requests . append ( request ) <EOL> while ( not alpha . ixes or beta . requests or <EOL> beta . connector . txes or not beta . respondent . ended ) : <EOL> self . mockEchoServicePath ( alpha ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . serviceAll ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> self . assertEqual ( len ( beta . connector . rxbs ) , <NUM_LIT:0> ) <EOL> self . assertIs ( beta . waited , False ) <EOL> self . assertIs ( beta . respondent . ended , True ) <EOL> self . assertEqual ( len ( beta . responses ) , <NUM_LIT:1> ) <EOL> response = beta . responses . popleft ( ) <EOL> self . assertEqual ( response , { '<STR_LIT:version>' : ( <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> '<STR_LIT:status>' : <NUM_LIT:200> , <EOL> '<STR_LIT>' : '<STR_LIT:OK>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:application/json>' , <EOL> '<STR_LIT:date>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT:body>' : bytearray ( b'<STR_LIT>' ) , <EOL> '<STR_LIT:data>' : { '<STR_LIT:action>' : None , <EOL> '<STR_LIT:content>' : None , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT:url>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' } , <EOL> '<STR_LIT:error>' : None , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT:host>' : '<STR_LIT:localhost>' , <EOL> '<STR_LIT:port>' : <NUM_LIT> , <EOL> '<STR_LIT>' : '<STR_LIT:http>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' , <EOL> '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT:application/json>' } , <EOL> '<STR_LIT:body>' : b'<STR_LIT>' , <EOL> '<STR_LIT:data>' : None , <EOL> '<STR_LIT>' : None , <EOL> } <EOL> } ) <EOL> alpha . close ( ) <EOL> beta . connector . close ( ) <EOL> wireLogAlpha . close ( ) <EOL> wireLogBeta . close ( ) <EOL> def testPatronPipelineEchoSimplePathTrack ( self ) : <EOL> """<STR_LIT>""" <EOL> console . terse ( "<STR_LIT>" . format ( self . testPatronPipelineEchoSimplePathTrack . __doc__ ) ) <EOL> wireLogAlpha = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogAlpha . reopen ( ) <EOL> alpha = tcp . Server ( port = <NUM_LIT> , bufsize = <NUM_LIT> , wlog = wireLogAlpha ) <EOL> self . assertIs ( alpha . reopen ( ) , True ) <EOL> self . assertEqual ( alpha . ha , ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEqual ( alpha . eha , ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> console . terse ( "<STR_LIT>" . format ( "<STR_LIT>" ) ) <EOL> wireLogBeta = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogBeta . reopen ( ) <EOL> path = "<STR_LIT>" . format ( '<STR_LIT:localhost>' , alpha . eha [ <NUM_LIT:1> ] ) <EOL> beta = clienting . Patron ( bufsize = <NUM_LIT> , <EOL> wlog = wireLogBeta , <EOL> path = path , <EOL> reconnectable = True , <EOL> ) <EOL> self . assertIs ( beta . connector . reopen ( ) , True ) <EOL> self . assertIs ( beta . connector . accepted , False ) <EOL> self . assertIs ( beta . connector . connected , False ) <EOL> self . assertIs ( beta . connector . cutoff , False ) <EOL> request = odict ( [ ( '<STR_LIT>' , u'<STR_LIT:GET>' ) , <EOL> ( '<STR_LIT:path>' , u'<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , odict ( ) ) , <EOL> ( '<STR_LIT>' , u'<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , odict ( [ ( '<STR_LIT>' , '<STR_LIT:application/json>' ) ] ) ) , <EOL> ( '<STR_LIT:body>' , None ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:1> ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] ) <EOL> beta . requests . append ( request ) <EOL> while ( not alpha . ixes or beta . requests or <EOL> beta . connector . txes or not beta . respondent . ended ) : <EOL> self . mockEchoServicePath ( alpha ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . serviceAll ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> self . assertEqual ( len ( beta . connector . rxbs ) , <NUM_LIT:0> ) <EOL> self . assertIs ( beta . waited , False ) <EOL> self . assertIs ( beta . respondent . ended , True ) <EOL> self . assertEqual ( len ( beta . responses ) , <NUM_LIT:1> ) <EOL> response = beta . responses . popleft ( ) <EOL> self . assertEqual ( response , { '<STR_LIT:version>' : ( <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> '<STR_LIT:status>' : <NUM_LIT:200> , <EOL> '<STR_LIT>' : '<STR_LIT:OK>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:application/json>' , <EOL> '<STR_LIT:date>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT:body>' : bytearray ( b'<STR_LIT>' ) , <EOL> '<STR_LIT:data>' : { '<STR_LIT:action>' : None , <EOL> '<STR_LIT:content>' : None , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT:url>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' } , <EOL> '<STR_LIT:error>' : None , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT:host>' : '<STR_LIT:localhost>' , <EOL> '<STR_LIT:port>' : <NUM_LIT> , <EOL> '<STR_LIT>' : '<STR_LIT:http>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' , <EOL> '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT:application/json>' } , <EOL> '<STR_LIT:body>' : b'<STR_LIT>' , <EOL> '<STR_LIT:data>' : None , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> } ) <EOL> request . update ( mid = <NUM_LIT:2> , drop = '<STR_LIT>' ) <EOL> beta . requests . append ( request ) <EOL> while ( not alpha . ixes or beta . requests or <EOL> beta . connector . txes or not beta . respondent . ended ) : <EOL> self . mockEchoServicePath ( alpha ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . serviceAll ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> self . assertEqual ( len ( beta . connector . rxbs ) , <NUM_LIT:0> ) <EOL> self . assertIs ( beta . waited , False ) <EOL> self . assertIs ( beta . respondent . ended , True ) <EOL> self . assertEqual ( len ( beta . responses ) , <NUM_LIT:1> ) <EOL> response = beta . responses . popleft ( ) <EOL> self . assertEqual ( response , { '<STR_LIT:version>' : ( <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> '<STR_LIT:status>' : <NUM_LIT:200> , <EOL> '<STR_LIT>' : '<STR_LIT:OK>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:application/json>' , <EOL> '<STR_LIT:date>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT:body>' : bytearray ( b'<STR_LIT>' ) , <EOL> '<STR_LIT:data>' : { '<STR_LIT:action>' : None , <EOL> '<STR_LIT:content>' : None , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT:url>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' } , <EOL> '<STR_LIT:error>' : None , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT:host>' : '<STR_LIT:localhost>' , <EOL> '<STR_LIT:port>' : <NUM_LIT> , <EOL> '<STR_LIT>' : '<STR_LIT:http>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' , <EOL> '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT:application/json>' } , <EOL> '<STR_LIT:body>' : b'<STR_LIT>' , <EOL> '<STR_LIT:data>' : None , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : <NUM_LIT:2> , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> } ) <EOL> alpha . close ( ) <EOL> beta . connector . close ( ) <EOL> wireLogAlpha . close ( ) <EOL> wireLogBeta . close ( ) <EOL> def mockEchoServiceJson ( self , server ) : <EOL> """<STR_LIT>""" <EOL> server . serviceConnects ( ) <EOL> if server . ixes : <EOL> server . serviceReceivesAllIx ( ) <EOL> ixClient = server . ixes . values ( ) [ <NUM_LIT:0> ] <EOL> msgIn = bytes ( ixClient . rxbs ) <EOL> if msgIn == b'<STR_LIT>' : <EOL> ixClient . clearRxbs ( ) <EOL> msgOut = b'<STR_LIT>' <EOL> ixClient . tx ( msgOut ) <EOL> msgIn = b'<STR_LIT>' <EOL> msgOut = b'<STR_LIT>' <EOL> server . serviceTxesAllIx ( ) <EOL> def testPatronPipelineEchoJson ( self ) : <EOL> """<STR_LIT>""" <EOL> console . terse ( "<STR_LIT>" . format ( self . testPatronPipelineEchoJson . __doc__ ) ) <EOL> wireLogAlpha = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogAlpha . reopen ( ) <EOL> alpha = tcp . Server ( port = <NUM_LIT> , bufsize = <NUM_LIT> , wlog = wireLogAlpha ) <EOL> self . assertIs ( alpha . reopen ( ) , True ) <EOL> self . assertEqual ( alpha . ha , ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEqual ( alpha . eha , ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> console . terse ( "<STR_LIT>" . format ( "<STR_LIT>" ) ) <EOL> wireLogBeta = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogBeta . reopen ( ) <EOL> path = "<STR_LIT>" . format ( '<STR_LIT:localhost>' , alpha . eha [ <NUM_LIT:1> ] ) <EOL> beta = clienting . Patron ( bufsize = <NUM_LIT> , <EOL> wlog = wireLogBeta , <EOL> path = path , <EOL> reconnectable = True , <EOL> ) <EOL> self . assertIs ( beta . connector . reopen ( ) , True ) <EOL> self . assertIs ( beta . connector . accepted , False ) <EOL> self . assertIs ( beta . connector . connected , False ) <EOL> self . assertIs ( beta . connector . cutoff , False ) <EOL> request = odict ( [ ( '<STR_LIT>' , u'<STR_LIT>' ) , <EOL> ( '<STR_LIT:path>' , u'<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , odict ( ) ) , <EOL> ( '<STR_LIT>' , u'<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , odict ( [ ( '<STR_LIT>' , '<STR_LIT:application/json>' ) ] ) ) , <EOL> ( '<STR_LIT:data>' , odict ( [ ( "<STR_LIT>" , "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT>" ) ] ) ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:1> ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] ) <EOL> beta . requests . append ( request ) <EOL> while ( not alpha . ixes or beta . requests or <EOL> beta . connector . txes or not beta . respondent . ended ) : <EOL> self . mockEchoServiceJson ( alpha ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . serviceAll ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> self . assertEqual ( len ( beta . connector . rxbs ) , <NUM_LIT:0> ) <EOL> self . assertIs ( beta . waited , False ) <EOL> self . assertIs ( beta . respondent . ended , True ) <EOL> self . assertEqual ( len ( beta . responses ) , <NUM_LIT:1> ) <EOL> response = beta . responses . popleft ( ) <EOL> self . assertEqual ( response , { '<STR_LIT:version>' : ( <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> '<STR_LIT:status>' : <NUM_LIT:200> , <EOL> '<STR_LIT>' : '<STR_LIT:OK>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:application/json>' , <EOL> '<STR_LIT:date>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT:body>' : bytearray ( b'<STR_LIT>' ) , <EOL> '<STR_LIT:data>' : { '<STR_LIT:action>' : None , <EOL> '<STR_LIT:content>' : None , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT:url>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' } , <EOL> '<STR_LIT:error>' : None , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT:host>' : '<STR_LIT:localhost>' , <EOL> '<STR_LIT:port>' : <NUM_LIT> , <EOL> '<STR_LIT>' : '<STR_LIT:http>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT:application/json>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT:body>' : b'<STR_LIT>' , <EOL> '<STR_LIT:data>' : { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> } ) <EOL> request . update ( mid = <NUM_LIT:2> , drop = '<STR_LIT>' ) <EOL> beta . requests . append ( request ) <EOL> while ( not alpha . ixes or beta . requests or <EOL> beta . connector . txes or not beta . respondent . ended ) : <EOL> self . mockEchoServiceJson ( alpha ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . serviceAll ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> self . assertEqual ( len ( beta . connector . rxbs ) , <NUM_LIT:0> ) <EOL> self . assertIs ( beta . waited , False ) <EOL> self . assertIs ( beta . respondent . ended , True ) <EOL> self . assertEqual ( len ( beta . responses ) , <NUM_LIT:1> ) <EOL> response = beta . responses . popleft ( ) <EOL> self . assertEqual ( response , { '<STR_LIT:version>' : ( <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> '<STR_LIT:status>' : <NUM_LIT:200> , <EOL> '<STR_LIT>' : '<STR_LIT:OK>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:application/json>' , <EOL> '<STR_LIT:date>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT:body>' : bytearray ( b'<STR_LIT>' ) , <EOL> '<STR_LIT:data>' : { '<STR_LIT:action>' : None , <EOL> '<STR_LIT:content>' : None , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT:url>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' } , <EOL> '<STR_LIT:error>' : None , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT:host>' : '<STR_LIT:localhost>' , <EOL> '<STR_LIT:port>' : <NUM_LIT> , <EOL> '<STR_LIT>' : '<STR_LIT:http>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT:application/json>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT:body>' : b'<STR_LIT>' , <EOL> '<STR_LIT:data>' : { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : <NUM_LIT:2> , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> } ) <EOL> alpha . close ( ) <EOL> beta . connector . close ( ) <EOL> wireLogAlpha . close ( ) <EOL> wireLogBeta . close ( ) <EOL> def testPatronPipelineStream ( self ) : <EOL> """<STR_LIT>""" <EOL> console . terse ( "<STR_LIT>" . format ( self . testPatronPipelineStream . __doc__ ) ) <EOL> store = storing . Store ( stamp = <NUM_LIT:0.0> ) <EOL> wireLogAlpha = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogAlpha . reopen ( ) <EOL> alpha = tcp . Server ( port = <NUM_LIT> , <EOL> bufsize = <NUM_LIT> , <EOL> wlog = wireLogAlpha , <EOL> store = store ) <EOL> self . assertIs ( alpha . reopen ( ) , True ) <EOL> self . assertEqual ( alpha . ha , ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEqual ( alpha . eha , ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> console . terse ( "<STR_LIT>" . format ( "<STR_LIT>" ) ) <EOL> wireLogBeta = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogBeta . reopen ( ) <EOL> host = alpha . eha [ <NUM_LIT:0> ] <EOL> port = alpha . eha [ <NUM_LIT:1> ] <EOL> beta = clienting . Patron ( bufsize = <NUM_LIT> , <EOL> wlog = wireLogBeta , <EOL> hostname = host , <EOL> port = port , <EOL> store = store , <EOL> reconnectable = True , <EOL> ) <EOL> self . assertIs ( beta . connector . reopen ( ) , True ) <EOL> self . assertIs ( beta . connector . accepted , False ) <EOL> self . assertIs ( beta . connector . connected , False ) <EOL> self . assertIs ( beta . connector . cutoff , False ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> while True : <EOL> beta . serviceAll ( ) <EOL> alpha . serviceConnects ( ) <EOL> if beta . connector . connected and beta . connector . ca in alpha . ixes : <EOL> break <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . connector . store . advanceStamp ( <NUM_LIT> ) <EOL> self . assertIs ( beta . connector . accepted , True ) <EOL> self . assertIs ( beta . connector . connected , True ) <EOL> self . assertIs ( beta . connector . cutoff , False ) <EOL> self . assertEqual ( beta . connector . ca , beta . connector . cs . getsockname ( ) ) <EOL> self . assertEqual ( beta . connector . ha , beta . connector . cs . getpeername ( ) ) <EOL> self . assertEqual ( alpha . eha , beta . connector . ha ) <EOL> ixBeta = alpha . ixes [ beta . connector . ca ] <EOL> self . assertIsNotNone ( ixBeta . ca ) <EOL> self . assertIsNotNone ( ixBeta . cs ) <EOL> self . assertEqual ( ixBeta . cs . getsockname ( ) , beta . connector . cs . getpeername ( ) ) <EOL> self . assertEqual ( ixBeta . cs . getpeername ( ) , beta . connector . cs . getsockname ( ) ) <EOL> self . assertEqual ( ixBeta . ca , beta . connector . ca ) <EOL> self . assertEqual ( ixBeta . ha , beta . connector . ha ) <EOL> console . terse ( "<STR_LIT>" . format ( "<STR_LIT>" ) ) <EOL> request = odict ( [ ( '<STR_LIT>' , u'<STR_LIT:GET>' ) , <EOL> ( '<STR_LIT:path>' , u'<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , odict ( ) ) , <EOL> ( '<STR_LIT>' , u'<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , odict ( [ ( '<STR_LIT>' , '<STR_LIT:application/json>' ) ] ) ) , <EOL> ( '<STR_LIT:body>' , None ) , <EOL> ] ) <EOL> beta . requests . append ( request ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> console . terse ( "<STR_LIT>" . format ( beta . connector . ha [ <NUM_LIT:0> ] , <EOL> beta . connector . ha [ <NUM_LIT:1> ] , <EOL> request [ '<STR_LIT>' ] , <EOL> request [ '<STR_LIT:path>' ] ) ) <EOL> while ( beta . requests or beta . connector . txes ) and not ixBeta . rxbs : <EOL> beta . serviceAll ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . connector . store . advanceStamp ( <NUM_LIT> ) <EOL> alpha . serviceReceivesAllIx ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . connector . store . advanceStamp ( <NUM_LIT> ) <EOL> msgIn = bytes ( ixBeta . rxbs ) <EOL> msgOut = b'<STR_LIT>' <EOL> self . assertEqual ( msgIn , msgOut ) <EOL> ixBeta . clearRxbs ( ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> lines = [ <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> ] <EOL> msgOut = b'<STR_LIT>' . join ( lines ) <EOL> ixBeta . tx ( msgOut ) <EOL> timer = StoreTimer ( store = store , duration = <NUM_LIT:0.5> ) <EOL> while ixBeta . txes or not timer . expired : <EOL> alpha . serviceTxesAllIx ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . connector . store . advanceStamp ( <NUM_LIT> ) <EOL> beta . serviceAll ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . connector . store . advanceStamp ( <NUM_LIT> ) <EOL> self . assertEqual ( len ( beta . connector . rxbs ) , <NUM_LIT:0> ) <EOL> self . assertIs ( beta . waited , True ) <EOL> self . assertIs ( beta . respondent . ended , False ) <EOL> self . assertEqual ( len ( beta . responses ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( len ( beta . events ) , <NUM_LIT:5> ) <EOL> self . assertEqual ( beta . respondent . retry , <NUM_LIT:1000> ) <EOL> self . assertEqual ( beta . respondent . leid , '<STR_LIT:4>' ) <EOL> event = beta . events . popleft ( ) <EOL> self . assertEqual ( event , { '<STR_LIT:id>' : '<STR_LIT:0>' , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:data>' : '<STR_LIT>' } ) <EOL> event = beta . events . popleft ( ) <EOL> self . assertEqual ( event , { '<STR_LIT:id>' : '<STR_LIT:1>' , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:data>' : '<STR_LIT>' } ) <EOL> event = beta . events . popleft ( ) <EOL> self . assertEqual ( event , { '<STR_LIT:id>' : '<STR_LIT:2>' , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:data>' : '<STR_LIT>' } ) <EOL> beta . events . clear ( ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> alpha . closeIx ( beta . connector . ca ) <EOL> alpha . removeIx ( beta . connector . ca ) <EOL> while True : <EOL> beta . serviceAll ( ) <EOL> if not beta . connector . connected : <EOL> break <EOL> time . sleep ( <NUM_LIT:0.1> ) <EOL> beta . connector . store . advanceStamp ( <NUM_LIT:0.1> ) <EOL> self . assertIs ( beta . connector . cutoff , False ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> while True : <EOL> beta . serviceAll ( ) <EOL> alpha . serviceConnects ( ) <EOL> if beta . connector . connected and beta . connector . ca in alpha . ixes : <EOL> break <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . connector . store . advanceStamp ( <NUM_LIT> ) <EOL> self . assertIs ( beta . connector . accepted , True ) <EOL> self . assertIs ( beta . connector . connected , True ) <EOL> self . assertIs ( beta . connector . cutoff , False ) <EOL> self . assertEqual ( beta . connector . ca , beta . connector . cs . getsockname ( ) ) <EOL> self . assertEqual ( beta . connector . ha , beta . connector . cs . getpeername ( ) ) <EOL> self . assertEqual ( alpha . eha , beta . connector . ha ) <EOL> ixBeta = alpha . ixes [ beta . connector . ca ] <EOL> self . assertIsNotNone ( ixBeta . ca ) <EOL> self . assertIsNotNone ( ixBeta . cs ) <EOL> self . assertEqual ( ixBeta . cs . getsockname ( ) , beta . connector . cs . getpeername ( ) ) <EOL> self . assertEqual ( ixBeta . cs . getpeername ( ) , beta . connector . cs . getsockname ( ) ) <EOL> self . assertEqual ( ixBeta . ca , beta . connector . ca ) <EOL> self . assertEqual ( ixBeta . ha , beta . connector . ha ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> while ( beta . requests or beta . connector . txes ) or not ixBeta . rxbs : <EOL> beta . serviceAll ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . connector . store . advanceStamp ( <NUM_LIT> ) <EOL> alpha . serviceReceivesAllIx ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . connector . store . advanceStamp ( <NUM_LIT> ) <EOL> msgIn = bytes ( ixBeta . rxbs ) <EOL> msgOut = b'<STR_LIT>' <EOL> self . assertEqual ( msgIn , msgOut ) <EOL> ixBeta . clearRxbs ( ) <EOL> console . terse ( "<STR_LIT>" ) <EOL> lines = [ <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> b'<STR_LIT>' , <EOL> ] <EOL> msgOut = b'<STR_LIT>' . join ( lines ) <EOL> ixBeta . tx ( msgOut ) <EOL> timer = StoreTimer ( store = store , duration = <NUM_LIT:0.5> ) <EOL> while ixBeta . txes or not timer . expired : <EOL> alpha . serviceTxesAllIx ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . connector . store . advanceStamp ( <NUM_LIT> ) <EOL> beta . serviceAll ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . connector . store . advanceStamp ( <NUM_LIT> ) <EOL> self . assertEqual ( len ( beta . connector . rxbs ) , <NUM_LIT:0> ) <EOL> self . assertIs ( beta . waited , True ) <EOL> self . assertIs ( beta . respondent . ended , False ) <EOL> self . assertEqual ( len ( beta . responses ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( len ( beta . events ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( beta . respondent . retry , <NUM_LIT:1000> ) <EOL> self . assertEqual ( beta . respondent . leid , '<STR_LIT>' ) <EOL> event = beta . events . popleft ( ) <EOL> self . assertEqual ( event , { '<STR_LIT:id>' : '<STR_LIT:5>' , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:data>' : '<STR_LIT>' } ) <EOL> event = beta . events . popleft ( ) <EOL> self . assertEqual ( event , { '<STR_LIT:id>' : '<STR_LIT>' , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:data>' : '<STR_LIT>' } ) <EOL> alpha . close ( ) <EOL> beta . connector . close ( ) <EOL> wireLogAlpha . close ( ) <EOL> wireLogBeta . close ( ) <EOL> def mockEchoServiceSecure ( self , server ) : <EOL> """<STR_LIT>""" <EOL> server . serviceConnects ( ) <EOL> if server . ixes : <EOL> server . serviceReceivesAllIx ( ) <EOL> ixClient = server . ixes . values ( ) [ <NUM_LIT:0> ] <EOL> msgIn = bytes ( ixClient . rxbs ) <EOL> if msgIn == b'<STR_LIT>' : <EOL> ixClient . clearRxbs ( ) <EOL> msgOut = b'<STR_LIT>' <EOL> ixClient . tx ( msgOut ) <EOL> msgIn = b'<STR_LIT>' <EOL> msgOut = b'<STR_LIT>' <EOL> server . serviceTxesAllIx ( ) <EOL> def testPatronPipelineEchoSimpleSecure ( self ) : <EOL> """<STR_LIT>""" <EOL> console . terse ( "<STR_LIT>" . format ( self . testPatronPipelineEchoSimpleSecure . __doc__ ) ) <EOL> wireLogAlpha = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogAlpha . reopen ( ) <EOL> serverKeypath = '<STR_LIT>' <EOL> serverCertpath = '<STR_LIT>' <EOL> clientCafilepath = '<STR_LIT>' <EOL> clientKeypath = '<STR_LIT>' <EOL> clientCertpath = '<STR_LIT>' <EOL> serverCafilepath = '<STR_LIT>' <EOL> serverCertCommonName = '<STR_LIT:localhost>' <EOL> alpha = tcp . ServerTls ( host = serverCertCommonName , <EOL> port = <NUM_LIT> , <EOL> bufsize = <NUM_LIT> , <EOL> wlog = wireLogAlpha , <EOL> context = None , <EOL> version = None , <EOL> certify = None , <EOL> keypath = serverKeypath , <EOL> certpath = serverCertpath , <EOL> cafilepath = clientCafilepath , <EOL> ) <EOL> self . assertIs ( alpha . reopen ( ) , True ) <EOL> self . assertEqual ( alpha . ha , ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> self . assertEqual ( alpha . eha , ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> console . terse ( "<STR_LIT>" . format ( "<STR_LIT>" ) ) <EOL> wireLogBeta = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogBeta . reopen ( ) <EOL> host = alpha . eha [ <NUM_LIT:0> ] <EOL> port = alpha . eha [ <NUM_LIT:1> ] <EOL> beta = clienting . Patron ( hostname = serverCertCommonName , <EOL> port = alpha . eha [ <NUM_LIT:1> ] , <EOL> bufsize = <NUM_LIT> , <EOL> wlog = wireLogBeta , <EOL> scheme = '<STR_LIT>' , <EOL> reconnectable = True , <EOL> certedhost = serverCertCommonName , <EOL> keypath = clientKeypath , <EOL> certpath = clientCertpath , <EOL> cafilepath = serverCafilepath , <EOL> ) <EOL> self . assertIs ( beta . connector . reopen ( ) , True ) <EOL> self . assertIs ( beta . connector . accepted , False ) <EOL> self . assertIs ( beta . connector . connected , False ) <EOL> self . assertIs ( beta . connector . cutoff , False ) <EOL> request = odict ( [ ( '<STR_LIT>' , u'<STR_LIT:GET>' ) , <EOL> ( '<STR_LIT:path>' , u'<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , odict ( ) ) , <EOL> ( '<STR_LIT>' , u'<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , odict ( [ ( '<STR_LIT>' , '<STR_LIT:application/json>' ) ] ) ) , <EOL> ( '<STR_LIT:body>' , None ) , <EOL> ] ) <EOL> beta . requests . append ( request ) <EOL> while ( not alpha . ixes or beta . requests or <EOL> beta . connector . txes or not beta . respondent . ended ) : <EOL> self . mockEchoServiceSecure ( alpha ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . serviceAll ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> self . assertEqual ( len ( beta . connector . rxbs ) , <NUM_LIT:0> ) <EOL> self . assertIs ( beta . waited , False ) <EOL> self . assertIs ( beta . respondent . ended , True ) <EOL> self . assertEqual ( len ( beta . responses ) , <NUM_LIT:1> ) <EOL> response = beta . responses . popleft ( ) <EOL> self . assertEqual ( response , { '<STR_LIT:version>' : ( <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> '<STR_LIT:status>' : <NUM_LIT:200> , <EOL> '<STR_LIT>' : '<STR_LIT:OK>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:application/json>' , <EOL> '<STR_LIT:date>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT:body>' : bytearray ( b'<STR_LIT>' ) , <EOL> '<STR_LIT:data>' : { '<STR_LIT:action>' : None , <EOL> '<STR_LIT:content>' : None , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT:url>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' } , <EOL> '<STR_LIT:error>' : None , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT:host>' : '<STR_LIT:localhost>' , <EOL> '<STR_LIT:port>' : <NUM_LIT> , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' , <EOL> '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT:application/json>' } , <EOL> '<STR_LIT:body>' : b'<STR_LIT>' , <EOL> '<STR_LIT:data>' : None , <EOL> '<STR_LIT>' : None , <EOL> } <EOL> } ) <EOL> beta . requests . append ( request ) <EOL> while ( not alpha . ixes or beta . requests or <EOL> beta . connector . txes or not beta . respondent . ended ) : <EOL> self . mockEchoServiceSecure ( alpha ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . serviceAll ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> self . assertEqual ( len ( beta . connector . rxbs ) , <NUM_LIT:0> ) <EOL> self . assertIs ( beta . waited , False ) <EOL> self . assertIs ( beta . respondent . ended , True ) <EOL> self . assertEqual ( len ( beta . responses ) , <NUM_LIT:1> ) <EOL> response = beta . responses . popleft ( ) <EOL> self . assertEqual ( response , { '<STR_LIT:version>' : ( <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> '<STR_LIT:status>' : <NUM_LIT:200> , <EOL> '<STR_LIT>' : '<STR_LIT:OK>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:application/json>' , <EOL> '<STR_LIT:date>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT:body>' : bytearray ( b'<STR_LIT>' ) , <EOL> '<STR_LIT:data>' : { '<STR_LIT:action>' : None , <EOL> '<STR_LIT:content>' : None , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT:url>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' } , <EOL> '<STR_LIT:error>' : None , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT:host>' : '<STR_LIT:localhost>' , <EOL> '<STR_LIT:port>' : <NUM_LIT> , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' , <EOL> '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT:application/json>' } , <EOL> '<STR_LIT:body>' : b'<STR_LIT>' , <EOL> '<STR_LIT:data>' : None , <EOL> '<STR_LIT>' : None , <EOL> } <EOL> } ) <EOL> alpha . close ( ) <EOL> beta . connector . close ( ) <EOL> wireLogAlpha . close ( ) <EOL> wireLogBeta . close ( ) <EOL> def testPatronPipelineEchoSimpleSecurePath ( self ) : <EOL> """<STR_LIT>""" <EOL> console . terse ( "<STR_LIT>" . format ( self . testPatronPipelineEchoSimpleSecurePath . __doc__ ) ) <EOL> wireLogAlpha = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogAlpha . reopen ( ) <EOL> serverKeypath = '<STR_LIT>' <EOL> serverCertpath = '<STR_LIT>' <EOL> clientCafilepath = '<STR_LIT>' <EOL> clientKeypath = '<STR_LIT>' <EOL> clientCertpath = '<STR_LIT>' <EOL> serverCafilepath = '<STR_LIT>' <EOL> serverCertCommonName = '<STR_LIT:localhost>' <EOL> alpha = tcp . ServerTls ( host = serverCertCommonName , <EOL> port = <NUM_LIT> , <EOL> bufsize = <NUM_LIT> , <EOL> wlog = wireLogAlpha , <EOL> context = None , <EOL> version = None , <EOL> certify = None , <EOL> keypath = serverKeypath , <EOL> certpath = serverCertpath , <EOL> cafilepath = clientCafilepath , <EOL> ) <EOL> self . assertIs ( alpha . reopen ( ) , True ) <EOL> self . assertEqual ( alpha . ha , ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> self . assertEqual ( alpha . eha , ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> console . terse ( "<STR_LIT>" . format ( "<STR_LIT>" ) ) <EOL> wireLogBeta = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogBeta . reopen ( ) <EOL> path = "<STR_LIT>" . format ( serverCertCommonName , alpha . eha [ <NUM_LIT:1> ] ) <EOL> beta = clienting . Patron ( path = path , <EOL> bufsize = <NUM_LIT> , <EOL> wlog = wireLogBeta , <EOL> reconnectable = True , <EOL> keypath = clientKeypath , <EOL> certpath = clientCertpath , <EOL> cafilepath = serverCafilepath , <EOL> ) <EOL> self . assertIs ( beta . connector . reopen ( ) , True ) <EOL> self . assertIs ( beta . connector . accepted , False ) <EOL> self . assertIs ( beta . connector . connected , False ) <EOL> self . assertIs ( beta . connector . cutoff , False ) <EOL> request = odict ( [ ( '<STR_LIT>' , u'<STR_LIT:GET>' ) , <EOL> ( '<STR_LIT:path>' , u'<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , odict ( ) ) , <EOL> ( '<STR_LIT>' , u'<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , odict ( [ ( '<STR_LIT>' , '<STR_LIT:application/json>' ) ] ) ) , <EOL> ( '<STR_LIT:body>' , None ) , <EOL> ] ) <EOL> beta . requests . append ( request ) <EOL> while ( not alpha . ixes or beta . requests or <EOL> beta . connector . txes or not beta . respondent . ended ) : <EOL> self . mockEchoServiceSecure ( alpha ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . serviceAll ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> self . assertEqual ( len ( beta . connector . rxbs ) , <NUM_LIT:0> ) <EOL> self . assertIs ( beta . waited , False ) <EOL> self . assertIs ( beta . respondent . ended , True ) <EOL> self . assertEqual ( len ( beta . responses ) , <NUM_LIT:1> ) <EOL> response = beta . responses . popleft ( ) <EOL> self . assertEqual ( response , { '<STR_LIT:version>' : ( <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> '<STR_LIT:status>' : <NUM_LIT:200> , <EOL> '<STR_LIT>' : '<STR_LIT:OK>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:application/json>' , <EOL> '<STR_LIT:date>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT:body>' : bytearray ( b'<STR_LIT>' ) , <EOL> '<STR_LIT:data>' : { '<STR_LIT:action>' : None , <EOL> '<STR_LIT:content>' : None , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT:url>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' } , <EOL> '<STR_LIT:error>' : None , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT:host>' : '<STR_LIT:localhost>' , <EOL> '<STR_LIT:port>' : <NUM_LIT> , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' , <EOL> '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT:application/json>' } , <EOL> '<STR_LIT:body>' : b'<STR_LIT>' , <EOL> '<STR_LIT:data>' : None , <EOL> '<STR_LIT>' : None , <EOL> } <EOL> } ) <EOL> beta . requests . append ( request ) <EOL> while ( not alpha . ixes or beta . requests or <EOL> beta . connector . txes or not beta . respondent . ended ) : <EOL> self . mockEchoServiceSecure ( alpha ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . serviceAll ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> self . assertEqual ( len ( beta . connector . rxbs ) , <NUM_LIT:0> ) <EOL> self . assertIs ( beta . waited , False ) <EOL> self . assertIs ( beta . respondent . ended , True ) <EOL> self . assertEqual ( len ( beta . responses ) , <NUM_LIT:1> ) <EOL> response = beta . responses . popleft ( ) <EOL> self . assertEqual ( response , { '<STR_LIT:version>' : ( <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> '<STR_LIT:status>' : <NUM_LIT:200> , <EOL> '<STR_LIT>' : '<STR_LIT:OK>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:application/json>' , <EOL> '<STR_LIT:date>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT:body>' : bytearray ( b'<STR_LIT>' ) , <EOL> '<STR_LIT:data>' : { '<STR_LIT:action>' : None , <EOL> '<STR_LIT:content>' : None , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT:url>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' } , <EOL> '<STR_LIT:error>' : None , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT:host>' : '<STR_LIT:localhost>' , <EOL> '<STR_LIT:port>' : <NUM_LIT> , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' , <EOL> '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT:application/json>' } , <EOL> '<STR_LIT:body>' : b'<STR_LIT>' , <EOL> '<STR_LIT:data>' : None , <EOL> '<STR_LIT>' : None , <EOL> } <EOL> } ) <EOL> alpha . close ( ) <EOL> beta . connector . close ( ) <EOL> wireLogAlpha . close ( ) <EOL> wireLogBeta . close ( ) <EOL> def mockRedirectService ( self , server ) : <EOL> """<STR_LIT>""" <EOL> server . serviceConnects ( ) <EOL> if server . ixes : <EOL> server . serviceReceivesAllIx ( ) <EOL> ixClient = server . ixes . values ( ) [ <NUM_LIT:0> ] <EOL> msgIn = bytes ( ixClient . rxbs ) <EOL> if msgIn == b'<STR_LIT>' : <EOL> ixClient . clearRxbs ( ) <EOL> msgOut = b'<STR_LIT>' <EOL> ixClient . tx ( msgOut ) <EOL> msgIn = b'<STR_LIT>' <EOL> msgOut = b'<STR_LIT>' <EOL> elif msgIn == b'<STR_LIT>' : <EOL> ixClient . clearRxbs ( ) <EOL> msgOut = b'<STR_LIT>' <EOL> ixClient . tx ( msgOut ) <EOL> msgIn = b'<STR_LIT>' <EOL> msgOut = b'<STR_LIT>' <EOL> server . serviceTxesAllIx ( ) <EOL> def testPatronRedirectSimple ( self ) : <EOL> """<STR_LIT>""" <EOL> console . terse ( "<STR_LIT>" . format ( self . testPatronRedirectSimple . __doc__ ) ) <EOL> wireLogAlpha = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogAlpha . reopen ( ) <EOL> alpha = tcp . Server ( port = <NUM_LIT> , bufsize = <NUM_LIT> , wlog = wireLogAlpha ) <EOL> self . assertIs ( alpha . reopen ( ) , True ) <EOL> self . assertEqual ( alpha . ha , ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEqual ( alpha . eha , ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> console . terse ( "<STR_LIT>" . format ( "<STR_LIT>" ) ) <EOL> wireLogBeta = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogBeta . reopen ( ) <EOL> host = alpha . eha [ <NUM_LIT:0> ] <EOL> port = alpha . eha [ <NUM_LIT:1> ] <EOL> beta = clienting . Patron ( bufsize = <NUM_LIT> , <EOL> wlog = wireLogBeta , <EOL> hostname = host , <EOL> port = port , <EOL> reconnectable = True , <EOL> ) <EOL> self . assertIs ( beta . connector . reopen ( ) , True ) <EOL> self . assertIs ( beta . connector . accepted , False ) <EOL> self . assertIs ( beta . connector . connected , False ) <EOL> self . assertIs ( beta . connector . cutoff , False ) <EOL> request = odict ( [ ( '<STR_LIT>' , u'<STR_LIT:GET>' ) , <EOL> ( '<STR_LIT:path>' , u'<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , odict ( ) ) , <EOL> ( '<STR_LIT>' , u'<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , odict ( [ ( '<STR_LIT>' , '<STR_LIT:application/json>' ) ] ) ) , <EOL> ( '<STR_LIT:body>' , None ) , <EOL> ] ) <EOL> beta . requests . append ( request ) <EOL> while ( not alpha . ixes or beta . requests or <EOL> beta . connector . txes or not beta . respondent . ended ) : <EOL> self . mockRedirectService ( alpha ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . serviceAll ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> self . assertEqual ( len ( beta . connector . rxbs ) , <NUM_LIT:0> ) <EOL> self . assertIs ( beta . waited , False ) <EOL> self . assertIs ( beta . respondent . ended , True ) <EOL> self . assertEqual ( len ( beta . responses ) , <NUM_LIT:1> ) <EOL> response = beta . responses . popleft ( ) <EOL> self . assertEqual ( response , { '<STR_LIT:version>' : ( <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> '<STR_LIT:status>' : <NUM_LIT:200> , <EOL> '<STR_LIT>' : '<STR_LIT:OK>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:application/json>' , <EOL> '<STR_LIT:date>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT:body>' : bytearray ( b'<STR_LIT>' ) , <EOL> '<STR_LIT:data>' : { '<STR_LIT:action>' : None , <EOL> '<STR_LIT:content>' : None , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT:url>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' } , <EOL> '<STR_LIT:error>' : None , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : [ { '<STR_LIT:body>' : bytearray ( b'<STR_LIT>' ) , <EOL> '<STR_LIT:data>' : None , <EOL> '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT:*>' , <EOL> '<STR_LIT>' : '<STR_LIT:0>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:location>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:error>' : None , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : { '<STR_LIT:body>' : b'<STR_LIT>' , <EOL> '<STR_LIT:data>' : None , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT:application/json>' } , <EOL> '<STR_LIT:host>' : '<STR_LIT:127.0.0.1>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' , <EOL> '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT:port>' : <NUM_LIT> , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : '<STR_LIT:http>' } , <EOL> '<STR_LIT:status>' : <NUM_LIT> , <EOL> '<STR_LIT:version>' : ( <NUM_LIT:1> , <NUM_LIT:1> ) } ] , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT:host>' : '<STR_LIT:127.0.0.1>' , <EOL> '<STR_LIT:port>' : <NUM_LIT> , <EOL> '<STR_LIT>' : '<STR_LIT:http>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' , <EOL> '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT:application/json>' } , <EOL> '<STR_LIT:body>' : b'<STR_LIT>' , <EOL> '<STR_LIT:data>' : None , <EOL> '<STR_LIT>' : None , <EOL> } <EOL> } ) <EOL> alpha . close ( ) <EOL> beta . connector . close ( ) <EOL> wireLogAlpha . close ( ) <EOL> wireLogBeta . close ( ) <EOL> def mockRedirectComplexServiceA ( self , server ) : <EOL> """<STR_LIT>""" <EOL> server . serviceConnects ( ) <EOL> if server . ixes : <EOL> server . serviceReceivesAllIx ( ) <EOL> ixClient = server . ixes . values ( ) [ <NUM_LIT:0> ] <EOL> msgIn = bytes ( ixClient . rxbs ) <EOL> if msgIn == b'<STR_LIT>' : <EOL> ixClient . clearRxbs ( ) <EOL> msgOut = b'<STR_LIT>' <EOL> ixClient . tx ( msgOut ) <EOL> msgIn = b'<STR_LIT>' <EOL> msgOut = b'<STR_LIT>' <EOL> server . serviceTxesAllIx ( ) <EOL> def mockRedirectComplexServiceG ( self , server ) : <EOL> """<STR_LIT>""" <EOL> server . serviceConnects ( ) <EOL> if server . ixes : <EOL> server . serviceReceivesAllIx ( ) <EOL> ixClient = server . ixes . values ( ) [ <NUM_LIT:0> ] <EOL> msgIn = bytes ( ixClient . rxbs ) <EOL> if msgIn == b'<STR_LIT>' : <EOL> ixClient . clearRxbs ( ) <EOL> msgOut = b'<STR_LIT>' <EOL> ixClient . tx ( msgOut ) <EOL> msgIn = b'<STR_LIT>' <EOL> msgOut = b'<STR_LIT>' <EOL> server . serviceTxesAllIx ( ) <EOL> def testPatronRedirectComplex ( self ) : <EOL> """<STR_LIT>""" <EOL> console . terse ( "<STR_LIT>" . format ( self . testPatronRedirectComplex . __doc__ ) ) <EOL> wireLogAlpha = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogAlpha . reopen ( ) <EOL> alpha = tcp . Server ( port = <NUM_LIT> , bufsize = <NUM_LIT> , wlog = wireLogAlpha ) <EOL> self . assertIs ( alpha . reopen ( ) , True ) <EOL> self . assertEqual ( alpha . ha , ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEqual ( alpha . eha , ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> wireLogGamma = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogGamma . reopen ( ) <EOL> gamma = tcp . Server ( port = <NUM_LIT> , bufsize = <NUM_LIT> , wlog = wireLogGamma ) <EOL> self . assertIs ( gamma . reopen ( ) , True ) <EOL> self . assertEqual ( gamma . ha , ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> self . assertEqual ( gamma . eha , ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> console . terse ( "<STR_LIT>" . format ( "<STR_LIT>" ) ) <EOL> wireLogBeta = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogBeta . reopen ( ) <EOL> host = alpha . eha [ <NUM_LIT:0> ] <EOL> port = alpha . eha [ <NUM_LIT:1> ] <EOL> beta = clienting . Patron ( bufsize = <NUM_LIT> , <EOL> wlog = wireLogBeta , <EOL> hostname = host , <EOL> port = port , <EOL> reconnectable = True , <EOL> ) <EOL> self . assertIs ( beta . connector . reopen ( ) , True ) <EOL> self . assertIs ( beta . connector . accepted , False ) <EOL> self . assertIs ( beta . connector . connected , False ) <EOL> self . assertIs ( beta . connector . cutoff , False ) <EOL> request = odict ( [ ( '<STR_LIT>' , u'<STR_LIT:GET>' ) , <EOL> ( '<STR_LIT:path>' , u'<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , odict ( ) ) , <EOL> ( '<STR_LIT>' , u'<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , odict ( [ ( '<STR_LIT>' , '<STR_LIT:application/json>' ) ] ) ) , <EOL> ( '<STR_LIT:body>' , None ) , <EOL> ] ) <EOL> beta . requests . append ( request ) <EOL> while ( not alpha . ixes or beta . requests or <EOL> beta . connector . txes or not beta . respondent . ended ) : <EOL> self . mockRedirectComplexServiceA ( alpha ) <EOL> self . mockRedirectComplexServiceG ( gamma ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . serviceAll ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> self . assertEqual ( len ( beta . connector . rxbs ) , <NUM_LIT:0> ) <EOL> self . assertIs ( beta . waited , False ) <EOL> self . assertIs ( beta . respondent . ended , True ) <EOL> self . assertEqual ( len ( beta . responses ) , <NUM_LIT:1> ) <EOL> response = beta . responses . popleft ( ) <EOL> self . assertEqual ( response , { '<STR_LIT:version>' : ( <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> '<STR_LIT:status>' : <NUM_LIT:200> , <EOL> '<STR_LIT>' : '<STR_LIT:OK>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:application/json>' , <EOL> '<STR_LIT:date>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT:body>' : bytearray ( b'<STR_LIT>' ) , <EOL> '<STR_LIT:data>' : { '<STR_LIT:action>' : None , <EOL> '<STR_LIT:content>' : None , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT:url>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' } , <EOL> '<STR_LIT:error>' : None , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : [ { '<STR_LIT:body>' : bytearray ( b'<STR_LIT>' ) , <EOL> '<STR_LIT:data>' : None , <EOL> '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT:*>' , <EOL> '<STR_LIT>' : '<STR_LIT:0>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:location>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:error>' : None , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : { '<STR_LIT:body>' : b'<STR_LIT>' , <EOL> '<STR_LIT:data>' : None , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT:application/json>' } , <EOL> '<STR_LIT:host>' : '<STR_LIT:127.0.0.1>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' , <EOL> '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT:port>' : <NUM_LIT> , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : '<STR_LIT:http>' } , <EOL> '<STR_LIT:status>' : <NUM_LIT> , <EOL> '<STR_LIT:version>' : ( <NUM_LIT:1> , <NUM_LIT:1> ) } ] , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT:host>' : '<STR_LIT:localhost>' , <EOL> '<STR_LIT:port>' : <NUM_LIT> , <EOL> '<STR_LIT>' : '<STR_LIT:http>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' , <EOL> '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT:application/json>' } , <EOL> '<STR_LIT:body>' : b'<STR_LIT>' , <EOL> '<STR_LIT:data>' : None , <EOL> '<STR_LIT>' : None , <EOL> } <EOL> } ) <EOL> alpha . close ( ) <EOL> gamma . close ( ) <EOL> beta . connector . close ( ) <EOL> wireLogAlpha . close ( ) <EOL> wireLogGamma . close ( ) <EOL> wireLogBeta . close ( ) <EOL> def mockRedirectComplexServiceASecure ( self , server ) : <EOL> """<STR_LIT>""" <EOL> server . serviceConnects ( ) <EOL> if server . ixes : <EOL> server . serviceReceivesAllIx ( ) <EOL> ixClient = server . ixes . values ( ) [ <NUM_LIT:0> ] <EOL> msgIn = bytes ( ixClient . rxbs ) <EOL> if msgIn == b'<STR_LIT>' : <EOL> ixClient . clearRxbs ( ) <EOL> msgOut = b'<STR_LIT>' <EOL> ixClient . tx ( msgOut ) <EOL> msgIn = b'<STR_LIT>' <EOL> msgOut = b'<STR_LIT>' <EOL> server . serviceTxesAllIx ( ) <EOL> def mockRedirectComplexServiceGSecure ( self , server ) : <EOL> """<STR_LIT>""" <EOL> server . serviceConnects ( ) <EOL> if server . ixes : <EOL> server . serviceReceivesAllIx ( ) <EOL> ixClient = server . ixes . values ( ) [ <NUM_LIT:0> ] <EOL> msgIn = bytes ( ixClient . rxbs ) <EOL> if msgIn == b'<STR_LIT>' : <EOL> ixClient . clearRxbs ( ) <EOL> msgOut = b'<STR_LIT>' <EOL> ixClient . tx ( msgOut ) <EOL> msgIn = b'<STR_LIT>' <EOL> msgOut = b'<STR_LIT>' <EOL> server . serviceTxesAllIx ( ) <EOL> def testPatronRedirectComplexSecure ( self ) : <EOL> """<STR_LIT>""" <EOL> console . terse ( "<STR_LIT>" . format ( self . testPatronRedirectComplexSecure . __doc__ ) ) <EOL> serverCertCommonName = '<STR_LIT:localhost>' <EOL> serverKeypath = '<STR_LIT>' <EOL> serverCertpath = '<STR_LIT>' <EOL> clientCafilepath = '<STR_LIT>' <EOL> wireLogAlpha = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogAlpha . reopen ( ) <EOL> alpha = tcp . ServerTls ( host = serverCertCommonName , <EOL> port = <NUM_LIT> , <EOL> bufsize = <NUM_LIT> , <EOL> wlog = wireLogAlpha , <EOL> context = None , <EOL> version = None , <EOL> certify = None , <EOL> keypath = serverKeypath , <EOL> certpath = serverCertpath , <EOL> cafilepath = clientCafilepath , ) <EOL> self . assertIs ( alpha . reopen ( ) , True ) <EOL> self . assertEqual ( alpha . ha , ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> self . assertEqual ( alpha . eha , ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> wireLogGamma = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogGamma . reopen ( ) <EOL> gamma = tcp . ServerTls ( host = serverCertCommonName , <EOL> port = <NUM_LIT> , <EOL> bufsize = <NUM_LIT> , <EOL> wlog = wireLogGamma , <EOL> context = None , <EOL> version = None , <EOL> certify = None , <EOL> keypath = serverKeypath , <EOL> certpath = serverCertpath , <EOL> cafilepath = clientCafilepath ) <EOL> self . assertIs ( gamma . reopen ( ) , True ) <EOL> self . assertEqual ( gamma . ha , ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> self . assertEqual ( gamma . eha , ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) ) <EOL> console . terse ( "<STR_LIT>" . format ( "<STR_LIT>" ) ) <EOL> clientKeypath = '<STR_LIT>' <EOL> clientCertpath = '<STR_LIT>' <EOL> serverCafilepath = '<STR_LIT>' <EOL> wireLogBeta = wiring . WireLog ( buffify = True , same = True ) <EOL> result = wireLogBeta . reopen ( ) <EOL> host = serverCertCommonName <EOL> port = alpha . eha [ <NUM_LIT:1> ] <EOL> beta = clienting . Patron ( bufsize = <NUM_LIT> , <EOL> wlog = wireLogBeta , <EOL> hostname = host , <EOL> port = port , <EOL> reconnectable = True , <EOL> scheme = '<STR_LIT>' , <EOL> certedhost = serverCertCommonName , <EOL> keypath = clientKeypath , <EOL> certpath = clientCertpath , <EOL> cafilepath = serverCafilepath , ) <EOL> self . assertIs ( beta . connector . reopen ( ) , True ) <EOL> self . assertIs ( beta . connector . accepted , False ) <EOL> self . assertIs ( beta . connector . connected , False ) <EOL> self . assertIs ( beta . connector . cutoff , False ) <EOL> request = odict ( [ ( '<STR_LIT>' , u'<STR_LIT:GET>' ) , <EOL> ( '<STR_LIT:path>' , u'<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , odict ( ) ) , <EOL> ( '<STR_LIT>' , u'<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , odict ( [ ( '<STR_LIT>' , '<STR_LIT:application/json>' ) ] ) ) , <EOL> ( '<STR_LIT:body>' , None ) , <EOL> ] ) <EOL> beta . requests . append ( request ) <EOL> while ( not alpha . ixes or beta . requests or <EOL> beta . connector . txes or not beta . respondent . ended ) : <EOL> self . mockRedirectComplexServiceASecure ( alpha ) <EOL> self . mockRedirectComplexServiceGSecure ( gamma ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> beta . serviceAll ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> self . assertEqual ( len ( beta . connector . rxbs ) , <NUM_LIT:0> ) <EOL> self . assertIs ( beta . waited , False ) <EOL> self . assertIs ( beta . respondent . ended , True ) <EOL> self . assertEqual ( len ( beta . responses ) , <NUM_LIT:1> ) <EOL> response = beta . responses . popleft ( ) <EOL> self . assertEqual ( response , { '<STR_LIT:version>' : ( <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> '<STR_LIT:status>' : <NUM_LIT:200> , <EOL> '<STR_LIT>' : '<STR_LIT:OK>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:application/json>' , <EOL> '<STR_LIT:date>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT:body>' : bytearray ( b'<STR_LIT>' ) , <EOL> '<STR_LIT:data>' : { '<STR_LIT:action>' : None , <EOL> '<STR_LIT:content>' : None , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT:url>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' } , <EOL> '<STR_LIT:error>' : None , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : [ { '<STR_LIT:body>' : bytearray ( b'<STR_LIT>' ) , <EOL> '<STR_LIT:data>' : None , <EOL> '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT:*>' , <EOL> '<STR_LIT>' : '<STR_LIT:0>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:location>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:error>' : None , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : { '<STR_LIT:body>' : b'<STR_LIT>' , <EOL> '<STR_LIT:data>' : None , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT:application/json>' } , <EOL> '<STR_LIT:host>' : '<STR_LIT:localhost>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' , <EOL> '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT:port>' : <NUM_LIT> , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT:status>' : <NUM_LIT> , <EOL> '<STR_LIT:version>' : ( <NUM_LIT:1> , <NUM_LIT:1> ) } ] , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT:host>' : '<STR_LIT:localhost>' , <EOL> '<STR_LIT:port>' : <NUM_LIT> , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' , <EOL> '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT:application/json>' } , <EOL> '<STR_LIT:body>' : b'<STR_LIT>' , <EOL> '<STR_LIT:data>' : None , <EOL> '<STR_LIT>' : None , <EOL> } <EOL> } ) <EOL> alpha . close ( ) <EOL> gamma . close ( ) <EOL> beta . connector . close ( ) <EOL> wireLogAlpha . close ( ) <EOL> wireLogGamma . close ( ) <EOL> wireLogBeta . close ( ) <EOL> def testMultiPartForm ( self ) : <EOL> """<STR_LIT>""" <EOL> console . terse ( "<STR_LIT>" . format ( self . testMultiPartForm . __doc__ ) ) <EOL> console . terse ( "<STR_LIT>" . format ( "<STR_LIT>" ) ) <EOL> host = u'<STR_LIT:127.0.0.1>' <EOL> port = <NUM_LIT> <EOL> method = u'<STR_LIT:POST>' <EOL> path = u'<STR_LIT>' <EOL> console . terse ( "<STR_LIT>" . format ( method , host , port , path ) ) <EOL> headers = odict ( [ ( u'<STR_LIT>' , u'<STR_LIT:application/json>' ) , <EOL> ( u'<STR_LIT:Content-Type>' , u'<STR_LIT>' ) ] ) <EOL> fargs = odict ( [ ( "<STR_LIT:text>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT:html>" , "<STR_LIT>" ) ] ) <EOL> request = clienting . Requester ( hostname = host , <EOL> port = port , <EOL> method = method , <EOL> path = path , <EOL> headers = headers ) <EOL> msgOut = request . build ( fargs = fargs ) <EOL> self . assertTrue ( b'<STR_LIT>' in msgOut ) <EOL> self . assertTrue ( b'<STR_LIT>' in msgOut ) <EOL> self . assertTrue ( request . head . startswith ( b'<STR_LIT>' ) ) <EOL> def testQueryQuoting ( self ) : <EOL> """<STR_LIT>""" <EOL> console . terse ( "<STR_LIT>" . format ( self . testQueryQuoting . __doc__ ) ) <EOL> location = u'<STR_LIT>' <EOL> path , sep , query = location . partition ( '<STR_LIT:?>' ) <EOL> path = unquote ( path ) <EOL> if sep : <EOL> location = sep . join ( [ path , query ] ) <EOL> else : <EOL> location = path <EOL> self . assertEqual ( location , u'<STR_LIT>' ) <EOL> splits = urlsplit ( location ) <EOL> query = splits . query <EOL> self . assertEqual ( query , u'<STR_LIT>' ) <EOL> querySplits = query . split ( u'<STR_LIT:&>' ) <EOL> self . assertEqual ( querySplits , [ u'<STR_LIT>' , <EOL> u'<STR_LIT>' , <EOL> u'<STR_LIT>' , <EOL> u'<STR_LIT>' , <EOL> u'<STR_LIT>' , <EOL> u'<STR_LIT>' , <EOL> u'<STR_LIT>' ] ) <EOL> qargs = odict ( ) <EOL> for queryPart in querySplits : <EOL> if queryPart : <EOL> if '<STR_LIT:=>' in queryPart : <EOL> key , val = queryPart . split ( '<STR_LIT:=>' , <NUM_LIT:1> ) <EOL> val = unquote ( val ) <EOL> else : <EOL> key = queryPart <EOL> val = True <EOL> qargs [ key ] = val <EOL> self . assertEqual ( qargs , { u'<STR_LIT>' : u'<STR_LIT>' , <EOL> u'<STR_LIT>' : u'<STR_LIT>' , <EOL> u'<STR_LIT>' : u'<STR_LIT>' , <EOL> u'<STR_LIT>' : u'<STR_LIT>' , <EOL> u'<STR_LIT>' : u'<STR_LIT>' , <EOL> u'<STR_LIT>' : u'<STR_LIT:1.0>' , <EOL> u'<STR_LIT>' : u'<STR_LIT>' } ) <EOL> qargParts = [ u"<STR_LIT>" . format ( key , quote_plus ( str ( val ) ) ) <EOL> for key , val in qargs . items ( ) ] <EOL> newQuery = '<STR_LIT:&>' . join ( qargParts ) <EOL> self . assertEqual ( newQuery , u'<STR_LIT>' ) <EOL> def runOne ( test ) : <EOL> '''<STR_LIT>''' <EOL> test = BasicTestCase ( test ) <EOL> suite = unittest . TestSuite ( [ test ] ) <EOL> unittest . TextTestRunner ( verbosity = <NUM_LIT:2> ) . run ( suite ) <EOL> def runSome ( ) : <EOL> """<STR_LIT>""" <EOL> tests = [ ] <EOL> names = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> tests . extend ( map ( BasicTestCase , names ) ) <EOL> suite = unittest . TestSuite ( tests ) <EOL> unittest . TextTestRunner ( verbosity = <NUM_LIT:2> ) . run ( suite ) <EOL> def runAll ( ) : <EOL> """<STR_LIT>""" <EOL> suite = unittest . TestSuite ( ) <EOL> suite . addTest ( unittest . TestLoader ( ) . loadTestsFromTestCase ( BasicTestCase ) ) <EOL> unittest . TextTestRunner ( verbosity = <NUM_LIT:2> ) . run ( suite ) <EOL> if __name__ == '<STR_LIT:__main__>' and __package__ is None : <EOL> runSome ( ) </s>
