def test_enquire_link(self):
        client = SMPPClientTransmitter(self.config)
        smpp = yield client.connect()
        #Assert that enquireLinkTimer is not yet active on connection
        self.assertEquals(None, smpp.enquireLinkTimer)
        
        bindDeferred = client.bind(smpp)
        #Assert that enquireLinkTimer is not yet active until bind is complete
        self.assertEquals(None, smpp.enquireLinkTimer)
        yield bindDeferred
        #Assert that enquireLinkTimer is now active after bind is complete
        self.assertNotEquals(None, smpp.enquireLinkTimer)
        
        #Wrap functions for tracking
        smpp.sendPDU = mock.Mock(wraps=smpp.sendPDU)
        smpp.PDUReceived = mock.Mock(wraps=smpp.PDUReceived)
        
        yield self.wait(0.25)
        
        self.verifyEnquireLink(smpp)
        
        #Assert that enquireLinkTimer is still active
        self.assertNotEquals(None, smpp.enquireLinkTimer)
        
        unbindDeferred = smpp.unbind()

        #Assert that enquireLinkTimer is no longer active after unbind is issued
        self.assertEquals(None, smpp.enquireLinkTimer)
        
        yield unbindDeferred
        #Assert that enquireLinkTimer is no longer active after unbind is complete
        self.assertEquals(None, smpp.enquireLinkTimer)
        yield smpp.disconnect()
Exemple #2
0
    def test_enquire_link(self):
        client = SMPPClientTransmitter(self.config)
        smpp = yield client.connect()
        #Assert that enquireLinkTimer is not yet active on connection
        self.assertEquals(None, smpp.enquireLinkTimer)

        bindDeferred = client.bind(smpp)
        #Assert that enquireLinkTimer is not yet active until bind is complete
        self.assertEquals(None, smpp.enquireLinkTimer)
        yield bindDeferred
        #Assert that enquireLinkTimer is now active after bind is complete
        self.assertNotEquals(None, smpp.enquireLinkTimer)

        #Wrap functions for tracking
        smpp.sendPDU = mock.Mock(wraps=smpp.sendPDU)
        smpp.PDUReceived = mock.Mock(wraps=smpp.PDUReceived)

        yield self.wait(0.25)

        self.verifyEnquireLink(smpp)

        #Assert that enquireLinkTimer is still active
        self.assertNotEquals(None, smpp.enquireLinkTimer)

        unbindDeferred = smpp.unbind()

        #Assert that enquireLinkTimer is no longer active after unbind is issued
        self.assertEquals(None, smpp.enquireLinkTimer)

        yield unbindDeferred
        #Assert that enquireLinkTimer is no longer active after unbind is complete
        self.assertEquals(None, smpp.enquireLinkTimer)
        yield smpp.disconnect()
 def test_alert_notification(self):
     client = SMPPClientTransmitter(self.config)
     smpp = yield client.connectAndBind()
     
     alertNotificationDeferred = defer.Deferred()
     alertHandler = mock.Mock(wraps=lambda smpp, pdu: alertNotificationDeferred.callback(None))
     smpp.setAlertNotificationHandler(alertHandler)
             
     sendDataDeferred = smpp.sendDataRequest(DataSM())
     
     smpp.sendPDU = mock.Mock(wraps=smpp.sendPDU)
     smpp.PDUReceived = mock.Mock(wraps=smpp.PDUReceived)
     
     yield sendDataDeferred
     yield alertNotificationDeferred
     yield smpp.unbindAndDisconnect()
     
     self.assertEquals(1, alertHandler.call_count)
     self.assertEquals(smpp, alertHandler.call_args[0][0])
     self.assertTrue(isinstance(alertHandler.call_args[0][1], AlertNotification))
     
     self.assertEquals(1, smpp.sendPDU.call_count)
     self.assertEquals(3, smpp.PDUReceived.call_count)
     sent1 = smpp.sendPDU.call_args[0][0]
     recv1 = smpp.PDUReceived.call_args_list[0][0][0]
     recv2 = smpp.PDUReceived.call_args_list[1][0][0]
     recv3 = smpp.PDUReceived.call_args_list[2][0][0]
     self.assertTrue(isinstance(recv1, DataSMResp))
     self.assertTrue(isinstance(recv2, AlertNotification))
     self.assertTrue(isinstance(sent1, Unbind))
     self.assertTrue(isinstance(recv3, UnbindResp))
Exemple #4
0
    def test_alert_notification(self):
        client = SMPPClientTransmitter(self.config)
        smpp = yield client.connectAndBind()

        alertNotificationDeferred = defer.Deferred()
        alertHandler = mock.Mock(
            wraps=lambda smpp, pdu: alertNotificationDeferred.callback(None))
        smpp.setAlertNotificationHandler(alertHandler)

        sendDataDeferred = smpp.sendDataRequest(DataSM())

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

        yield sendDataDeferred
        yield alertNotificationDeferred
        yield smpp.unbindAndDisconnect()

        self.assertEquals(1, alertHandler.call_count)
        self.assertEquals(smpp, alertHandler.call_args[0][0])
        self.assertTrue(
            isinstance(alertHandler.call_args[0][1], AlertNotification))

        self.assertEquals(1, smpp.sendPDU.call_count)
        self.assertEquals(3, smpp.PDUReceived.call_count)
        sent1 = smpp.sendPDU.call_args[0][0]
        recv1 = smpp.PDUReceived.call_args_list[0][0][0]
        recv2 = smpp.PDUReceived.call_args_list[1][0][0]
        recv3 = smpp.PDUReceived.call_args_list[2][0][0]
        self.assertTrue(isinstance(recv1, DataSMResp))
        self.assertTrue(isinstance(recv2, AlertNotification))
        self.assertTrue(isinstance(sent1, Unbind))
        self.assertTrue(isinstance(recv3, UnbindResp))
 def test_unbind_timeout(self):
     client = SMPPClientTransmitter(self.config)
     bindDeferred = client.connectAndBind().addCallback(self.do_unbind)
     return defer.DeferredList([
         bindDeferred, #asserts that bind was successful
         self.assertFailure(self.unbindDeferred, SMPPSessionInitTimoutError), #asserts that unbind timed out
         ]
     )
Exemple #6
0
 def test_unbind_timeout(self):
     client = SMPPClientTransmitter(self.config)
     bindDeferred = client.connectAndBind().addCallback(self.do_unbind)
     return defer.DeferredList([
         bindDeferred,  #asserts that bind was successful
         self.assertFailure(
             self.unbindDeferred,
             SMPPSessionInitTimoutError),  #asserts that unbind timed out
     ])
Exemple #7
0
 def test_inactivity_timeout(self):
     client = SMPPClientTransmitter(self.config)
     bindDeferred = client.connectAndBind().addCallback(self.do_test_setup)
     self.disconnectDeferred.addCallback(self.verify)
     return defer.DeferredList([
         bindDeferred,  #asserts that bind was successful
         self.
         disconnectDeferred,  #asserts that disconnect deferred was triggered
     ])
 def test_inactivity_timeout(self):
     client = SMPPClientTransmitter(self.config)
     bindDeferred = client.connectAndBind().addCallback(self.do_test_setup)
     self.disconnectDeferred.addCallback(self.verify)
     return defer.DeferredList([
         bindDeferred, #asserts that bind was successful
         self.disconnectDeferred, #asserts that disconnect deferred was triggered
         ]
     )
Exemple #9
0
 def test_alert_notification(self):
     client = SMPPClientTransmitter(self.config)
     bindDeferred = client.connectAndBind().addCallback(self.do_test)
     return defer.DeferredList([
         bindDeferred, #asserts that bind was successful
         self.dataSMDeferred, #asserts that data_sm was successful
         self.alertNotificationDeferred, #asserts that alert notification handler was invoked
         self.disconnectDeferred.addCallback(self.verify), #asserts that disconnect was successful
     ])
Exemple #10
0
 def test_unbind(self):
     client = SMPPClientTransmitter(self.config)
     bindDeferred = client.connectAndBind().addCallback(self.do_lifecycle)
     return defer.DeferredList([
         bindDeferred,  #asserts that bind was successful
         self.submitSMDeferred,  #asserts that submit was successful
         self.unbindDeferred,  #asserts that unbind was successful
         self.disconnectDeferred,  #asserts that disconnect was successful
     ])
 def test_unbind(self):
     client = SMPPClientTransmitter(self.config)
     bindDeferred = client.connectAndBind().addCallback(self.do_lifecycle)
     return defer.DeferredList([
         bindDeferred, #asserts that bind was successful
         self.submitSMDeferred, #asserts that submit was successful
         self.unbindDeferred, #asserts that unbind was successful
         self.disconnectDeferred, #asserts that disconnect was successful
         ]
     )
 def test_server_unbind(self):
     client = SMPPClientTransmitter(self.config)
     bindDeferred = client.connectAndBind().addCallback(self.mock_stuff)
     self.disconnectDeferred.addCallback(self.verify)
     return defer.DeferredList([
         bindDeferred, #asserts that bind was successful
         self.disconnectDeferred, #asserts that disconnect deferred was triggered,
         self.assertFailure(self.submitSMDeferred, SMPPClientSessionStateError), #asserts that outbound txn was canceled
         ]
     )
 def test_response_timeout(self):
     client = SMPPClientTransmitter(self.config)
     bindDeferred = client.connectAndBind().addCallback(self.do_test_setup)
     self.disconnectDeferred.addCallback(self.verify)
     return defer.DeferredList([
         bindDeferred, #asserts that bind was successful
         self.assertFailure(self.submitSMDeferred1, SMPPRequestTimoutError), #asserts that request1 timed out
         self.assertFailure(self.submitSMDeferred2, SMPPRequestTimoutError), #asserts that request2 timed out
         self.disconnectDeferred, #asserts that disconnect deferred was triggered
         ]
     )
Exemple #14
0
 def test_alert_notification(self):
     client = SMPPClientTransmitter(self.config)
     bindDeferred = client.connectAndBind().addCallback(self.do_test)
     return defer.DeferredList([
         bindDeferred,  #asserts that bind was successful
         self.dataSMDeferred,  #asserts that data_sm was successful
         self.
         alertNotificationDeferred,  #asserts that alert notification handler was invoked
         self.disconnectDeferred.addCallback(
             self.verify),  #asserts that disconnect was successful
     ])
Exemple #15
0
 def test_server_unbind(self):
     client = SMPPClientTransmitter(self.config)
     bindDeferred = client.connectAndBind().addCallback(self.mock_stuff)
     self.disconnectDeferred.addCallback(self.verify)
     return defer.DeferredList([
         bindDeferred,  #asserts that bind was successful
         self.
         disconnectDeferred,  #asserts that disconnect deferred was triggered,
         self.assertFailure(self.submitSMDeferred,
                            SMPPClientSessionStateError
                            ),  #asserts that outbound txn was canceled
     ])
Exemple #16
0
 def test_response_timeout(self):
     client = SMPPClientTransmitter(self.config)
     bindDeferred = client.connectAndBind().addCallback(self.do_test_setup)
     self.disconnectDeferred.addCallback(self.verify)
     return defer.DeferredList([
         bindDeferred,  #asserts that bind was successful
         self.assertFailure(
             self.submitSMDeferred1,
             SMPPRequestTimoutError),  #asserts that request1 timed out
         self.assertFailure(
             self.submitSMDeferred2,
             SMPPRequestTimoutError),  #asserts that request2 timed out
         self.
         disconnectDeferred,  #asserts that disconnect deferred was triggered
     ])
Exemple #17
0
 def test_bind_transmitter_timeout(self):
     client = SMPPClientTransmitter(self.config)
     svc = SMPPClientService(client)
     stopDeferred = svc.getStopDeferred()
     startDeferred = svc.startService()
     return defer.DeferredList([
         self.assertFailure(startDeferred, SMPPSessionInitTimoutError),
         self.assertFailure(stopDeferred, SMPPSessionInitTimoutError),
     ])
Exemple #18
0
 def test_bind_error_generic_nack(self):
     client = SMPPClientTransmitter(self.config)
     return self.assertFailure(client.connectAndBind(),
                               SMPPGenericNackTransactionError)
 def test_bind_error_generic_nack(self):
     client = SMPPClientTransmitter(self.config)
     return self.assertFailure(client.connectAndBind(), SMPPGenericNackTransactionError)
 def test_bind_transmitter_timeout(self):
     client = SMPPClientTransmitter(self.config)
     return self.assertFailure(client.connectAndBind(), SMPPSessionInitTimoutError)
Exemple #21
0
 def test_bind_transmitter_timeout(self):
     client = SMPPClientTransmitter(self.config)
     return self.assertFailure(client.connectAndBind(),
                               SMPPSessionInitTimoutError)