diff options
author | Benny Prijono <bennylp@teluu.com> | 2008-12-22 18:54:58 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2008-12-22 18:54:58 +0000 |
commit | 0723dbc601c74330f792db67ad75f6d580c30d8b (patch) | |
tree | a10e1cc45bdeb80210168f2e26421ae0d7e7295d /tests/pjsua/mod_sendto.py | |
parent | 341dea971f9d548cc922f5f3446d80130a1d57d9 (diff) |
Created top-level directory tests and moved test-pjsua there. This will be the placeholder for future developed tests
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2392 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'tests/pjsua/mod_sendto.py')
-rw-r--r-- | tests/pjsua/mod_sendto.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/pjsua/mod_sendto.py b/tests/pjsua/mod_sendto.py new file mode 100644 index 00000000..4cc12a41 --- /dev/null +++ b/tests/pjsua/mod_sendto.py @@ -0,0 +1,53 @@ +# $Id$ +import imp +import sys +import inc_sip as sip +import inc_const as const +import re +from inc_cfg import * + +# Read configuration +cfg_file = imp.load_source("cfg_file", ARGS[1]) + +# Test body function +def test_func(t): + pjsua = t.process[0] + # Create dialog + dlg = sip.Dialog("127.0.0.1", pjsua.inst_param.sip_port, + tcp=cfg_file.sendto_cfg.use_tcp) + #dlg = sip.Dialog("127.0.0.1", 5060, tcp=cfg_file.sendto_cfg.use_tcp) + cfg = cfg_file.sendto_cfg + + if len(cfg.complete_msg) != 0: + req = cfg.complete_msg + else: + req = dlg.create_invite(cfg.sdp, cfg.extra_headers) + resp = dlg.send_request_wait(req, 10) + if resp=="": + raise TestError("Timed-out waiting for response") + # Check response code + code = int(sip.get_code(resp)) + if code != cfg.resp_code: + dlg.hangup(code) + raise TestError("Expecting code " + str(cfg.resp_code) + + " got " + str(code)) + # Check for patterns that must exist + for p in cfg.resp_include: + if re.search(p, resp, re.M | re.I)==None: + dlg.hangup(code) + raise TestError("Pattern " + p + " not found") + # Check for patterns that must not exist + for p in cfg.resp_exclude: + if re.search(p, resp, re.M | re.I)!=None: + dlg.hangup(code) + raise TestError("Excluded pattern " + p + " found") + pjsua.sync_stdout() + dlg.hangup(code) + pjsua.sync_stdout() + +# Here where it all comes together +test = TestParam(cfg_file.sendto_cfg.name, + [cfg_file.sendto_cfg.inst_param], + test_func) + + |