本文整理汇总了Python中jasmin.protocols.smpp.stats.SMPPServerStatsCollector类的典型用法代码示例。如果您正苦于以下问题:Python SMPPServerStatsCollector类的具体用法?Python SMPPServerStatsCollector怎么用?Python SMPPServerStatsCollector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SMPPServerStatsCollector类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_will_reuse_existent_connector
def test_get_will_reuse_existent_connector(self):
c = SMPPServerStatsCollector()
self.assertTrue('test_get_will_reuse_existent_connector' not in c.connectors)
i1 = c.get(cid = 'test_get_will_reuse_existent_connector')
i2 = c.get(cid = 'test_get_will_reuse_existent_connector')
self.assertEqual(i1, i2)
示例2: test_exceptions
def test_exceptions(self):
stats = SMPPServerStatsCollector().get(cid = 'test_exceptions')
self.assertRaises(KeyNotFound, stats.get, 'anything')
self.assertRaises(KeyNotFound, stats.set, 'anything', 22)
self.assertRaises(KeyNotFound, stats.inc, 'anything')
stats.set('created_at', datetime.now())
self.assertRaises(KeyNotIncrementable, stats.inc, 'created_at')
示例3: test_stats_inc
def test_stats_inc(self):
stats = SMPPServerStatsCollector().get(cid = 'test_stats_inc')
self.assertEqual(stats.get('bound_tx_count'), 0)
stats.inc('bound_tx_count')
self.assertEqual(stats.get('bound_tx_count'), 1)
stats.inc('bound_tx_count', 5)
self.assertEqual(stats.get('bound_tx_count'), 6)
示例4: test_02_enquire_link
def test_02_enquire_link(self):
self.smppc_config.enquireLinkTimerSecs = 1
stats = SMPPServerStatsCollector().get(cid = self.smpps_config.id)
self.assertEqual(stats.get('last_received_elink_at'), 0)
# Connect and bind
yield self.smppc_factory.connectAndBind()
self.assertEqual(self.smppc_factory.smpp.sessionState, SMPPSessionStates.BOUND_TRX)
# Wait some secs in order to receive some elinks
yield waitFor(6)
# Unbind & Disconnect
yield self.smppc_factory.smpp.unbindAndDisconnect()
self.assertEqual(self.smppc_factory.smpp.sessionState, SMPPSessionStates.UNBOUND)
self.assertTrue(type(stats.get('last_received_elink_at')) == datetime)
示例5: smppsapi
def smppsapi(self, arg, opts):
"""As of Jasmin's 0.6 version, there can be only one SMPPs API, the smpp server id
is set for later evolution to handle multiple APIs, this is why the id is hard coded
to 'smpps_01'.
"""
sc = SMPPServerStatsCollector()
headers = ["#Item", "Value"]
table = []
for k, v in sc.get('smpps_01')._stats.iteritems():
row = []
row.append('#%s' % k)
if k[-3:] == '_at':
row.append(formatDateTime(v))
else:
row.append(v)
table.append(row)
self.protocol.sendData(tabulate(table, headers, tablefmt="plain", numalign="left").encode('ascii'))
示例6: setUp
def setUp(self):
SMPPClientTestCases.setUp(self)
# Provision a user and default route into RouterPB
# Add throughput limit on user
self.foo = User('u1', Group('test'), 'username', 'password')
self.foo.mt_credential.setQuota('smpps_throughput', 2)
self.c1 = SmppClientConnector(id_generator())
self.defaultroute = DefaultRoute(self.c1)
self.provision_user_defaultroute(user = self.foo, defaultroute = self.defaultroute)
self.stats = SMPPServerStatsCollector().get(cid = self.smpps_config.id)
示例7: test_is_singleton
def test_is_singleton(self):
i1 = SMPPServerStatsCollector()
i2 = SMPPServerStatsCollector()
self.assertEqual(i1, i2)
i1.get(cid = 'testing').set('bind_rx_count', 100)
self.assertEqual(i1.get(cid = 'testing').get('bind_rx_count'),
i2.get(cid = 'testing').get('bind_rx_count'),
)
示例8: test_get_will_create_connector
def test_get_will_create_connector(self):
c = SMPPServerStatsCollector()
self.assertTrue('test_get_will_create_connector' not in c.connectors)
c.get(cid = 'test_get_will_create_connector')
self.assertTrue('test_get_will_create_connector' in c.connectors)
示例9: test_stats_set
def test_stats_set(self):
stats = SMPPServerStatsCollector().get(cid = 'test_stats_set')
self.assertEqual(stats.get('bind_rx_count'), 0)
stats.set('bind_rx_count', 2)
self.assertEqual(stats.get('bind_rx_count'), 2)
示例10: test_01_smpps_basic
def test_01_smpps_basic(self):
"A simple test of _some_ stats parameters"
stats = SMPPServerStatsCollector().get(cid = self.smpps_config.id)
self.assertTrue(type(stats.get('created_at')) == datetime)
self.assertEqual(stats.get('last_received_pdu_at'), 0)
self.assertEqual(stats.get('last_sent_pdu_at'), 0)
self.assertEqual(stats.get('connected_count'), 0)
self.assertEqual(stats.get('connect_count'), 0)
self.assertEqual(stats.get('disconnect_count'), 0)
self.assertEqual(stats.get('bound_trx_count'), 0)
self.assertEqual(stats.get('bound_rx_count'), 0)
self.assertEqual(stats.get('bound_tx_count'), 0)
self.assertEqual(stats.get('bind_trx_count'), 0)
self.assertEqual(stats.get('bind_rx_count'), 0)
self.assertEqual(stats.get('bind_tx_count'), 0)
self.assertEqual(stats.get('unbind_count'), 0)
# Connect and bind
yield self.smppc_factory.connectAndBind()
self.assertEqual(self.smppc_factory.smpp.sessionState, SMPPSessionStates.BOUND_TRX)
self.assertTrue(type(stats.get('created_at')) == datetime)
self.assertTrue(type(stats.get('last_received_pdu_at')) == datetime)
self.assertTrue(type(stats.get('last_sent_pdu_at')) == datetime)
self.assertEqual(stats.get('connected_count'), 1)
self.assertEqual(stats.get('connect_count'), 1)
self.assertEqual(stats.get('disconnect_count'), 0)
self.assertEqual(stats.get('bound_trx_count'), 1)
self.assertEqual(stats.get('bound_rx_count'), 0)
self.assertEqual(stats.get('bound_tx_count'), 0)
self.assertEqual(stats.get('bind_trx_count'), 1)
self.assertEqual(stats.get('bind_rx_count'), 0)
self.assertEqual(stats.get('bind_tx_count'), 0)
self.assertEqual(stats.get('unbind_count'), 0)
# Unbind & Disconnect
yield self.smppc_factory.smpp.unbindAndDisconnect()
self.assertEqual(self.smppc_factory.smpp.sessionState, SMPPSessionStates.UNBOUND)
self.assertTrue(type(stats.get('created_at')) == datetime)
self.assertTrue(type(stats.get('last_received_pdu_at')) == datetime)
self.assertTrue(type(stats.get('last_sent_pdu_at')) == datetime)
self.assertEqual(stats.get('connected_count'), 0)
self.assertEqual(stats.get('connect_count'), 1)
self.assertEqual(stats.get('disconnect_count'), 1)
self.assertEqual(stats.get('bound_trx_count'), 0)
self.assertEqual(stats.get('bound_rx_count'), 0)
self.assertEqual(stats.get('bound_tx_count'), 0)
self.assertEqual(stats.get('bind_trx_count'), 1)
self.assertEqual(stats.get('bind_rx_count'), 0)
self.assertEqual(stats.get('bind_tx_count'), 0)
self.assertEqual(stats.get('unbind_count'), 1)
示例11: SmppsStatsTestCases
class SmppsStatsTestCases(SMPPClientTestCases):
def setUp(self):
SMPPClientTestCases.setUp(self)
# Provision a user and default route into RouterPB
# Add throughput limit on user
self.foo = User('u1', Group('test'), 'username', 'password')
self.foo.mt_credential.setQuota('smpps_throughput', 2)
self.c1 = SmppClientConnector(id_generator())
self.defaultroute = DefaultRoute(self.c1)
self.provision_user_defaultroute(user = self.foo, defaultroute = self.defaultroute)
self.stats = SMPPServerStatsCollector().get(cid = self.smpps_config.id)
@defer.inlineCallbacks
def test_elink_count(self):
self.smppc_config.enquireLinkTimerSecs = 1
# Save the 'before' value
_elink_count = self.stats.get('elink_count')
# Connect and bind
yield self.smppc_factory.connectAndBind()
self.assertEqual(self.smppc_factory.smpp.sessionState, SMPPSessionStates.BOUND_TRX)
# Wait
yield waitFor(5)
# Unbind & Disconnect
yield self.smppc_factory.smpp.unbindAndDisconnect()
self.assertEqual(self.smppc_factory.smpp.sessionState, SMPPSessionStates.UNBOUND)
# Asserts
self.assertEqual(_elink_count+4, self.stats.get('elink_count'))
@defer.inlineCallbacks
def test_throttling_error_count(self):
"""In this test it is demonstrated the
difference between submit_sm_request_count and submit_sm_count:
* submit_sm_request_count: is the number of submit_sm requested
* submit_sm_count: is number of submit_sm accepted (replied with ESME_ROK)
"""
# Connect and bind
yield self.smppc_factory.connectAndBind()
self.assertEqual(self.smppc_factory.smpp.sessionState, SMPPSessionStates.BOUND_TRX)
# Save the 'before' value
_submit_sm_request_count = self.stats.get('submit_sm_request_count')
_throttling_error_count = self.stats.get('throttling_error_count')
_other_submit_error_count = self.stats.get('other_submit_error_count')
_submit_sm_count = self.stats.get('submit_sm_count')
# SMPPClient > SMPPServer
for _ in range(50):
yield self.smppc_factory.lastProto.sendDataRequest(self.SubmitSmPDU)
yield waitFor(0.1)
# Assert after
self.assertEqual(self.stats.get('submit_sm_request_count'), _submit_sm_request_count+50)
self.assertEqual(self.stats.get('other_submit_error_count'), _other_submit_error_count)
self.assertLess(self.stats.get('throttling_error_count'), _submit_sm_request_count+50)
self.assertGreater(self.stats.get('throttling_error_count'), 0)
self.assertGreater(self.stats.get('submit_sm_count'), _submit_sm_count)
# Unbind & Disconnect
yield self.smppc_factory.smpp.unbindAndDisconnect()
self.assertEqual(self.smppc_factory.smpp.sessionState, SMPPSessionStates.UNBOUND)
@defer.inlineCallbacks
def test_other_submit_error_count(self):
"""Send a submit_sm wile bound_rx: will get a resp with ESME_RINVBNDSTS
Will also ensure
"""
self.smppc_config.bindOperation = 'receiver'
# Connect and bind
yield self.smppc_factory.connectAndBind()
self.assertEqual(self.smppc_factory.smpp.sessionState, SMPPSessionStates.BOUND_RX)
# Save the 'before' value
_other_submit_error_count = self.stats.get('other_submit_error_count')
_throttling_error_count = self.stats.get('throttling_error_count')
# SMPPClient > SMPPServer
yield self.smppc_factory.lastProto.sendDataRequest(self.SubmitSmPDU)
# Assert after
self.assertEqual(self.stats.get('other_submit_error_count'), _other_submit_error_count+1)
self.assertEqual(self.stats.get('throttling_error_count'), _throttling_error_count)
# Unbind & Disconnect
yield self.smppc_factory.smpp.unbindAndDisconnect()
self.assertEqual(self.smppc_factory.smpp.sessionState, SMPPSessionStates.UNBOUND)
@defer.inlineCallbacks
def test_deliver_sm_count(self):
# Connect and bind
#.........这里部分代码省略.........