示例#1
0
 def setUp(self):
     self.callActor = CallActor()
     self.sccpPhone = Mock()
     self.callActor.setPhone(self.sccpPhone)
     self.timerProvider = Mock()
     self.callActor.setTimerProvider(self.timerProvider)
     self.callActor.setAutoAnswer(True)
示例#2
0
 def setUp(self):
     self.callActor = CallActor()
     self.sccpPhone = Mock()
     self.callActor.setPhone(self.sccpPhone)
     self.timerProvider = Mock()
     self.callActor.setTimerProvider(self.timerProvider)
     self.callActor.setAutoAnswer(True)
示例#3
0
    def createPhone(self,deviceName):
        
        
        mainPhoneView = PhoneView(SERVER_HOST,deviceName,self.onConnect)
        self.phoneBox.addLayout(mainPhoneView)

        callActor = CallActor()
        actorView = ActorView(callActor)
        mainPhoneView.addLayout(actorView)

        sccpPhone = SCCPPhone(SERVER_HOST,deviceName)
        sccpPhone.setLogger(self.log)
        sccpPhone.setTimerProvider(self)
        callActor.setPhone(sccpPhone)
        callActor.setTimerProvider(self)
        sccpPhone.addCallHandler(callActor)
        
        mainPhoneView.useSccpPhone(sccpPhone)
        self.phoneViews.append(mainPhoneView)
示例#4
0
    def createPhone(self, deviceName):
        mainPhoneView = PhoneView(config.SERVER_HOST, deviceName,
                                  self.onConnect)
        self.phoneBox.addLayout(mainPhoneView)

        callActor = CallActor()
        actorView = ActorView(callActor)
        mainPhoneView.addLayout(actorView)

        sccpPhone = SCCPPhone(config.SERVER_HOST, deviceName)
        sccpPhone.setLogger(self.log)
        sccpPhone.setTimerProvider(self)
        callActor.setPhone(sccpPhone)
        callActor.setTimerProvider(self)
        sccpPhone.addCallHandler(callActor)

        mainPhoneView.useSccpPhone(sccpPhone)
        self.phoneViews.append(mainPhoneView)
示例#5
0
class Test(unittest.TestCase):
    def setUp(self):
        self.callActor = CallActor()
        self.sccpPhone = Mock()
        self.callActor.setPhone(self.sccpPhone)
        self.timerProvider = Mock()
        self.callActor.setTimerProvider(self.timerProvider)
        self.callActor.setAutoAnswer(True)

    def testOnCallRinging(self):
        self.callActor.handleCall(1, 34,
                                  SCCPCallState.SCCP_CHANNELSTATE_RINGING)
        self.callActor.handleCall(1, 34,
                                  SCCPCallState.SCCP_CHANNELSTATE_OFFHOOK)
        self.sccpPhone.answerCall.assert_called_once_with()

    def testSecondCallRinging(self):
        self.callActor.handleCall(1, 34,
                                  SCCPCallState.SCCP_CHANNELSTATE_RINGING)
        self.callActor.handleCall(1, 38,
                                  SCCPCallState.SCCP_CHANNELSTATE_RINGING)
        self.sccpPhone.answerCall.assert_called_once_with()

    def testOtherCallRingingAndGointOffHook(self):
        self.callActor.handleCall(1, 34,
                                  SCCPCallState.SCCP_CHANNELSTATE_RINGING)
        self.callActor.handleCall(1, 38,
                                  SCCPCallState.SCCP_CHANNELSTATE_RINGING)
        self.callActor.handleCall(1, 38,
                                  SCCPCallState.SCCP_CHANNELSTATE_ONHOOK)
        self.callActor.handleCall(1, 40,
                                  SCCPCallState.SCCP_CHANNELSTATE_RINGING)
        self.sccpPhone.answerCall.assert_called_once_with()

    def testOnCallEstablished(self):

        self.callActor.handleCall(1, 34,
                                  SCCPCallState.SCCP_CHANNELSTATE_CONNECTED)

        self.timerProvider.createOneShotTimer.assert_called_with(ANY, ANY)

    def testOnCallEndTimer(self):
        self.callActor.handleCall(7, 34,
                                  SCCPCallState.SCCP_CHANNELSTATE_RINGING)

        self.callActor.onCallEndTimer()

        self.sccpPhone.endCall.assert_called_once_with(7, 34)

    def testAutoAnswer(self):
        self.callActor.setAutoAnswer(False)
        self.callActor.handleCall(1, 34,
                                  SCCPCallState.SCCP_CHANNELSTATE_RINGING)
        self.sccpPhone.answerCall.assert_never_called()
示例#6
0
class Test(unittest.TestCase):
    
    
    def setUp(self):
        self.callActor = CallActor()
        self.sccpPhone = Mock()
        self.callActor.setPhone(self.sccpPhone)
        self.timerProvider = Mock()
        self.callActor.setTimerProvider(self.timerProvider)
        self.callActor.setAutoAnswer(True)

        
    def testOnCallRinging(self):
        self.callActor.handleCall(1,34,SCCPCallState.SCCP_CHANNELSTATE_RINGING)
        self.callActor.handleCall(1,34,SCCPCallState.SCCP_CHANNELSTATE_OFFHOOK)
        self.sccpPhone.answerCall.assert_called_once_with()
        
    
    def testSecondCallRinging(self):
        self.callActor.handleCall(1,34,SCCPCallState.SCCP_CHANNELSTATE_RINGING)
        self.callActor.handleCall(1,38,SCCPCallState.SCCP_CHANNELSTATE_RINGING)
        self.sccpPhone.answerCall.assert_called_once_with()

    
    def testOtherCallRingingAndGointOffHook(self):
        self.callActor.handleCall(1,34,SCCPCallState.SCCP_CHANNELSTATE_RINGING)
        self.callActor.handleCall(1,38,SCCPCallState.SCCP_CHANNELSTATE_RINGING)
        self.callActor.handleCall(1,38,SCCPCallState.SCCP_CHANNELSTATE_ONHOOK)
        self.callActor.handleCall(1,40,SCCPCallState.SCCP_CHANNELSTATE_RINGING)
        self.sccpPhone.answerCall.assert_called_once_with()
        
    
    def testOnCallEstablished(self):
        
        self.callActor.handleCall(1,34,SCCPCallState.SCCP_CHANNELSTATE_CONNECTED)
        
        
        self.timerProvider.createOneShotTimer.assert_called_with(ANY,ANY)
        
        
    def testOnCallEndTimer(self):
        self.callActor.handleCall(7,34,SCCPCallState.SCCP_CHANNELSTATE_RINGING)

        self.callActor.onCallEndTimer()
        
        self.sccpPhone.endCall.assert_called_once_with(7,34)
        

    def testAutoAnswer(self):
        self.callActor.setAutoAnswer(False)
        self.callActor.handleCall(1,34,SCCPCallState.SCCP_CHANNELSTATE_RINGING)
        self.sccpPhone.answerCall.assert_never_called()