当前位置: 首页>>代码示例>>Python>>正文


Python factory.SMPPClientFactory类代码示例

本文整理汇总了Python中jasmin.protocols.smpp.factory.SMPPClientFactory的典型用法代码示例。如果您正苦于以下问题:Python SMPPClientFactory类的具体用法?Python SMPPClientFactory怎么用?Python SMPPClientFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SMPPClientFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_very_long_submit_sm_16bit

    def test_very_long_submit_sm_16bit(self):
        client = SMPPClientFactory(self.config)
        # Connect and bind
        yield client.connectAndBind()
        smpp = client.smpp
        self.prepareMocks(smpp)

        # Send submit_sm
        UCS2 = {'\x0623', '\x0631', '\x0646', '\x0628'}
        content = self.composeMessage(UCS2, 3350) # 3350 = 67 * 10
        SubmitSmPDU = self.opFactory.SubmitSM(
            source_addr=self.source_addr,
            destination_addr=self.destination_addr,
            short_message=content,
            data_coding = 8,
        )
        yield smpp.sendDataRequest(SubmitSmPDU)
        
        # Unbind & Disconnect
        yield smpp.unbindAndDisconnect()
        
        ##############
        # Assertions :
        self.assertEquals(self.long_content_max_parts + 1, smpp.PDUReceived.call_count)
        self.assertEquals(self.long_content_max_parts + 1, smpp.sendPDU.call_count)
开发者ID:pyghassen,项目名称:jasmin,代码行数:25,代码来源:test_smpp_client.py

示例2: test_submit_sm_resp_deferred

    def test_submit_sm_resp_deferred(self):
        client = SMPPClientFactory(self.config)
        # Connect and bind
        yield client.connectAndBind()
        smpp = client.smpp

        smpp.PDUReceived = mock.Mock(wraps=smpp.PDUReceived)
        smpp.sendPDU = mock.Mock(wraps=smpp.sendPDU)
        
        # Send submit_sm
        SubmitSmPDU = self.opFactory.SubmitSM(
            source_addr=self.source_addr,
            destination_addr=self.destination_addr,
            short_message=self.shortMsg,
        )
        yield smpp.sendDataRequest(SubmitSmPDU).addCallback(self.handleSubmitSmResp)
        
        # Unbind & Disconnect
        yield smpp.unbindAndDisconnect()
        
        ##############
        # Assertions :
        self.assertEquals(2, smpp.PDUReceived.call_count)
        self.assertEquals(2, smpp.sendPDU.call_count)
        recv1 = smpp.PDUReceived.call_args_list[0][0][0]
        recv2 = smpp.PDUReceived.call_args_list[1][0][0]
        sent1 = smpp.sendPDU.call_args_list[0][0][0]
        sent2 = smpp.sendPDU.call_args_list[1][0][0]
        self.assertTrue(isinstance(recv1, SubmitSMResp))
        self.assertTrue(isinstance(recv1, sent1.requireAck))
        self.assertEqual(recv1.status, CommandStatus.ESME_ROK)
        self.verifyUnbindSuccess(smpp, sent2, recv2)
开发者ID:pyghassen,项目名称:jasmin,代码行数:32,代码来源:test_smpp_client.py

示例3: test_long_submit_sm_gsm0338

    def test_long_submit_sm_gsm0338(self):
        client = SMPPClientFactory(self.config)
        # Connect and bind
        yield client.connectAndBind()
        smpp = client.smpp

        smpp.PDUReceived = mock.Mock(wraps=smpp.PDUReceived)
        smpp.sendPDU = mock.Mock(wraps=smpp.sendPDU)
        smpp.startLongSubmitSmTransaction = mock.Mock(wraps=smpp.startLongSubmitSmTransaction)
        smpp.cancelLongSubmitSmTransactions = mock.Mock(wraps=smpp.cancelLongSubmitSmTransactions)
        
        # Send submit_sm
        SubmitSmPDU = self.opFactory.SubmitSM(
            source_addr=self.source_addr,
            destination_addr=self.destination_addr,
            short_message=self.concatenated2Msgs,
        )
        yield self.assertFailure(smpp.sendDataRequest(SubmitSmPDU), SMPPClientConnectionCorruptedError)
        
        # Unbind & Disconnect
        yield smpp.unbindAndDisconnect()
        
        ##############
        # Assertions :
        self.assertEquals(1, smpp.PDUReceived.call_count)
        self.assertEquals(2, smpp.sendPDU.call_count)
        recv1 = smpp.PDUReceived.call_args_list[0][0][0]
        sent1 = smpp.sendPDU.call_args_list[0][0][0]
        self.assertEqual(recv1.status, CommandStatus.ESME_RINVCMDLEN)
        self.assertEqual(2, sent1.params['sar_total_segments'])
        self.assertEqual(1, sent1.params['sar_segment_seqnum'])
        self.assertEqual(0, len(smpp.longSubmitSmTxns))
        self.assertEquals(1, smpp.startLongSubmitSmTransaction.call_count)
        self.assertEquals(1, smpp.cancelLongSubmitSmTransactions.call_count)
开发者ID:pyghassen,项目名称:jasmin,代码行数:34,代码来源:test_smpp_client.py

示例4: test_reconnect_on_authentication_failure

    def test_reconnect_on_authentication_failure(self):
        client = SMPPClientFactory(self.config)
        client.reConnect = mock.Mock(wraps=client.reConnect)
        # Connect and bind
        yield client.connectAndBind()

        smpp = client.smpp
        reactor.callLater(5, client.disconnectAndDontRetryToConnect)
        
        # Normally, the client shall not exit since it should retry to connect
        # Triggering the exitDeferred callback is a way to continue this test
        reactor.callLater(6, client.exitDeferred.callback, None)
        
        yield client.getExitDeferred()
        
        ##############
        # Assertions :
        # Protocol verification
        self.assertNotEqual(0, client.reConnect.call_count)
开发者ID:pyghassen,项目名称:jasmin,代码行数:19,代码来源:test_smpp_client.py

示例5: test_reconnect_on_connection_failure

    def test_reconnect_on_connection_failure(self):
        client = SMPPClientFactory(self.config)
        client.reConnect = mock.Mock(wraps=client.reConnect)
        # Connect and bind
        yield client.connectAndBind()
        smpp = client.smpp

        smpp.PDUReceived = mock.Mock(wraps=smpp.PDUReceived)
        smpp.sendPDU = mock.Mock(wraps=smpp.sendPDU)

        # Unbind & Disconnect
        yield client.disconnect()
        
        ##############
        # Assertions :
        # Protocol verification
        self.assertEquals(1, smpp.PDUReceived.call_count)
        self.assertEquals(1, smpp.sendPDU.call_count)
        self.assertNotEqual(0, client.reConnect.call_count)
开发者ID:pyghassen,项目名称:jasmin,代码行数:19,代码来源:test_smpp_client.py

示例6: SMPPClientService

class SMPPClientService(service.Service):
    def __init__(self, SMPPClientConfig, config):
        self.startCounter = 0
        self.stopCounter = 0
        self.config = config
        self.SMPPClientConfig = SMPPClientConfig
        self.SMPPClientFactory = SMPPClientFactory(SMPPClientConfig)
        self.SMPPClientServiceConfig = SMPPClientServiceConfig(self.config.getConfigFile())

        # Set up a dedicated logger
        self.log = logging.getLogger(LOG_CATEGORY)
        if len(self.log.handlers) != 1:
            self.log.setLevel(self.SMPPClientServiceConfig.log_level)
            handler = TimedRotatingFileHandler(
                filename=self.SMPPClientServiceConfig.log_file,
                when=self.SMPPClientServiceConfig.log_rotate)
            formatter = logging.Formatter(self.SMPPClientServiceConfig.log_format,
                                          self.SMPPClientServiceConfig.log_date_format)
            handler.setFormatter(formatter)
            self.log.addHandler(handler)
            self.log.propagate = False

        self.log.info('New SMPPClientService for [%s]', self.SMPPClientConfig.id)

    def startService(self):
        self.startCounter += 1
        service.Service.startService(self)

        self.log.info('Started service for [%s]', self.SMPPClientConfig.id)
        return self.SMPPClientFactory.connectAndBind().addErrback(self._startServiceErr)

    def stopService(self):
        self.stopCounter += 1
        service.Service.stopService(self)

        self.log.info('Stopped service for [%s]', self.SMPPClientConfig.id)
        return self.SMPPClientFactory.disconnectAndDontRetryToConnect()

    def _startServiceErr(self, reason):
        self.log.info('Service starting failed with reason: %s', reason)
        self.stopService()
开发者ID:AVert,项目名称:jasmin,代码行数:41,代码来源:services.py

示例7: test_submit_sm_receiver_failure

    def test_submit_sm_receiver_failure(self):
        client = SMPPClientFactory(self.config)
        # Connect and bind
        yield client.connectAndBind()
        smpp = client.smpp

        smpp.PDUReceived = mock.Mock(wraps=smpp.PDUReceived)
        smpp.sendPDU = mock.Mock(wraps=smpp.sendPDU)
        
        # Send submit_sm
        SubmitSmPDU = self.opFactory.SubmitSM(
            source_addr=self.source_addr,
            destination_addr=self.destination_addr,
            short_message=self.shortMsg,
        )
        try:
            yield smpp.sendDataRequest(SubmitSmPDU)
        except SMPPTransactionError:
            pass
        else:
            self.assertTrue(False, "SMPPTransactionError not raised")
开发者ID:pyghassen,项目名称:jasmin,代码行数:21,代码来源:test_smpp_client.py

示例8: test_bind_with_systemType_defined

    def test_bind_with_systemType_defined(self):
        "Testing for #64, systemType must be always string"

        # Test 1: systemType in string
        self.config.bindOperation = 'transmitter'
        self.config.systemType = '999999'
        client = SMPPClientFactory(self.config)
        # Connect and bind
        yield client.connectAndBind()
        smpp = client.smpp
        
        # Session state check
        self.assertEqual(SMPPSessionStates.BOUND_TX, smpp.sessionState)

        # Unbind & Disconnect
        yield client.disconnect()

        # Test 1: systemType in integer
        self.config.systemType = 999999
        client = SMPPClientFactory(self.config)
        # Connect and bind
        yield client.connectAndBind()
        smpp = client.smpp
        
        # Session state check
        self.assertEqual(SMPPSessionStates.BIND_TX_PENDING, smpp.sessionState)

        # Unbind & Disconnect
        yield client.disconnect()
开发者ID:AlternativeValue-ALVA,项目名称:jasmin,代码行数:29,代码来源:test_smpp_client.py

示例9: test_long_submit_sm_7bit

    def test_long_submit_sm_7bit(self):
        client = SMPPClientFactory(self.config)
        # Connect and bind
        yield client.connectAndBind()
        smpp = client.smpp
        self.prepareMocks(smpp)

        # Send submit_sm
        content = self.composeMessage(GSM0338, 1224) # 1224 = 153 * 8
        SubmitSmPDU = self.opFactory.SubmitSM(
            source_addr=self.source_addr,
            destination_addr=self.destination_addr,
            short_message=content,
            data_coding = 0,
        )
        yield smpp.sendDataRequest(SubmitSmPDU)
        
        # Unbind & Disconnect
        yield smpp.unbindAndDisconnect()
        
        ##############
        # Assertions :
        self.runAsserts(smpp, content, len(content) / 153)
开发者ID:pyghassen,项目名称:jasmin,代码行数:23,代码来源:test_smpp_client.py

示例10: test_bind_unbind_transceiver

    def test_bind_unbind_transceiver(self):
        client = SMPPClientFactory(self.config)
        # Connect and bind
        yield client.connectAndBind()
        smpp = client.smpp
        
        smpp.PDUReceived = mock.Mock(wraps=smpp.PDUReceived)
        smpp.sendPDU = mock.Mock(wraps=smpp.sendPDU)

        # Session state check
        self.assertEqual(SMPPSessionStates.BOUND_TRX, smpp.sessionState)

        # Unbind & Disconnect
        yield client.disconnect()
        
        ##############
        # Assertions :
        # Protocol verification
        recv1, sent1 = self.verify(smpp, UnbindResp)
        # Unbind successfull
        self.assertEqual(recv1.status, CommandStatus.ESME_ROK)
        # Session state check
        self.assertEqual(SMPPSessionStates.UNBOUND, smpp.sessionState)
开发者ID:pyghassen,项目名称:jasmin,代码行数:23,代码来源:test_smpp_client.py

示例11: test_long_submit_sm_16bit

    def test_long_submit_sm_16bit(self):
        client = SMPPClientFactory(self.config)
        # Connect and bind
        yield client.connectAndBind()
        smpp = client.smpp
        self.prepareMocks(smpp)

        # Send submit_sm
        UCS2 = {'\x0623', '\x0631', '\x0646', '\x0628'}
        content = self.composeMessage(UCS2, 536) # 536 = 67 * 8
        SubmitSmPDU = self.opFactory.SubmitSM(
            source_addr=self.source_addr,
            destination_addr=self.destination_addr,
            short_message=content,
            data_coding = 8,
        )
        yield smpp.sendDataRequest(SubmitSmPDU)
        
        # Unbind & Disconnect
        yield smpp.unbindAndDisconnect()
        
        ##############
        # Assertions :
        self.runAsserts(smpp, content, len(content) / 67)
开发者ID:pyghassen,项目名称:jasmin,代码行数:24,代码来源:test_smpp_client.py

示例12: __init__

    def __init__(self, SMPPClientConfig, config):
        self.startCounter = 0
        self.stopCounter = 0
        self.config = config
        self.SMPPClientConfig = SMPPClientConfig
        self.SMPPClientFactory = SMPPClientFactory(SMPPClientConfig)
        self.SMPPClientServiceConfig = SMPPClientServiceConfig(self.config.getConfigFile())

        # Set up a dedicated logger
        self.log = logging.getLogger(LOG_CATEGORY)
        if len(self.log.handlers) != 1:
            self.log.setLevel(self.SMPPClientServiceConfig.log_level)
            handler = logging.FileHandler(filename=self.SMPPClientServiceConfig.log_file)
            formatter = logging.Formatter(self.SMPPClientServiceConfig.log_format, self.SMPPClientServiceConfig.log_date_format)
            handler.setFormatter(formatter)
            self.log.addHandler(handler)
            self.log.propagate = False

        self.log.info('New SMPPClientService for [%s]', self.SMPPClientConfig.id)
开发者ID:Baalmart,项目名称:jasmin,代码行数:19,代码来源:services.py

示例13: test_multiple_clients

    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)
开发者ID:pyghassen,项目名称:jasmin,代码行数:38,代码来源:test_smpp_client.py

示例14: buildProtocol

 def buildProtocol(self, addr):
     self.lastProto = SMPPClientFactory.buildProtocol(self, addr)
     return self.lastProto
开发者ID:AVert,项目名称:jasmin,代码行数:3,代码来源:test_router_smpps.py

示例15: test_bind_to_blackhole

 def test_bind_to_blackhole(self):
     client = SMPPClientFactory(self.config)
     # Connect and bind
     yield self.assertFailure(client.connectAndBind(), SMPPSessionInitTimoutError)
开发者ID:pyghassen,项目名称:jasmin,代码行数:4,代码来源:test_smpp_client.py


注:本文中的jasmin.protocols.smpp.factory.SMPPClientFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。