Exemplo n.º 1
0
 def test_createResponse(self):
     aq = self.assertEqual
     at = self.assertTrue
     req = Request('NOTIFY', 'sip:[email protected]')
     req.headers['f'] = AddressHeader.parse(
         'Carol <sip:[email protected]> ;tag=abvgde123')
     req.headers['t'] = AddressHeader.parse("Echo <sip:[email protected]>")
     req.headers['via'] = ViaHeader.parse(
         "SIP/2.0/TCP 193.168.0.1:5061; received=10.10.10.10")
     req.headers['call-id'] = '1234@localhost'
     req.headers['cseq'] = CSeqHeader.parse('1 NOTIFY')
     r = req.createResponse('180', 'Ringing')
     aq(str(r.headers['from']),
        'Carol <sip:[email protected]> ;tag=abvgde123')
     aq(str(r.headers['To'].uri), 'sip:[email protected]')
     aq(r.headers['To'].display_name, 'Echo')
     aq(str(r.headers['Via']),
        'SIP/2.0/TCP 193.168.0.1:5061 ;received=10.10.10.10')
     aq(r.headers['Call-Id'], '1234@localhost')
     aq(r.headers['CSeq'].number, 1)
     aq(r.headers['CSeq'].method, 'NOTIFY')
     at('tag' in r.headers['To'].params)
     t1 = r.headers['to'].params['tag']
     at(isinstance(t1, basestring))
     r = req.createResponse('200', 'OK')
     t2 = r.headers['t'].params['tag']
     aq(t1, t2)
Exemplo n.º 2
0
 def test_parsing(self):
     aq = self.assertEqual
     v = AddressHeader.parse('<sips:[email protected]>;expires=60')
     aq(str(v.uri), 'sips:[email protected]')
     aq(v.params['expires'], '60')
     aq(v.display_name, '')
     v = AddressHeader.parse('<sip:server10.biloxi.com;lr>')
     aq(str(v.uri), 'sip:server10.biloxi.com;lr')
     aq(v.params, {})
     aq(v.display_name, '')
     v = AddressHeader.parse('The Operator <sip:[email protected]>;tag=287447')
     aq(str(v.uri), 'sip:[email protected]')
     aq(v.display_name, 'The Operator')
     aq(v.params, {'tag': '287447'})
     v = AddressHeader.parse('sip:[email protected]')
     aq(str(v.uri), 'sip:[email protected]')
Exemplo n.º 3
0
 def test_parsing(self):
     aq = self.assertEqual
     v = AddressHeader.parse('<sips:[email protected]>;expires=60')
     aq(str(v.uri), 'sips:[email protected]')
     aq(v.params['expires'], '60')
     aq(v.display_name, '')
     v = AddressHeader.parse('<sip:server10.biloxi.com;lr>')
     aq(str(v.uri), 'sip:server10.biloxi.com;lr')
     aq(v.params, {})
     aq(v.display_name, '')
     v = AddressHeader.parse(
         'The Operator <sip:[email protected]>;tag=287447')
     aq(str(v.uri), 'sip:[email protected]')
     aq(v.display_name, 'The Operator')
     aq(v.params, {'tag': '287447'})
     v = AddressHeader.parse('sip:[email protected]')
     aq(str(v.uri), 'sip:[email protected]')
Exemplo n.º 4
0
 def test_createResponse(self):
     aq = self.assertEqual
     at = self.assertTrue
     req = Request('NOTIFY', 'sip:[email protected]')
     req.headers['f'] = AddressHeader.parse('Carol <sip:[email protected]> ;tag=abvgde123')
     req.headers['t'] = AddressHeader.parse("Echo <sip:[email protected]>")
     req.headers['via'] = ViaHeader.parse("SIP/2.0/TCP 193.168.0.1:5061; received=10.10.10.10")
     req.headers['call-id'] = '1234@localhost'
     req.headers['cseq'] = CSeqHeader.parse('1 NOTIFY')
     r = req.createResponse('180', 'Ringing')
     aq(str(r.headers['from']), 'Carol <sip:[email protected]> ;tag=abvgde123')
     aq(str(r.headers['To'].uri), 'sip:[email protected]')
     aq(r.headers['To'].display_name, 'Echo')
     aq(str(r.headers['Via']), 'SIP/2.0/TCP 193.168.0.1:5061 ;received=10.10.10.10')
     aq(r.headers['Call-Id'], '1234@localhost')
     aq(r.headers['CSeq'].number, 1)
     aq(r.headers['CSeq'].method, 'NOTIFY')
     at('tag' in r.headers['To'].params)
     t1 = r.headers['to'].params['tag']
     at(isinstance(t1, basestring))
     r = req.createResponse('200', 'OK')
     t2 = r.headers['t'].params['tag']
     aq(t1, t2)
Exemplo n.º 5
0
 def test_isValid(self):
     at = self.assertTrue
     af = self.assertFalse
     r = Request('NOTIFY', 'sip:[email protected]')
     h = r.headers
     af(r.isValid())
     h['f'] = AddressHeader.parse('sip:[email protected]')
     af(r.isValid())
     h['To'] = 'sip:[email protected]'
     af(r.isValid())
     h['v'] = 'via'
     af(r.isValid())
     h['call-id'] = 'abracadabra'
     af(r.isValid())
     h['CSEQ'] = '1'
     af(r.isValid())
     h['Max-Forwards'] = '30'
     af(r.isValid())
     r.headers['from'].params['tag'] = 'cadabra'
     at(r.isValid())
Exemplo n.º 6
0
 def test_isValid(self):
     at = self.assertTrue
     af = self.assertFalse
     r = Request('NOTIFY', 'sip:[email protected]')
     h = r.headers
     af(r.isValid())
     h['f'] = AddressHeader.parse('sip:[email protected]')
     af(r.isValid())
     h['To'] = 'sip:[email protected]'
     af(r.isValid())
     h['v'] = 'via'
     af(r.isValid())
     h['call-id'] = 'abracadabra'
     af(r.isValid())
     h['CSEQ'] = '1'
     af(r.isValid())
     h['Max-Forwards'] = '30'
     af(r.isValid())
     r.headers['from'].params['tag'] = 'cadabra'
     at(r.isValid())