當前位置: 首頁>>代碼示例>>Python>>正文


Python stats.SMPPServerStatsCollector類代碼示例

本文整理匯總了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)
開發者ID:akibsayyed,項目名稱:jasmin,代碼行數:7,代碼來源:test_stats.py

示例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')
開發者ID:akibsayyed,項目名稱:jasmin,代碼行數:8,代碼來源:test_stats.py

示例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)
開發者ID:akibsayyed,項目名稱:jasmin,代碼行數:9,代碼來源:test_stats.py

示例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)
開發者ID:balsagoth,項目名稱:jasmin,代碼行數:18,代碼來源:test_smpp_server.py

示例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'))
開發者ID:ktosiu,項目名稱:jasmin,代碼行數:20,代碼來源:statsm.py

示例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)
開發者ID:balsagoth,項目名稱:jasmin,代碼行數:12,代碼來源:test_smpp_server.py

示例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'),
						 )
開發者ID:akibsayyed,項目名稱:jasmin,代碼行數:10,代碼來源:test_stats.py

示例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)
開發者ID:akibsayyed,項目名稱:jasmin,代碼行數:6,代碼來源:test_stats.py

示例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)
開發者ID:akibsayyed,項目名稱:jasmin,代碼行數:6,代碼來源:test_stats.py

示例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)
開發者ID:balsagoth,項目名稱:jasmin,代碼行數:53,代碼來源:test_smpp_server.py

示例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
#.........這裏部分代碼省略.........
開發者ID:balsagoth,項目名稱:jasmin,代碼行數:101,代碼來源:test_smpp_server.py


注:本文中的jasmin.protocols.smpp.stats.SMPPServerStatsCollector類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。