コード例 #1
0
    def test_outgoing_calls_for_phone(self, mock_outgoing_for_phone):
        now = datetime.now()
        identifier = u'sip/abcdef'
        date1 = date2 = date3 = now
        duration1 = 1
        caller_name1 = u'123'
        duration2 = 2
        caller_name2 = u'456'
        duration3 = 3
        caller_name3 = u'789'

        call_log_1 = CallLog(date=now,
                             duration=timedelta(0, 1, 0),
                             destination_exten=u'123')

        call_log_2 = CallLog(date=now,
                             duration=timedelta(0, 2, 0),
                             destination_exten=u'456')

        returned_call_logs = [call_log_1, call_log_2]

        expected_sent_calls = [
            SentCall(date1, duration1, caller_name1),
            SentCall(date2, duration2, caller_name2)
        ]

        mock_outgoing_for_phone.return_value = returned_call_logs

        sent_calls = call_history_manager.outgoing_calls_for_phone(
            identifier, 2)

        mock_outgoing_for_phone.assert_called_once_with(identifier, 2)
        self.assertEqual(expected_sent_calls, sent_calls)
コード例 #2
0
    def test_missed_calls_for_phone(self, mock_missed_for_phone):
        now = datetime.now()
        identifier = u'sip/abcdef'
        date1 = date2 = date3 = now
        duration1 = 0
        caller_name1 = u'"Foo" <123>'
        duration2 = 0
        caller_name2 = u'"Bar" <456>'
        duration3 = 0
        caller_name3 = u'"Man" <789>'

        call_log_1 = CallLog(date=now,
                             duration=timedelta(0, 0, 0),
                             source_name=u'Foo',
                             source_exten=u'123')

        call_log_2 = CallLog(date=now,
                             duration=timedelta(0, 0, 0),
                             source_name=u'Bar',
                             source_exten=u'456')

        returned_call_logs = [call_log_1, call_log_2]

        expected_received_calls = [
            ReceivedCall(date1, duration1, caller_name1),
            ReceivedCall(date2, duration2, caller_name2)
        ]

        mock_missed_for_phone.return_value = returned_call_logs

        received_calls = call_history_manager.missed_calls_for_phone(
            identifier, 2)

        mock_missed_for_phone.assert_called_once_with(identifier, 2)
        self.assertEqual(expected_received_calls, received_calls)
コード例 #3
0
 def _mock_call_log(self,
                    cel_ids=None,
                    date=None,
                    id=None,
                    source_line_identity=None,
                    destination_line_identity=None,
                    answered=False):
     if cel_ids is None:
         cel_ids = ()
     if date is None:
         date = datetime.now()
     call_log = CallLog(id=id,
                        date=date,
                        duration=timedelta(0),
                        source_line_identity=source_line_identity,
                        destination_line_identity=destination_line_identity,
                        answered=answered)
     call_log.add_related_cels(cel_ids)
     self.call_log_rows.append(
         CallLogSchema(id=id,
                       date=date,
                       source_line_identity=source_line_identity,
                       destination_line_identity=destination_line_identity,
                       answered=answered,
                       duration=timedelta(3)))
     return call_log
コード例 #4
0
 def setUp(self):
     self.call_log = CallLog()
コード例 #5
0
def create_call_logs(entries):
    call_logs = [CallLog(**entry) for entry in entries]
    dao.create_from_list(call_logs)
コード例 #6
0
ファイル: test_dao.py プロジェクト: jaunis/xivo-dao
 def _add_call(self, duration=datetime.timedelta(seconds=5)):
     call_log = CallLog(date=datetime.datetime.now(), duration=duration)
     call_log_row = db_converter.to_source(call_log)
     self.add_me(call_log_row)
     return call_log_row.id