Example #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)
Example #2
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())
Example #3
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())
Example #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)
Example #5
0
 def test_constructRequest(self):
     aq = self.assertEqual
     r = Request('NOTIFY', 'sip:[email protected]')
     s = str(r).split('\r\n')
     aq(s[0], 'NOTIFY sip:[email protected] SIP/2.0')