def test_timeout(self): """Test a callgroup with acceptance, nobody picks up. +315080xxxxx calls +31613925xxx and does not pick up within the time. """ events = self.run_and_get_events( 'fixtures/acceptance/accept_timeout.json') expected_events = self.events_from_tuples(( ('on_b_dial', { 'call_id': 'ua0-acc-1507624058.2045', 'caller': CallerId(code=12668, number='+315080xxxxx', is_public=True), 'to_number': '+31853xxxxxx', 'targets': [CallerId(code=0, number='+31613925xxx', is_public=True)], }), ('on_hangup', { 'call_id': 'ua0-acc-1507624058.2045', 'caller': CallerId(code=12668, number='+315080xxxxx', is_public=True), 'to_number': '+31853xxxxxx', 'reason': 'no-answer', }), )) self.assertEqual(expected_events, events)
def test_deny(self): """Test a denied call. +315080xxxxx calls +31613925xxx and +31613925xxx refuses the call. """ events = self.run_and_get_events( 'fixtures/acceptance/accept_deny.json') expected_events = self.events_from_tuples(( ('on_b_dial', { 'call_id': 'ua0-acc-1507624765.2057', 'caller': CallerId(code=12668, number='+315080xxxxx', is_public=True), 'to_number': '+31853xxxxxx', 'targets': [CallerId(code=0, number='+31613925xxx', is_public=True)], }), ('on_hangup', { 'call_id': 'ua0-acc-1507624765.2057', 'caller': CallerId(code=12668, number='+315080xxxxx', is_public=True), 'to_number': '+31853xxxxxx', 'reason': 'no-answer', }), )) self.assertEqual(expected_events, events)
def test_ab_success(self): """Test a simple, successful call. 202 calls 203, 203 picks up and later the call is disconnected. """ events = self.run_and_get_events('fixtures/simple/ab_success.json') expected_events = self.events_from_tuples(( ('on_b_dial', { 'call_id': '63f2f9ce924a-1501851189.231', 'caller': CallerId(code=150010002, name='Robert Murray', number='202', is_public=True), 'to_number': '203', 'targets': [CallerId(code=150010003, number='203', is_public=True)], }), ('on_up', { 'call_id': '63f2f9ce924a-1501851189.231', 'caller': CallerId(code=150010002, name='Robert Murray', number='202', is_public=True), 'to_number': '203', 'callee': CallerId(code=150010003, number='203', is_public=True), }), ('on_hangup', { 'call_id': '63f2f9ce924a-1501851189.231', 'caller': CallerId(code=150010002, name='Robert Murray', number='202', is_public=True), 'to_number': '203', 'reason': 'completed', }), )) self.assertEqual(expected_events, events)
def test_ab_callgroup_no_answer(self): """ Test a call to a group where no target picks up. """ events = self.run_and_get_events('fixtures/simple/ab_callgroup_no_answer.json') expected_events = self.events_from_tuples(( ('on_b_dial', { 'call_id': '0f00dcaa884f-1509355567.22', 'caller': CallerId(code=150010002, name='David Meadows', number='202', is_public=True), 'to_number': '403', 'targets': [ CallerId(code=150010001, number='403', is_public=True), CallerId(code=150010003, number='403', is_public=True), ], }), ('on_hangup', { 'call_id': '0f00dcaa884f-1509355567.22', 'caller': CallerId(code=150010002, name='David Meadows', number='202', is_public=True), 'to_number': '403', 'reason': 'no-answer', }), )) self.assertEqual(expected_events, events)
def test_ab_success_twoaccounts(self): """Test a simple, successful call. Account 260010001 using +31260010001 as outdialing number, dials +31150010001 which is connected to account 150010001 with internal number 201 the call is picked up and completed successfully. """ events = self.run_and_get_events('fixtures/simple/ab_success_twoclients.json') expected_events = self.events_from_tuples(( ('on_b_dial', { 'call_id': '2087873f7e47-1508940720.14', 'caller': CallerId(code=15001, number='+31260010001', is_public=True), 'to_number': '+31150010001', 'targets': [CallerId(code=150010001, number='+31150010001', is_public=True)], }), ('on_up', { 'call_id': '2087873f7e47-1508940720.14', 'caller': CallerId(code=15001, number='+31260010001', is_public=True), 'to_number': '+31150010001', 'callee': CallerId(code=150010001, number='+31150010001', is_public=True), }), ('on_hangup', { 'call_id': '2087873f7e47-1508940720.14', 'caller': CallerId(code=15001, number='+31260010001', is_public=True), 'to_number': '+31150010001', 'reason': 'completed', }), )) self.assertEqual(events, expected_events)
def test_a_created_no_answer(self): """ Test a simple AB call where the state is changed before the dial. """ fixture_file = 'fixtures/simple/a_created_no_answer.json' events = self.run_and_get_events(fixture_file) calling_chan = SimpleChannel( name='SIP/voipgrid-siproute-docker-00000009', uniqueid='e25ad522d444-1553503669.94', linkedid='e25ad522d444-1553503669.94', account_code='15001', caller_id=CallerId(name='', num='+31150010001'), cid_calling_pres=None, connected_line=CallerId(), exten='+31150010004', state=6, ) expected_events = [ ('on_hangup', { 'caller': calling_chan, 'reason': 'completed', }), ] self.assertEqual(expected_events, events)
def test_a_success_hangup(self): """ Test a call where A hangs up after being connected to B. """ events = self.run_and_get_events('fixtures/simple/ab_a_success_hangup.json') expected_events = self.events_from_tuples(( ('on_b_dial', { 'call_id': '0f00dcaa884f-1508490669.30', 'caller': CallerId(code=150010002, name='David Meadows', number='202', is_public=True), 'to_number': '204', 'targets': [CallerId(code=150010004, number='204', is_public=True)], }), ('on_up', { 'call_id': '0f00dcaa884f-1508490669.30', 'caller': CallerId(code=150010002, name='David Meadows', number='202', is_public=True), 'to_number': '204', 'callee': CallerId(code=150010004, number='204', is_public=True), }), ('on_hangup', { 'call_id': '0f00dcaa884f-1508490669.30', 'caller': CallerId(code=150010002, name='David Meadows', number='202', is_public=True), 'to_number': '204', 'reason': 'completed', }), )) self.assertEqual(expected_events, events)
def test_notaccepted(self): """Test a not accepted but answered call. +31613925xxx picks up, does NOT accept the call, and hangs up. """ events = self.run_and_get_events( 'fixtures/acceptance/accept_notaccepted.json') expected_events = self.events_from_tuples(( ('on_b_dial', { 'call_id': 'ua0-acc-1507621393.1940', 'caller': CallerId(code=12668, number='+315080xxxxx', is_public=True), 'to_number': '+31853xxxxxx', 'targets': [CallerId(code=0, number='+31613925xxx', is_public=True)], }), ('on_hangup', { 'call_id': 'ua0-acc-1507621393.1940', 'caller': CallerId(code=12668, number='+315080xxxxx', is_public=True), 'to_number': '+31853xxxxxx', 'reason': 'no-answer', }), )) self.assertEqual(expected_events, events)
def __init__(self, event): """ Create a new channel instance. Args: event (dict): The attributes of a Newchannel event. """ self.name = event['Channel'] self.uniqueid = event['Uniqueid'] self.linkedid = event['Linkedid'] self.state = int(event['ChannelState']) self.exten = event['Exten'] self.account_code = event['AccountCode'] self.cid_calling_pres = None self.caller_id = CallerId( name=event['CallerIDName'], num=event['CallerIDNum'], ) self.connected_line = CallerId( name=event['ConnectedLineName'], num=event['ConnectedLineNum'], ) # Create vars which are used to store generated data based on other # events from Asterisk. self.fwd_local_bridge = None self.back_local_bridge = None self.back_dial = None self.fwd_dials = [] self.bridge = None self.is_originated = False self.is_calling = self.uniqueid == self.linkedid # The Custom dict can be used to store custom data. self.custom = {}
def test_ctd_account_world(self): """ Click-to-dial call between a phoneaccount and an external number. In this scenario: 1. 201 is dialed 2. 201 picks up 3. +31260010001 is dialed 4. +31260010001 picks up 5. +31260010001 hangs up Which is reported as: 1. 201 dials +31260010001 2. +31260010001 picks up 3. +31260010001 hangs up """ events = self.run_and_get_events( 'fixtures/originate/ctd-account-world.json') calling_chan = SimpleChannel( account_code='15001', caller_id=CallerId(num='201'), cid_calling_pres='0 (Presentation Allowed, Not Screened)', connected_line=CallerId(name='Calling...', num='+31150010001'), exten='+31260010001', linkedid='c4061ca6474c-1531990515.302', name='SIP/150010001-00000008', state=6, uniqueid='c4061ca6474c-1531990515.317', ) target_chan = SimpleChannel( account_code='15001', caller_id=CallerId(num='+31260010001'), cid_calling_pres='0 (Presentation Allowed, Not Screened)', connected_line=CallerId(num='+31150010001'), exten='s', linkedid='c4061ca6474c-1531990515.302', name='SIP/voipgrid-siproute-docker-00000009', state=6, uniqueid='c4061ca6474c-1531990517.363', ) expected_events = [ ('on_b_dial', { 'caller': calling_chan, 'targets': [target_chan.replace(state=5)], }), ('on_up', { 'caller': calling_chan, 'target': target_chan, }), ('on_hangup', { 'caller': calling_chan, 'reason': 'completed', }), ] self.assertEqual(expected_events, events)
def test_account_world(self): """ Click-to-dial call between a phoneaccount and an external number. 217 is dialed, 217 picks up, +31613925xxx is dialed +31613925xxx picks up +31613925xxx hangs up """ events = self.run_and_get_events( 'fixtures/connectab/ctd-account-world.json') expected_events = self.events_from_tuples( ( ('on_b_dial', { 'call_id': 'ua0-acc-1511536963.147', 'caller': CallerId(code=126680005, number='+31853030900', is_public=True), 'to_number': '+31613925xxx', 'targets': [CallerId(code=0, number='+31613925xxx', is_public=True)], }), ('on_up', { 'call_id': 'ua0-acc-1511536963.147', 'caller': CallerId(code=126680005, number='+31853030900', is_public=True), 'to_number': '+31613925xxx', 'callee': CallerId(code=0, number='+31613925xxx', is_public=True), }), ('on_hangup', { 'call_id': 'ua0-acc-1511536963.147', 'caller': CallerId(code=126680005, number='+31853030900', is_public=True), 'to_number': '+31613925xxx', 'reason': 'completed', }), )) self.assertEqual(expected_events, events)
def test_ctd_account_world_no_ringing(self): """ Click-to-dial where the B side never reaches state 5 RINGING. """ events = self.run_and_get_events( 'fixtures/originate/ctd-account-world-no-ringing.json') calling_chan = SimpleChannel( account_code='15001', caller_id=CallerId(num='2401'), cid_calling_pres='0 (Presentation Allowed, Not Screened)', connected_line=CallerId(name='Calling...', num='+31150010001'), exten='+31260010001', linkedid='ua5-ams-1552575068.23242646', name='SIP/150010063-0015f5f1', state=6, uniqueid='ua5-ams-1552575068.23242663', ) target_chan = SimpleChannel( account_code='15001', caller_id=CallerId(num='+31260010001'), cid_calling_pres='0 (Presentation Allowed, Not Screened)', connected_line=CallerId(num='+31150010001'), exten='s', linkedid='ua5-ams-1552575068.23242646', name='SIP/voipgrid-siproute-ams-0015f5f3', state=6, uniqueid='ua5-ams-1552575069.23242717', ) self.maxDiff = None expected_events = [ ( 'on_b_dial', { 'caller': calling_chan, 'targets': [target_chan], # no .replace(state=5) here }), ('on_up', { 'caller': calling_chan, 'target': target_chan, }), ('on_hangup', { 'caller': calling_chan, 'reason': 'completed', }), ] self.assertEqual(expected_events, events)
def test_xfer_blind_b_no_answer(self): """ Test a blind transfer from B where the transfer target is down. """ events = self.run_and_get_events( 'fixtures/xfer_blind/xfer_blind_b_no_answer.json') expected_events = self.events_from_tuples(( ('on_b_dial', { 'call_id': '0f00dcaa884f-1509115795.11', 'caller': CallerId(code=150010002, name='David Meadows', number='202', is_public=True), 'to_number': '204', 'targets': [CallerId(code=150010004, number='204', is_public=True)], }), ('on_up', { 'call_id': '0f00dcaa884f-1509115795.11', 'caller': CallerId(code=150010002, name='David Meadows', number='202', is_public=True), 'to_number': '204', 'callee': CallerId(code=150010004, number='204', is_public=True), }), ('on_hangup', { 'call_id': '0f00dcaa884f-1509115795.11', 'caller': CallerId(code=150010002, name='David Meadows', number='202', is_public=True), 'to_number': '204', 'reason': 'completed', }), )) self.assertEqual(expected_events, events)
def test_call_pickup(self): """ Test a call pickup transfer. """ events = self.run_and_get_events('fixtures/xfer_misc/call_pickup.json') expected_events = self.events_from_tuples(( ('on_b_dial', { 'call_id': 'vgua0-dev-1445001221.106', 'caller': CallerId(code=123450001, name='Alice', number='201', is_public=True), 'to_number': '202', 'targets': [CallerId(code=123450002, number='202', is_public=True)], }), ('on_up', { 'call_id': 'vgua0-dev-1445001221.106', 'caller': CallerId(code=123450001, name='Alice', number='201', is_public=True), 'to_number': '202', 'callee': CallerId(code=123450003, number='202', is_public=True), }), ('on_hangup', { 'call_id': 'vgua0-dev-1445001221.106', 'caller': CallerId(code=123450001, name='Alice', number='201', is_public=True), 'to_number': '202', 'reason': 'completed', }), )) self.assertEqual(expected_events, events)
def test_outbound(self): """ Test a simple outbound call. """ events = self.run_and_get_events( 'fixtures/fixed/fixed_outbound_success.json') expected_events = self.events_from_tuples( ( ('on_b_dial', { 'call_id': 'ua0-acc-1513784375.1916', 'caller': CallerId(code=126680010, number='+31853030900', is_public=True), 'targets': [CallerId(number='+31508009000', is_public=True)], 'to_number': '0508009000', }), ('on_up', { 'call_id': 'ua0-acc-1513784375.1916', 'caller': CallerId(code=126680010, number='+31853030900', is_public=True), 'callee': CallerId(number='+31508009000', is_public=True), 'to_number': '0508009000', }), ('on_hangup', { 'call_id': 'ua0-acc-1513784375.1916', 'caller': CallerId(code=126680010, number='+31853030900', is_public=True), 'to_number': '0508009000', 'reason': 'completed', }), )) self.assertEqual(expected_events, events)
def test_simple_mobile(self): """ Test a call from external which is routed to another number. """ events_file = 'fixtures/mobile/simple_mobile.json' events = self.run_and_get_events(events_file) caller = SimpleChannel( name='SIP/voipgrid-siproute-docker-00000036', uniqueid='f29ea68048f6-1530017224.892', linkedid='f29ea68048f6-1530017224.892', account_code='15001', caller_id=CallerId(num='+31150010001'), cid_calling_pres=None, connected_line=CallerId(), exten='+31150010004', state=6, ) target = SimpleChannel( name='SIP/voipgrid-siproute-docker-00000037', uniqueid='f29ea68048f6-1530017224.905', linkedid='f29ea68048f6-1530017224.892', account_code='15001', caller_id=CallerId(num='+31260010001'), cid_calling_pres='0 (Presentation Allowed, Not Screened)', connected_line=CallerId(num='+31150010001'), exten='s', state=6, ) expected_events = [ ('on_b_dial', { 'caller': caller.replace(state=4), 'targets': [target.replace(state=5)], }), ('on_up', { 'caller': caller, 'target': target, }), ('on_hangup', { 'caller': caller, 'reason': 'completed', }), ] self.assertEqual(expected_events, events)
def test_cmn_world_account(self): """ Call-me-now call between a mobilephone and an internal number. +31613925xxx is dialed, +31613925xxx picks up, 203 is dialed 203 picks up, +31613925xxx hangs up """ events = self.run_and_get_events( 'fixtures/connectab/cmn-world-account.json') expected_events = self.events_from_tuples(( ('on_b_dial', { 'call_id': 'ua1-staging-1512038737.882', 'caller': CallerId(code=15001, number='+31613925xxx', is_public=True), 'to_number': '203', 'targets': [CallerId(code=150010003, number='203', is_public=True)], }), ('on_up', { 'call_id': 'ua1-staging-1512038737.882', 'caller': CallerId(code=15001, number='+31613925xxx', is_public=True), 'to_number': '203', 'callee': CallerId(code=150010003, number='203', is_public=True), }), ('on_hangup', { 'call_id': 'ua1-staging-1512038737.882', 'caller': CallerId(code=15001, number='+31613925xxx', is_public=True), 'to_number': '203', 'reason': 'completed', }), )) self.assertEqual(expected_events, events)
def test_ab_success_a_hangup(self): """ Test a simple, successful call where A hangs up. """ fixture_file = 'fixtures/simple/ab_success_a_hangup.json' events = self.run_and_get_events(fixture_file) calling_chan = SimpleChannel( account_code='150010001', caller_id=CallerId(name='Andrew Garza', num='201'), cid_calling_pres='1 (Presentation Allowed, Passed Screen)', connected_line=CallerId(), exten='202', linkedid='195176c06ab8-1529936170.42', name='SIP/150010001-00000004', state=6, uniqueid='195176c06ab8-1529936170.42', ) target_chan = SimpleChannel( account_code='150010001', caller_id=CallerId(num='202'), cid_calling_pres='0 (Presentation Allowed, Not Screened)', connected_line=CallerId(name='Andrew Garza', num='201'), exten='s', linkedid='195176c06ab8-1529936170.42', name='SIP/150010002-00000005', state=6, uniqueid='195176c06ab8-1529936170.50', ) expected_events = [ ('on_b_dial', { 'caller': calling_chan.replace(state=4), 'targets': [target_chan.replace(state=5)], }), ('on_up', { 'caller': calling_chan, 'target': target_chan, }), ('on_hangup', { 'caller': calling_chan, 'reason': 'completed', }), ] self.assertEqual(expected_events, events)
def test_call_forwarding(self): """ Test a call where the call is locally forwarded to another phone. """ events = self.run_and_get_events( 'fixtures/xfer_misc/call_forwarding.json') calling_chan = SimpleChannel( name='SIP/voipgrid-siproute-docker-00000016', uniqueid='b6093874285e-1530191379.305', linkedid='b6093874285e-1530191379.305', account_code='15001', caller_id=CallerId(num='+31260010001'), cid_calling_pres=None, connected_line=CallerId(), exten='+31150010001', state=6, ) target_chan = SimpleChannel( name='SIP/150010002-00000018', uniqueid='b6093874285e-1530191380.328', linkedid='b6093874285e-1530191379.305', account_code='15001', caller_id=CallerId(num='202'), cid_calling_pres='0 (Presentation Allowed, Not Screened)', connected_line=CallerId(num='+31260010001'), exten='s', state=6, ) expected_events = [ ('on_b_dial', { 'caller': calling_chan.replace(state=4), 'targets': [target_chan.replace(state=5)], }), ('on_up', { 'caller': calling_chan, 'target': target_chan, }), ('on_hangup', { 'caller': calling_chan, 'reason': 'completed', }), ] self.assertEqual(expected_events, events)
def test_queue_simple(self): """ Test a simple call through a queue to a single account. """ fixture_file = 'fixtures/queue/queue_simple.json' events = self.run_and_get_events(fixture_file) caller = SimpleChannel( name='SIP/voipgrid-siproute-docker-00000025', uniqueid='195176c06ab8-1529939196.518', linkedid='195176c06ab8-1529939196.518', account_code='15001', caller_id=CallerId(num='+31150010001'), cid_calling_pres=None, connected_line=CallerId(), exten='+31150010004', state=6, ) target = SimpleChannel( name='SIP/150010002-00000026', uniqueid='195176c06ab8-1529939198.548', linkedid='195176c06ab8-1529939196.518', account_code='15001', caller_id=CallerId(num='+31150010004'), cid_calling_pres='0 (Presentation Allowed, Not Screened)', connected_line=CallerId(num='+31150010001'), exten='s', state=6, ) expected_events = [ ('on_b_dial', { 'caller': caller, 'targets': [target.replace(state=5)], }), ('on_up', { 'caller': caller, 'target': target, }), ('on_hangup', { 'caller': caller, 'reason': 'completed', }), ] self.assertEqual(expected_events, events)
def test_ab_out_of_order_dial(self): """ Test a simple AB call where the state is changed before the dial. """ fixture_file = 'fixtures/simple/ab_success_o3.json' events = self.run_and_get_events(fixture_file) calling_chan = SimpleChannel( name='SIP/100060001-0000000e', uniqueid='fc7a1e79d662-1539093894.250', linkedid='fc7a1e79d662-1539093894.250', account_code='100060001', caller_id=CallerId(name='Robert Hughes', num='201'), cid_calling_pres='1 (Presentation Allowed, Passed Screen)', connected_line=CallerId(), exten='202', state=6, ) target_chan = SimpleChannel( name='SIP/100060002-0000000f', uniqueid='fc7a1e79d662-1539093894.258', linkedid='fc7a1e79d662-1539093894.250', account_code='100060001', caller_id=CallerId(num='202'), cid_calling_pres='0 (Presentation Allowed, Not Screened)', connected_line=CallerId(name='Robert Hughes', num='201'), exten='s', state=6, ) expected_events = [ ('on_b_dial', { 'caller': calling_chan.replace(state=4), 'targets': [target_chan.replace(state=5)], }), ('on_up', { 'caller': calling_chan, 'target': target_chan, }), ('on_hangup', { 'caller': calling_chan, 'reason': 'completed', }), ] self.assertEqual(expected_events, events)
def test_call_forwarding(self): """ Test a call where the call is locally forwarded to another phone. """ events = self.run_and_get_events( 'fixtures/xfer_misc/call_forwarding.json') expected_events = self.events_from_tuples((('on_b_dial', { 'call_id': 'vgua0-dev-1444992672.12', 'caller': CallerId(code=123450001, name='Alice', number='201', is_public=True), 'to_number': '202', 'targets': [CallerId(code=123450003, number='203', is_public=True)], }), ('on_up', { 'call_id': 'vgua0-dev-1444992672.12', 'caller': CallerId(code=123450001, name='Alice', number='201', is_public=True), 'to_number': '202', 'callee': CallerId(code=123450003, number='203', is_public=True), }), ('on_hangup', { 'call_id': 'vgua0-dev-1444992672.12', 'caller': CallerId(code=123450001, name='Alice', number='201', is_public=True), 'to_number': '202', 'reason': 'completed', }))) self.assertEqual(expected_events, events)
def test_account_account(self): """ Click-to-dial call between a phoneaccount and an external number. 203 is dialed, 203 picks up, 202 is dialed 202 picks up 203 hangs up """ events = self.run_and_get_events( 'fixtures/connectab/ctd-account-account.json') expected_events = self.events_from_tuples(( ('on_b_dial', { 'call_id': 'ua1-staging-1511945444.284', 'caller': CallerId(code=150010003, number='203', is_public=True), 'to_number': '202', 'targets': [CallerId(code=150010002, number='202', is_public=True)], }), ('on_up', { 'call_id': 'ua1-staging-1511945444.284', 'caller': CallerId(code=150010003, number='203', is_public=True), 'to_number': '202', 'callee': CallerId(code=150010002, number='202', is_public=True), }), ('on_hangup', { 'call_id': 'ua1-staging-1511945444.284', 'caller': CallerId(code=150010003, number='203', is_public=True), 'to_number': '202', 'reason': 'completed', }), )) self.assertEqual(expected_events, events)
def test_incoming(self): """Test an incomming call from outside the platform. +31853030900 dials +31853030904, dialplan causes 203 to be dialed. """ events = self.run_and_get_events( 'fixtures/fixed/fixed_incomming_success.json') expected_events = self.events_from_tuples(( ('on_b_dial', { 'call_id': '2087873f7e47-1509101015.24', 'caller': CallerId(code=15001, number='+31853030900', is_public=True), 'to_number': '+31853030904', 'targets': [ CallerId(code=150010003, number='+31853030904', is_public=True) ], }), ('on_up', { 'call_id': '2087873f7e47-1509101015.24', 'caller': CallerId(code=15001, number='+31853030900', is_public=True), 'to_number': '+31853030904', 'callee': CallerId(code=150010003, number='+31853030904', is_public=True), }), ('on_hangup', { 'call_id': '2087873f7e47-1509101015.24', 'caller': CallerId(code=15001, number='+31853030900', is_public=True), 'to_number': '+31853030904', 'reason': 'completed', }), )) self.assertEqual(expected_events, events)
def test_accepted(self): """Test an accepted call via callgroup. +315080xxxxx dials calls +31853xxxxxx, +31612345678 is the configured fixed destination, +31612345678 picks up, accepts the call by pressing 1, Later the call is disconnected. """ events = self.run_and_get_events( 'fixtures/acceptance/accept_accepted.json') expected_events = self.events_from_tuples(( ('on_b_dial', { 'call_id': 'ua0-acc-1506952916.1769', 'caller': CallerId(code=12668, number='+315080xxxxx', is_public=True), 'to_number': '+31853xxxxxx', 'targets': [CallerId(code=0, number='+31612345678', is_public=True)], }), ('on_up', { 'call_id': 'ua0-acc-1506952916.1769', 'caller': CallerId(code=12668, number='+315080xxxxx', is_public=True), 'to_number': '+31853xxxxxx', 'callee': CallerId(code=12668, number='+31612345678', is_public=True), }), ('on_hangup', { 'call_id': 'ua0-acc-1506952916.1769', 'caller': CallerId(code=12668, number='+315080xxxxx', is_public=True), 'to_number': '+31853xxxxxx', 'reason': 'completed', }), )) self.assertEqual(expected_events, events)
def test_account_world_deny_b(self): """ Click-to-dial call between a phoneaccount and an external number. 203 is dialed, 203 picks up +31613925xxx does not pickup """ events = self.run_and_get_events( 'fixtures/connectab/ctd-account-world-deny_b.json') expected_events = self.events_from_tuples( ( ('on_b_dial', { 'call_id': 'ua1-staging-1512032862.847', 'caller': CallerId(code=150010003, number='+31150010001', is_public=True), 'to_number': '+31613925xxx', 'targets': [ CallerId(code=0, name='', number='+31613925xxx', is_public=True) ], }), ('on_hangup', { 'call_id': 'ua1-staging-1512032862.847', 'caller': CallerId(code=150010003, number='+31150010001', is_public=True), 'to_number': '+31613925xxx', 'reason': 'no-answer', }), )) self.assertEqual(expected_events, events)
def test_queue_simple(self): """ Test a successful call through a queue. """ events = self.run_and_get_events('fixtures/queue/queue_simple.json') expected_events = self.events_from_tuples(( ('on_b_dial', { 'call_id': 'e83df36bebbe-1507019160.61', 'caller': CallerId(code=15001, number='+31150010002', is_public=True), 'to_number': '+31150010004', 'targets': [ CallerId(code=150010001, number='+31150010004', is_public=True) ], }), ('on_up', { 'call_id': 'e83df36bebbe-1507019160.61', 'caller': CallerId(code=15001, number='+31150010002', is_public=True), 'to_number': '+31150010004', 'callee': CallerId(code=150010001, number='+31150010004', is_public=True), }), ('on_hangup', { 'call_id': 'e83df36bebbe-1507019160.61', 'caller': CallerId(code=15001, number='+31150010002', is_public=True), 'to_number': '+31150010004', 'reason': 'completed', }), )) self.assertEqual(expected_events, events)
def test_fixed(self): """Test an incomming call with fixed destination. +31853030900 dials +31853030904, dialplan dials fixed destiation +31613925xxx. """ events = self.run_and_get_events( 'fixtures/fixed/fixed_both_success.json') expected_events = self.events_from_tuples(( ('on_b_dial', { 'call_id': '2087873f7e47-1509103867.32', 'caller': CallerId(code=15001, number='+31853030900', is_public=True), 'to_number': '+31853030904', 'targets': [CallerId(code=0, number='+31613925xxx', is_public=True)], }), ('on_up', { 'call_id': '2087873f7e47-1509103867.32', 'caller': CallerId(code=15001, number='+31853030900', is_public=True), 'to_number': '+31853030904', 'callee': CallerId(code=0, number='+31613925xxx', is_public=True), }), ('on_hangup', { 'call_id': '2087873f7e47-1509103867.32', 'caller': CallerId(code=15001, number='+31853030900', is_public=True), 'to_number': '+31853030904', 'reason': 'completed', }), )) self.assertEqual(expected_events, events)
def test_ab_busy(self): """Test a simple call where B is busy. """ events = self.run_and_get_events('fixtures/simple/ab_busy.json') expected_events = self.events_from_tuples(( ('on_b_dial', { 'call_id': '63f2f9ce924a-1501851519.239', 'caller': CallerId(code=150010002, name='Robert Murray', number='202', is_public=True), 'to_number': '201', 'targets': [CallerId(code=150010001, number='201', is_public=True)], }), ('on_hangup', { 'call_id': '63f2f9ce924a-1501851519.239', 'caller': CallerId(code=150010002, name='Robert Murray', number='202', is_public=True), 'to_number': '201', 'reason': 'busy' }), )) self.assertEqual(expected_events, events)
def test_ab_callgroup(self): """ Test a simple call to a group where one phone is picked up. """ events = self.run_and_get_events('fixtures/simple/ab_callgroup.json') expected_events = self.events_from_tuples(( ('on_b_dial', { 'call_id': '63f2f9ce924a-1501852169.254', 'caller': CallerId(code=150010002, name='Robert Murray', number='202', is_public=True), 'to_number': '401', 'targets': [ CallerId(code=150010001, number='401', is_public=True), CallerId(code=150010003, number='401', is_public=True), ], }), ('on_up', { 'call_id': '63f2f9ce924a-1501852169.254', 'caller': CallerId(code=150010002, name='Robert Murray', number='202', is_public=True), 'to_number': '401', 'callee': CallerId(code=150010001, number='401', is_public=True), }), ('on_hangup', { 'call_id': '63f2f9ce924a-1501852169.254', 'caller': CallerId(code=150010002, name='Robert Murray', number='202', is_public=True), 'to_number': '401', 'reason': 'completed' }), )) self.assertEqual(expected_events, events)