def test_error_on_submit(self): client = SMPPClientTransceiver(self.config, lambda smpp, pdu: None) smpp = yield client.connectAndBind() try: yield smpp.sendDataRequest(SubmitSM()) except SMPPTransactionError: pass else: self.assertTrue(False, "SMPPTransactionError not raised") finally: yield smpp.unbindAndDisconnect()
def test_generic_nack_no_seq_num(self): client = SMPPClientTransceiver(self.config, lambda smpp, pdu: None) smpp = yield client.connectAndBind() try: submitDeferred = smpp.sendDataRequest(SubmitSM()) smpp.sendPDU = mock.Mock(wraps=smpp.sendPDU) yield submitDeferred except SMPPClientConnectionCorruptedError: pass else: self.assertTrue(False, "SMPPClientConnectionCorruptedError not raised") #for nack with no seq num, the connection is corrupt so don't unbind() self.assertEquals(0, smpp.sendPDU.call_count)
def test_nack_on_invalid_msg(self): client = SMPPClientTransceiver(self.config, lambda smpp, pdu: None) smpp = yield client.connectAndBind() msgSentDeferred = defer.Deferred() smpp.sendPDU = mock.Mock() smpp.sendPDU.side_effect = functools.partial(self.mock_side_effect, msgSentDeferred) yield msgSentDeferred yield smpp.disconnect() self.assertEquals(1, smpp.sendPDU.call_count) smpp.sendPDU.assert_called_with(QuerySMResp(seqNum=self.protocol.seqNum, status=CommandStatus.ESME_RINVSRCTON))
def test_generic_nack_on_invalid_cmd_id(self): client = SMPPClientTransceiver(self.config, lambda smpp, pdu: None) smpp = yield client.connectAndBind() msgSentDeferred = defer.Deferred() smpp.sendPDU = mock.Mock() smpp.sendPDU.side_effect = functools.partial(self.mock_side_effect, msgSentDeferred) yield msgSentDeferred yield smpp.disconnect() self.assertEquals(1, smpp.sendPDU.call_count) smpp.sendPDU.assert_called_with(GenericNack(status=CommandStatus.ESME_RINVCMDID))
def run(self): try: #Bind smpp = yield SMPPClientTransceiver( self.config, self.handleMsg).connectAndBind() #Wait for disconnect yield smpp.getDisconnectedDeferred() except Exception, e: print "ERROR: %s" % str(e)
def test_bind_transceiver_timeout(self): client = SMPPClientTransceiver(self.config, lambda smpp, pdu: None) return self.assertFailure(client.connectAndBind(), SMPPSessionInitTimoutError)