本文整理汇总了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)
示例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)
示例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)
示例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)
示例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)
示例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()
示例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")
示例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()
示例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)
示例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)
示例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)
示例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)
示例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)
示例14: buildProtocol
def buildProtocol(self, addr):
self.lastProto = SMPPClientFactory.buildProtocol(self, addr)
return self.lastProto
示例15: test_bind_to_blackhole
def test_bind_to_blackhole(self):
client = SMPPClientFactory(self.config)
# Connect and bind
yield self.assertFailure(client.connectAndBind(), SMPPSessionInitTimoutError)