<s> import urllib <EOL> from twisted . internet import reactor <EOL> from twisted . web . client import getPage <EOL> from twisted . internet import defer <EOL> from testfixtures import LogCapture <EOL> from jasmin . routing . proxies import RouterPBProxy <EOL> from jasmin . routing . test . test_router import HappySMSCTestCase , SubmitSmTestCaseTools <EOL> from jasmin . routing . test . test_encoding import composeMessage <EOL> from jasmin . routing . test . codepages import GSM0338 <EOL> class LoggingTestCases ( RouterPBProxy , HappySMSCTestCase , SubmitSmTestCaseTools ) : <EOL> @ defer . inlineCallbacks <EOL> def run_test ( self , content , datacoding = None , port = <NUM_LIT> ) : <EOL> yield self . connect ( '<STR_LIT:127.0.0.1>' , self . pbPort ) <EOL> yield self . prepareRoutingsAndStartConnector ( ) <EOL> self . params [ '<STR_LIT:content>' ] = content <EOL> if datacoding is None and '<STR_LIT>' in self . params : <EOL> del self . params [ '<STR_LIT>' ] <EOL> if datacoding is not None : <EOL> self . params [ '<STR_LIT>' ] = datacoding <EOL> baseurl = '<STR_LIT>' % ( port , urllib . urlencode ( self . params ) ) <EOL> c = yield getPage ( baseurl , method = self . method , postdata = self . postdata ) <EOL> msgStatus = c [ : <NUM_LIT:7> ] <EOL> exitDeferred = defer . Deferred ( ) <EOL> reactor . callLater ( <NUM_LIT:2> , exitDeferred . callback , None ) <EOL> yield exitDeferred <EOL> yield self . stopSmppClientConnectors ( ) <EOL> self . assertEqual ( msgStatus , '<STR_LIT>' ) <EOL> class SubmitSmTestCases ( LoggingTestCases ) : <EOL> @ defer . inlineCallbacks <EOL> def test_submit_sm ( self ) : <EOL> """<STR_LIT>""" <EOL> lc = LogCapture ( "<STR_LIT>" ) <EOL> _gsm0338_str = composeMessage ( [ '<STR_LIT:A>' , '<STR_LIT:B>' , '<STR_LIT:C>' ] , <NUM_LIT> ) <EOL> yield self . run_test ( content = _gsm0338_str ) <EOL> loggedMsgCount = <NUM_LIT:0> <EOL> for record in lc . records : <EOL> if record . getMessage ( ) [ : <NUM_LIT:6> ] == '<STR_LIT>' : <EOL> loggedMsgCount += <NUM_LIT:1> <EOL> self . assertEqual ( loggedMsgCount , <NUM_LIT:1> ) </s>
