blob: 92437e97beb7ab6d13e1eb1226d6046058d73e31 [file] [log] [blame]
Benny Prijono7d578a72008-06-20 00:25:55 +00001# $Id:$
2import imp
3import sys
4import inc_sip as sip
5import inc_const as const
6import re
7from inc_cfg import *
8
9# Read configuration
10cfg_file = imp.load_source("cfg_file", sys.argv[2])
11
12# Test body function
13def test_func(t, userdata):
14 pjsua = t.process[0]
15 # Create dialog
16 dlg = sip.Dialog("127.0.0.1", pjsua.inst_param.sip_port,
17 tcp=cfg_file.sendto_cfg.use_tcp)
18 #dlg = sip.Dialog("127.0.0.1", 5060, tcp=cfg_file.sendto_cfg.use_tcp)
19 cfg = cfg_file.sendto_cfg
20
21 req = dlg.create_invite(cfg.sdp)
22 resp = dlg.send_request_wait(req, 10)
23 if resp=="":
24 raise TestError("Timed-out waiting for response")
25 # Check response code
26 code = int(sip.get_code(resp))
27 if code != cfg.resp_code:
28 dlg.hangup(code)
29 raise TestError("Expecting code " + str(cfg.resp_code) +
30 " got " + str(code))
31 # Check for patterns that must exist
32 for p in cfg.resp_include:
33 if re.search(p, resp, re.M | re.I)==None:
34 dlg.hangup(code)
35 raise TestError("Pattern " + p + " not found")
36 # Check for patterns that must not exist
37 for p in cfg.resp_exclude:
38 if re.search(p, resp, re.M | re.I)!=None:
39 dlg.hangup(code)
40 raise TestError("Excluded pattern " + p + " found")
41 pjsua.sync_stdout()
42 dlg.hangup(code)
43 pjsua.sync_stdout()
44
45# Here where it all comes together
46test = TestParam(cfg_file.sendto_cfg.name,
47 [cfg_file.sendto_cfg.inst_param],
48 test_func)
49
50