diff --git a/mocks/pv.lua b/mocks/pv.lua index 46438eb..79bb888 100644 --- a/mocks/pv.lua +++ b/mocks/pv.lua @@ -42,10 +42,13 @@ local pvMock = { -- fake pseudo vars go here t.vars_pv = { ro = { + ci = "fake_ci", + ua = "fake agent", si = "127.0.0.1", sp = "9090" }, rw = { + ru = "sip:noname@nodomain.com:5060;transport=udp", rU = "noname" } } @@ -242,6 +245,22 @@ local pvMock = { end end + function t.gete(id) + return t.get(id) or "" + end + + function t.getvn(id, default) + return t.get(id) or default + end + + function t.getvs(id, default) + return t.get(id) or tostring(default) + end + + function t.getvw(id) + return t.get(id) or "<>" + end + function t._addvalue_new(result, value) local temp if result.type == 'var' or result.type == 'dlg_var' then diff --git a/tests/mocks_pv.lua b/tests/mocks_pv.lua index 9ab207f..e462a0e 100644 --- a/tests/mocks_pv.lua +++ b/tests/mocks_pv.lua @@ -488,3 +488,27 @@ TestPVMock = {} lu.assertEquals(self.pv.get("$avp(s:hithere)"), 1) lu.assertEquals(self.pv.get("$(avp(s:hithere)[*])"), {1}) end + + function TestPVMock:test_pv_gete() + lu.assertEquals(self.pv.gete("$avp(hithere)"), "") + self.pv.seti("$avp(hithere)", 0) + lu.assertEquals(self.pv.gete("$avp(hithere)"), 0) + end + + function TestPVMock:test_pv_getvn() + lu.assertEquals(self.pv.getvn("$avp(hithere)", 1), 1) + self.pv.seti("$avp(hithere)", 0) + lu.assertEquals(self.pv.getvn("$avp(hithere)", 1), 0) + end + + function TestPVMock:test_pv_getvs() + lu.assertEquals(self.pv.getvs("$avp(hithere)", "1"), "1") + self.pv.seti("$avp(hithere)", 0) + lu.assertEquals(self.pv.getvs("$avp(hithere)", "1"), 0) + end + + function TestPVMock:test_pv_getvw() + lu.assertEquals(self.pv.getvw("$avp(hithere)"), "<>") + self.pv.seti("$avp(hithere)", 0) + lu.assertEquals(self.pv.getvw("$avp(hithere)"), 0) + end