def setUp(self): SMPPServerTestCases.setUp(self) self.SubmitSmPDU = SubmitSM( source_addr='1234', destination_addr='4567', short_message='hello !', seqNum=1, ) self.DeliverSmPDU = DeliverSM( source_addr='4567', destination_addr='1234', short_message='hello !', seqNum=1, ) # SMPPClientConfig init args = { 'id': 'smppc_01', 'port': self.smpps_config.port, 'log_level': logging.DEBUG, 'reconnectOnConnectionLoss': False, 'username': '******', 'password': '******' } self.smppc_config = SMPPClientConfig(**args) # SMPPClientFactory init self.smppc_factory = LastProtoSMPPClientFactory(self.smppc_config)
def prepareRoutingsAndStartConnector(self, connector): self.AckServerResource.render_GET = mock.Mock( wraps=self.AckServerResource.render_GET) # Prepare for routing connector.port = self.SMSCPort.getHost().port c2_destination = HttpConnector( id_generator(), 'http://127.0.0.1:%s/send' % self.AckServer.getHost().port) # Set the route yield self.moroute_add(DefaultRoute(c2_destination), 0) # Now we'll create the connector 1 from which we'll receive DeliverSm PDUs before # throwing to http yield self.SMPPClientManagerPBProxy.connect('127.0.0.1', self.CManagerPort) c1Config = SMPPClientConfig(id=connector.cid, port=connector.port) yield self.SMPPClientManagerPBProxy.add(c1Config) # Start the connector yield self.SMPPClientManagerPBProxy.start(connector.cid) # Wait for 'BOUND_TRX' state while True: ssRet = yield self.SMPPClientManagerPBProxy.session_state( connector.cid) if ssRet == 'BOUND_TRX': break else: time.sleep(0.2)
def test_seqNum(self): yield self.connect('127.0.0.1', self.pbPort) yield self.provision_user_connector() # add connector yield self.SMPPClientManagerPBProxy.connect('127.0.0.1', self.CManagerPort) c1Config = SMPPClientConfig(id=self.c1.cid) yield self.SMPPClientManagerPBProxy.add(c1Config) # Bind and send many SMS MT through smpps interface self._bind_smpps(self.u1) count = 5 SubmitSmPDU = copy.deepcopy(self.SubmitSmPDU) for i in range(count): self.smpps_proto.dataReceived(self.encoder.encode(SubmitSmPDU)) SubmitSmPDU.seqNum += 1 # Assertions # smpps sent back a response ? self.assertEqual(self.smpps_proto.sendPDU.call_count, count) # Collect message_ids from submit_sm_resps current_seqNum = 1 for call_arg in self.smpps_proto.sendPDU.call_args_list: response_pdu = call_arg[0][0] self.assertEqual(response_pdu.id, pdu_types.CommandId.submit_sm_resp) self.assertEqual(response_pdu.status, pdu_types.CommandStatus.ESME_ROK) # is seqNum correctly incrementing ? self.assertEqual(response_pdu.seqNum, current_seqNum) current_seqNum += 1
def test_delivery_from_smpps_with_default_src_addr(self): yield self.connect('127.0.0.1', self.pbPort) yield self.provision_user_connector() default_source_addr = 'JASMINTEST' self.u1.mt_credential.setDefaultValue('source_address', default_source_addr) # add connector yield self.SMPPClientManagerPBProxy.connect('127.0.0.1', self.CManagerPort) c1Config = SMPPClientConfig(id=self.c1.cid) yield self.SMPPClientManagerPBProxy.add(c1Config) # Bind and send a SMS MT through smpps interface self._bind_smpps(self.u1) SubmitSmPDU = copy.deepcopy(self.SubmitSmPDU) SubmitSmPDU.params['source_addr'] = None self.smpps_proto.dataReceived(self.encoder.encode(SubmitSmPDU)) # Assertions # submit_sm source_addr has been changed to default one SentSubmitSmPDU = self.clientManager_f.perspective_submit_sm.call_args_list[ 0][1]['SubmitSmPDU'] self.assertEqual(SentSubmitSmPDU.params['source_addr'], default_source_addr)
def setUp(self): if hasattr(self, 'ipb_client'): yield HappySMSCTestCase.setUp(self, interceptorpb_client = self.ipb_client) else: yield HappySMSCTestCase.setUp(self) # Connect to RouterPB yield self.connect('127.0.0.1', self.pbPort) # Provision user, group, default mt route and # default mt interceptor self.g1 = Group(1) yield self.group_add(self.g1) self.c1 = SmppClientConnector(id_generator()) self.mt_interceptor = MTInterceptorScript(self.script) self.u1_password = '******' self.u1 = User(1, self.g1, 'username', self.u1_password) self.u2_password = '******' self.u2 = User(1, self.g1, 'username2', self.u2_password) yield self.user_add(self.u1) yield self.mtroute_add(DefaultRoute(self.c1), 0) yield self.mtinterceptor_add(DefaultInterceptor(self.mt_interceptor), 0) # Now we'll create the connector yield self.SMPPClientManagerPBProxy.connect('127.0.0.1', self.CManagerPort) c1Config = SMPPClientConfig(id=self.c1.cid, port = self.SMSCPort.getHost().port) yield self.SMPPClientManagerPBProxy.add(c1Config) # And start it ! yield self.SMPPClientManagerPBProxy.start(self.c1.cid) # Get stats singletons self.stats_http = HttpAPIStatsCollector().get()
def prepareRoutingsAndStartConnector(self, bindOperation='transceiver', route_rate=0.0, user=None, port=None): # Routing stuff g1 = Group(1) yield self.group_add(g1) self.c1 = SmppClientConnector(id_generator()) user_password = '******' if user is None: self.u1 = User(1, g1, 'username', user_password) else: self.u1 = user yield self.user_add(self.u1) yield self.mtroute_add(DefaultRoute(self.c1, route_rate), 0) # Set port if port is None: port = self.SMSCPort.getHost().port # Now we'll create the connecter yield self.SMPPClientManagerPBProxy.connect('127.0.0.1', self.CManagerPort) c1Config = SMPPClientConfig(id=self.c1.cid, port=port, bindOperation=bindOperation) yield self.SMPPClientManagerPBProxy.add(c1Config) # Start the connector yield self.SMPPClientManagerPBProxy.start(self.c1.cid) # Wait for 'BOUND_TRX' state while True: ssRet = yield self.SMPPClientManagerPBProxy.session_state( self.c1.cid) if ssRet[:6] == 'BOUND_': break else: time.sleep(0.2) # Configuration self.method = 'GET' self.postdata = None self.params = { 'to': '98700177', 'username': self.u1.username, 'password': user_password, 'content': 'test' } if hasattr(self, 'AckServer'): # Send a SMS MT through http interface and set delivery receipt callback in url self.dlr_url = 'http://127.0.0.1:%d/receipt' % ( self.AckServer.getHost().port) self.AckServerResource.render_POST = mock.Mock( wraps=self.AckServerResource.render_POST) self.AckServerResource.render_GET = mock.Mock( wraps=self.AckServerResource.render_GET)
def __init__(self, config=None, long_content_max_parts=5, long_content_split='sar'): if config is not None: self.config = config else: self.config = SMPPClientConfig(**{'id': 'anyid'}) self.long_content_max_parts = long_content_max_parts self.long_content_split = long_content_split
def setUp(self): self.opFactory = SMPPOperationFactory(SMPPClientConfig(id='test-id')) self.user = User(1, Group(100), 'username', 'password') self.pdu = self.opFactory.SubmitSM( source_addr=b'2', destination_addr=b'3', short_message=b'sunny day !', )
def send_long_submit_sm(self, long_content_split): """Reference to #27: When sending a long SMS, logger must write concatenated content """ lc = LogCapture("jasmin-sm-listener") yield self.connect('127.0.0.1', self.pbPort) yield self.add(self.defaultConfig) yield self.start(self.defaultConfig.id) # Wait for 'BOUND_TRX' state yield waitFor(2) # Build a long submit_sm assertionKey = str(randint(10, 99)) * 100 + 'EOF' # 203 chars config = SMPPClientConfig(id='defaultId') opFactory = SMPPOperationFactory(config, long_content_split = long_content_split) SubmitSmPDU = opFactory.SubmitSM( source_addr='1423', destination_addr='98700177', short_message=assertionKey, ) # Send submit_sm yield self.submit_sm(self.defaultConfig.id, SubmitSmPDU) # Wait 2 seconds yield waitFor(2) yield self.stop(self.defaultConfig.id) # Wait for unbound state yield waitFor(2) # Assertions # Take the lastClient (and unique one) and assert received messages self.assertEqual(len(self.SMSCPort.factory.lastClient.submitRecords), 2) if long_content_split == 'udh': concatenatedShortMessage = self.SMSCPort.factory.lastClient.submitRecords[0].params['short_message'][6:] concatenatedShortMessage+= self.SMSCPort.factory.lastClient.submitRecords[1].params['short_message'][6:] else: concatenatedShortMessage = self.SMSCPort.factory.lastClient.submitRecords[0].params['short_message'] concatenatedShortMessage+= self.SMSCPort.factory.lastClient.submitRecords[1].params['short_message'] self.assertEqual(concatenatedShortMessage, assertionKey) # Logged concatenated message loggedSms = False for record in lc.records: if record.getMessage()[:6] == 'SMS-MT': loggedSms = True # Will raise ValueError if concatenatedShortMessage is not logged record.getMessage().index('[content:%s]' % concatenatedShortMessage) break # This will assert if we had a SMS-MT logged self.assertTrue(loggedSms) # There were a connection to the SMSC self.assertTrue(self.SMSCPort.factory.buildProtocol.called) self.assertEqual(self.SMSCPort.factory.buildProtocol.call_count, 1)
def __init__(self, config=None, long_content_max_parts=5, long_content_split='sar'): if config is not None: self.config = config else: self.config = SMPPClientConfig(**{'id': 'anyid'}) self.long_content_max_parts = int(long_content_max_parts) if isinstance(long_content_split, bytes): long_content_split = long_content_split.decode() self.long_content_split = long_content_split
def prepareRoutingsAndStartConnector(self, user=None, default_route=None, side_effect=None): # Routing stuff yield self.group_add(self.group1) if user is None: user = self.user1 yield self.user_add(user) if default_route is None: yield self.mtroute_add(DefaultRoute(self.c1), 0) else: yield self.mtroute_add(default_route, 0) # Now we'll create the connecter yield self.SMPPClientManagerPBProxy.connect('127.0.0.1', self.CManagerPort) c1Config = SMPPClientConfig( id=self.c1.cid, port=self.SMSCPort.getHost().port, bindOperation='transceiver', submit_sm_throughput=0, log_level=logging.DEBUG, ) yield self.SMPPClientManagerPBProxy.add(c1Config) # Start the connector yield self.SMPPClientManagerPBProxy.start(self.c1.cid) # Wait for 'BOUND_TRX' state while True: ssRet = yield self.SMPPClientManagerPBProxy.session_state( self.c1.cid) if ssRet in ('BOUND_TRX', 'BOUND_TX', 'BOUND_RX'): break else: yield waitFor(0.2) # Install mock # TODO: side effect causes the wrapped function to not be called and fails the tests # the ability to use wrap and side effect was considered a bug # that was fixed here: https://bugs.python.org/issue35330 self.SMSCPort.factory.lastClient.sendSubmitSmResponse = Mock( wraps=self.SMSCPort.factory.lastClient.sendSubmitSmResponse) # side_effect=side_effect) # Configuration self.method = 'POST' self.postdata = None self.params = { 'to': '06155423', 'username': user.username, 'password': '******', 'content': 'test' }
def setUp(self): yield SMSCSimulatorRecorder.setUp(self) self.SMSCPort.factory.buildProtocol = mock.Mock(wraps=self.SMSCPort.factory.buildProtocol) config = SMPPClientConfig(id='defaultId') opFactory = SMPPOperationFactory(config) self.SubmitSmPDU = opFactory.SubmitSM( source_addr='1423', destination_addr='98700177', short_message='Hello world !', )
def setUp(self): yield SmppServerTestCases.setUp(self) # SMPPClientConfig init args = {'id': 'smppc_01', 'port': self.smpps_config.port, 'log_level': logging.DEBUG, 'reconnectOnConnectionLoss': False, 'username': '******', 'password': '******'} self.smppc_config = SMPPClientConfig(**args) # SMPPClientFactory init self.smppc_factory = LastProtoSMPPClientFactory(self.smppc_config)
def test_add_many_persist_and_load_default(self): "Related to #420" yield self.connect('127.0.0.1', self.pbPort) # Add many yield self.add(SMPPClientConfig(id='IPBANK')) yield self.add(SMPPClientConfig(id='UPBANK')) yield self.add(SMPPClientConfig(id='ITEL')) yield self.add(SMPPClientConfig(id='MOBILMATIC')) yield self.add(SMPPClientConfig(id='SMSGH')) listRet = yield self.connector_list() self.assertEqual(5, len(listRet)) # Persist yield self.persist() # Load yield self.load() # List and assert listRet = yield self.connector_list() self.assertEqual(5, len(listRet))
def prepareRoutingsAndStartConnector(self, user=None, default_route=None, side_effect=None): # Routing stuff yield self.group_add(self.group1) if user is None: user = self.user1 yield self.user_add(user) if default_route is None: yield self.mtroute_add(DefaultRoute(self.c1), 0) else: yield self.mtroute_add(default_route, 0) # Now we'll create the connecter yield self.SMPPClientManagerPBProxy.connect('127.0.0.1', self.CManagerPort) c1Config = SMPPClientConfig( id=self.c1.cid, port=self.SMSCPort.getHost().port, bindOperation='transceiver', submit_sm_throughput=0, ) yield self.SMPPClientManagerPBProxy.add(c1Config) # Start the connector yield self.SMPPClientManagerPBProxy.start(self.c1.cid) # Wait for 'BOUND_TRX' state while True: ssRet = yield self.SMPPClientManagerPBProxy.session_state( self.c1.cid) if ssRet[:6] == 'BOUND_': break else: yield waitFor(0.2) # Install mock self.SMSCPort.factory.lastClient.sendSubmitSmResponse = mock.Mock( wraps=self.SMSCPort.factory.lastClient.sendSubmitSmResponse, side_effect=side_effect) # Configuration self.method = 'GET' self.postdata = None self.params = { 'to': '06155423', 'username': user.username, 'password': '******', 'content': 'test' }
def setUp(self): yield SMSCSimulatorRecorder.setUp(self) self.SMSCPort.factory.buildProtocol = mock.Mock(wraps=self.SMSCPort.factory.buildProtocol) config = SMPPClientConfig(id='defaultId') opFactory = SMPPOperationFactory(config) self.SubmitSmPDU = opFactory.SubmitSM( source_addr='1423', destination_addr='06155423', short_message='Hello world !', ) self.SubmitSmBill = SubmitSmBill(User('test_user', Group('test_group'), 'test_username', 'pwd'))
def setUp(self, authentication=False): # Initiating config objects without any filename # will lead to setting defaults and that's what we # need to run the tests self.SMPPClientPBConfigInstance = SMPPClientPBConfig() self.SMPPClientPBConfigInstance.authentication = authentication AMQPServiceConfigInstance = AmqpConfig() AMQPServiceConfigInstance.reconnectOnConnectionLoss = False # Launch AMQP Broker self.amqpBroker = AmqpFactory(AMQPServiceConfigInstance) self.amqpBroker.preConnect() self.amqpClient = reactor.connectTCP(AMQPServiceConfigInstance.host, AMQPServiceConfigInstance.port, self.amqpBroker) # Wait for AMQP Broker connection to get ready yield self.amqpBroker.getChannelReadyDeferred() # Launch the client manager server pbRoot = SMPPClientManagerPB() pbRoot.setConfig(self.SMPPClientPBConfigInstance) yield pbRoot.addAmqpBroker(self.amqpBroker) p = portal.Portal(JasminPBRealm(pbRoot)) if not authentication: p.registerChecker(AllowAnonymousAccess()) else: c = InMemoryUsernamePasswordDatabaseDontUse() c.addUser('test_user', md5('test_password').digest()) p.registerChecker(c) jPBPortalRoot = JasminPBPortalRoot(p) self.PBServer = reactor.listenTCP(0, pb.PBServerFactory(jPBPortalRoot)) self.pbPort = self.PBServer.getHost().port # Launch the router server self.RouterPBInstance = RouterPB() self.RouterPBInstance.setConfig(RouterPBConfig()) pbRoot.addRouterPB(self.RouterPBInstance) # Default SMPPClientConfig defaultSMPPClientId = '001-testconnector' self.defaultConfig = SMPPClientConfig( id=defaultSMPPClientId, username='******', reconnectOnConnectionFailure=True, port=9002, )
def setUp(self): self.factory = Factory() self.factory.protocol = self.protocol self.port = reactor.listenTCP(9001, self.factory) self.testPort = self.port.getHost().port args = self.configArgs.copy() args['host'] = self.configArgs.get('host', 'localhost') args['port'] = self.configArgs.get('port', self.testPort) args['username'] = self.configArgs.get('username', 'anyusername') args['password'] = self.configArgs.get('password', '') args['log_level'] = self.configArgs.get('log_level', logging.DEBUG) self.config = SMPPClientConfig(**args) self.opFactory = SMPPOperationFactory(self.config)
def log_update_requests_and_call(self, *args, **kwargs): cmd = args[0] arg = args[1] # Empty line if cmd is None: return self.protocol.sendData() # Pass sessBuffer as updateLog to fCallback if cmd == 'ok': if len(self.sessBuffer) == 0: return self.protocol.sendData('Nothing to save') try: # Initiate a volatile SMPPClientConfig instance to run through it's constructor # validation steps, this will raise an exception whenever an error is detected configArgs = self.sessBuffer configArgs['id'] = self.sessionContext['cid'] SMPPClientConfig(**configArgs) except Exception as e: return self.protocol.sendData('Error: %s' % str(e)) return fCallback(self, self.sessBuffer) else: # Unknown key if cmd not in SMPPClientConfigKeyMap: return self.protocol.sendData( 'Unknown SMPPClientConfig key: %s' % cmd) if cmd == 'cid': return self.protocol.sendData( 'Connector id can not be modified !') try: # Buffer key for later (when receiving 'ok') SMPPClientConfigKey = SMPPClientConfigKeyMap[cmd] if isinstance( arg, str ) and SMPPClientConfigKey not in SMPPClientConfigStringKeys: self.sessBuffer[ SMPPClientConfigKey] = castInputToBuiltInType( cmd, str2num(arg)) else: self.sessBuffer[ SMPPClientConfigKey] = castInputToBuiltInType( cmd, arg) except Exception as e: return self.protocol.sendData('Error: %s' % str(e)) return self.protocol.sendData()
def setUp(self, interceptorpb_client = None): yield SmppServerTestCases.setUp(self, interceptorpb_client) # Add interceptorpb_client to smpp client manager if interceptorpb_client is not None: self.clientManager_f.addInterceptorPBClient(interceptorpb_client) # SMPPClientConfig init args = {'id': 'smppc_01', 'port': self.smpps_config.port, 'log_level': logging.DEBUG, 'reconnectOnConnectionLoss': False, 'username': '******', 'password': '******'} self.smppc_config = SMPPClientConfig(**args) # SMPPClientFactory init self.smppc_factory = LastProtoSMPPClientFactory(self.smppc_config)
def setUp(self): self.factory = Factory() self.factory.protocol = self.protocol args = self.configArgs.copy() args['host'] = self.configArgs.get('host', 'localhost') args['port'] = self.configArgs.get('port', '2775') args['username'] = self.configArgs.get('username', 'anyusername') args['password'] = self.configArgs.get('password', '') args['log_level'] = self.configArgs.get('log_level', logging.DEBUG) self.config = SMPPClientConfig(**args) self.opFactory = SMPPOperationFactory(self.config) # Start listening 5 seconds later, the client shall successfully reconnect reactor.callLater(5, self.startListening, self.config.port)
def runScenario(): try: ## First part, SMPP Client connector management ############################################### # Connect to SMPP Client management PB proxy proxy_smpp = SMPPClientManagerPBProxy() yield proxy_smpp.connect('127.0.0.1', 8989, 'cmadmin', 'cmpwd') # Provision SMPPClientManagerPBProxy with a connector and start it connector1 = { 'id': 'abc', 'username': '******', 'reconnectOnConnectionFailure': True } config1 = SMPPClientConfig(**connector1) yield proxy_smpp.add(config1) yield proxy_smpp.start('abc') ## Second part, User and Routing management ########################################### # Connect to Router PB proxy proxy_router = RouterPBProxy() yield proxy_router.connect('127.0.0.1', 8988, 'radmin', 'rpwd') # Provision RouterPBProxy with MT routes yield proxy_router.mtroute_add( DefaultRoute(SmppClientConnector('abc')), 0) routes = yield proxy_router.mtroute_get_all() print("Configured routes: \n\t%s" % pickle.loads(routes)) # Provisiong router with users g1 = Group(1) u1 = User(uid=1, group=g1, username='******', password='******') yield proxy_router.group_add(g1) yield proxy_router.user_add(u1) users = yield proxy_router.user_get_all() print("Users: \n\t%s" % pickle.loads(users)) ## Last, tear down ################## # Stop connector yield proxy_smpp.stop('abc') except Exception as e: print("ERROR RUNNING SCENARIO: %s" % str(e)) finally: reactor.stop()
def test_successful_delivery_from_smpps_to_smppc(self): yield self.connect('127.0.0.1', self.pbPort) yield self.provision_user_connector() # add connector yield self.SMPPClientManagerPBProxy.connect('127.0.0.1', self.CManagerPort) c1Config = SMPPClientConfig(id=self.c1.cid) yield self.SMPPClientManagerPBProxy.add(c1Config) # Bind and send a SMS MT through smpps interface self._bind_smpps(self.u1) self.smpps_proto.dataReceived(self.encoder.encode(self.SubmitSmPDU)) # Assertions # smpps sent back a response ? self.assertEqual(self.smpps_proto.sendPDU.call_count, 1) # smpps response was a submit_sm_resp with ESME_ROK ? response_pdu = self.smpps_proto.sendPDU.call_args_list[0][0][0] self.assertEqual(response_pdu.id, pdu_types.CommandId.submit_sm_resp) self.assertEqual(response_pdu.seqNum, 1) self.assertEqual(response_pdu.status, pdu_types.CommandStatus.ESME_ROK) self.assertTrue(response_pdu.params['message_id'] is not None)
def log_update_requests_and_call(self, *args, **kwargs): cmd = args[0] arg = args[1] # Empty line if cmd is None: return self.protocol.sendData() # Pass sessBuffer as updateLog to fCallback if cmd == 'ok': if len(self.sessBuffer) == 0: return self.protocol.sendData('Nothing to save') try: # Initiate a volatile SMPPClientConfig instance to run through it's constructor # validation steps, this will raise an exception whenever an error is detected configArgs = self.sessBuffer configArgs['id'] = self.sessionContext['cid'] SMPPClientConfig(**configArgs) except Exception, e: return self.protocol.sendData('Error: %s' % str(e)) return fCallback(self, self.sessBuffer)
def test_multiple_clients(self): """Reference to #28: SMPP client's logging does not work correctly with multiple connectors """ args = self.configArgs.copy() args['id'] = 'test-id-2' args['port'] = self.testPort args['bindOperation'] = 'transmitter' args['log_level'] = self.configArgs.get('log_level', logging.DEBUG) self.config2 = SMPPClientConfig(**args) client1 = SMPPClientFactory(self.config) client2 = SMPPClientFactory(self.config2) lc1 = LogCapture("smpp.client.%s" % client1.config.id) lc2 = LogCapture("smpp.client.%s" % client2.config.id) # Connect and bind yield client1.connectAndBind() yield client2.connectAndBind() # Unbind & Disconnect yield client1.disconnect() yield client2.disconnect() # Assert logging of client1 bindRequestsCount = 0 for record in lc1.records: if record.getMessage()[:30] == 'Requesting bind as transceiver': bindRequestsCount += 1 self.assertEqual(bindRequestsCount, 1) # Assert logging of client2 bindRequestsCount = 0 for record in lc2.records: if record.getMessage()[:30] == 'Requesting bind as transmitter': bindRequestsCount += 1 self.assertEqual(bindRequestsCount, 1)
def setUp(self): self.opFactory = SMPPOperationFactory(SMPPClientConfig(id='test-id'))
self.assertEqual(lastErrorStatus, '403') # Since Connector doesnt really exist, the message will not be routed # to a queue, a 500 error will be returned, and more details will be written # in smpp client manager log: # 'Trying to enqueue a SUBMIT_SM to a connector with an unknown cid: ' try: yield getPage(url_ok) except Exception, e: lastErrorStatus = e.status self.assertEqual(lastErrorStatus, '500') # Now we'll create the connecter and send an MT to it yield self.SMPPClientManagerPBProxy.connect('127.0.0.1', self.CManagerPort) c1Config = SMPPClientConfig(id=c1.cid) yield self.SMPPClientManagerPBProxy.add(c1Config) # We should receive a msg id c = yield getPage(url_ok) self.assertEqual(c[:7], 'Success') # @todo: Should be a real uuid pattern testing self.assertApproximates(len(c), 40, 10) class LastClientFactory(Factory): lastClient = None def buildProtocol(self, addr): self.lastClient = Factory.buildProtocol(self, addr) return self.lastClient