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_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 ] )
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 ] )
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 ] )
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_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 ] )
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 ] )
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)
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)