Initializate dummy vars just in the creation.

On clear... create them.
squeeze-backports
Victor Seva 13 years ago
parent d01059784c
commit 4acb0d5131

@ -1,6 +1,6 @@
#!/usr/bin/env lua5.1 #!/usr/bin/env lua5.1
require 'ngcp.utils' require 'ngcp.utils'
require 'ngcp.xavp' require 'ngcp.pref'
-- class NGCPDomainPrefs -- class NGCPDomainPrefs
NGCPDomainPrefs = { NGCPDomainPrefs = {
@ -13,6 +13,8 @@ NGCPDomainPrefs_MT = { __index = NGCPDomainPrefs }
config = config, config = config,
db_table = "dom_preferences" db_table = "dom_preferences"
} }
-- creates xavp dom
NGCPPrefs.init("dom_prefs")
return setmetatable( t, NGCPDomainPrefs_MT ) return setmetatable( t, NGCPDomainPrefs_MT )
end end

@ -13,6 +13,8 @@ NGCPPeerPrefs_MT = { __index = NGCPPeerPrefs }
config = config, config = config,
db_table = "peer_preferences" db_table = "peer_preferences"
} }
-- creates xavp peer
NGCPPrefs.init("peer_prefs")
return setmetatable( t, NGCPPeerPrefs_MT ) return setmetatable( t, NGCPPeerPrefs_MT )
end end

@ -1,5 +1,5 @@
#!/usr/bin/env lua5.1 #!/usr/bin/env lua5.1
require 'ngcp.kam_utils' require 'ngcp.xavp'
-- class NGCPPrefs -- class NGCPPrefs
NGCPPrefs = { NGCPPrefs = {
@ -7,44 +7,13 @@ NGCPPrefs = {
} }
NGCPPrefs_MT = { __index = NGCPPrefs } NGCPPrefs_MT = { __index = NGCPPrefs }
function NGCPPrefs:new() function NGCPPrefs.init(group)
local t = NGCPPrefs.init() local _,v, xavp
setmetatable( t, NGCPPrefs_MT ) local levels = {"caller", "callee"}
return t for _,v in pairs(levels) do
end xavp = NGCPXAvp.init(v,group)
function NGCPPrefs.init()
local t = {
inbound = {},
outbound = {},
common = {},
groups = {'inbound', 'outbound', 'common'}
}
--print("NGCPPrefs:init" .. "\n" .. table.tostring(t))
return t
end
function NGCPPrefs._cleanvars(t)
for k,_ in pairs(t) do
t[k] = ""
end end
end end
function NGCPPrefs:clean(group)
--print("NGCPPrefs:clean")
--print(table.tostring(getmetatable(self)))
--print(table.tostring(self))
if group then
if self[group] then
clean_avp(self[group])
NGCPPrefs._cleanvars(self[group])
end
else
for k,v in pairs(self.groups) do
clean_avp(self[v])
NGCPPrefs._cleanvars(self[v])
end
end
end
-- class -- class
--EOF --EOF

@ -1,6 +1,6 @@
#!/usr/bin/env lua5.1 #!/usr/bin/env lua5.1
require 'ngcp.utils' require 'ngcp.utils'
require 'ngcp.xavp' require 'ngcp.pref'
-- class NGCPRealPrefs -- class NGCPRealPrefs
NGCPRealPrefs = { NGCPRealPrefs = {
@ -10,6 +10,8 @@ NGCPRealPrefs_MT = { __index = NGCPRealPrefs }
function NGCPRealPrefs:new() function NGCPRealPrefs:new()
local t = {} local t = {}
-- creates xavp real
NGCPPrefs.init("real_prefs")
return setmetatable( t, NGCPRealPrefs_MT ) return setmetatable( t, NGCPRealPrefs_MT )
end end

@ -1,6 +1,6 @@
#!/usr/bin/env lua5.1 #!/usr/bin/env lua5.1
require 'ngcp.utils' require 'ngcp.utils'
require 'ngcp.xavp' require 'ngcp.pref'
-- class NGCPUserPrefs -- class NGCPUserPrefs
NGCPUserPrefs = { NGCPUserPrefs = {
@ -13,6 +13,8 @@ NGCPUserPrefs_MT = { __index = NGCPUserPrefs }
config = config, config = config,
db_table = "usr_preferences" db_table = "usr_preferences"
} }
-- creates xavp usr
NGCPPrefs.init("usr_prefs")
return setmetatable( t, NGCPUserPrefs_MT ) return setmetatable( t, NGCPUserPrefs_MT )
end end

@ -90,6 +90,7 @@ NGCPXAvp_MT = {
local name = string.format("$xavp(%s=>dummy)", self.name) local name = string.format("$xavp(%s=>dummy)", self.name)
if not sr.pv.get(name) then if not sr.pv.get(name) then
NGCPXAvp._setvalue(name, 0, self.level) NGCPXAvp._setvalue(name, 0, self.level)
sr.log("dbg",string.format("%s created with dummy value:%s", name, self.level))
end end
for i=1,#l do for i=1,#l do
name = string.format("$xavp(%s[0]=>%s)", self.name, l[i].attribute) name = string.format("$xavp(%s[0]=>%s)", self.name, l[i].attribute)
@ -100,6 +101,7 @@ NGCPXAvp_MT = {
function NGCPXAvp:clean() function NGCPXAvp:clean()
sr.pv.unset(string.format("$xavp(%s)", self.name)) sr.pv.unset(string.format("$xavp(%s)", self.name))
sr.pv.sets(string.format("$xavp(%s=>dummy)", self.name), self.level)
end end
-- class -- class
--EOF --EOF

@ -23,10 +23,12 @@ require 'ngcp.ngcp'
TestNGCP = {} --class TestNGCP = {} --class
function TestNGCP:setUp() function TestNGCP:setUp()
sr.log("dbg", "TestNGCP:setUp")
self.ngcp = NGCP:new() self.ngcp = NGCP:new()
end end
function TestNGCP:tearDown() function TestNGCP:tearDown()
sr.log("dbg", "TestNGCP:tearDown")
sr.pv.unset("$xavp(caller_dom_prefs)") sr.pv.unset("$xavp(caller_dom_prefs)")
sr.pv.unset("$xavp(callee_dom_prefs)") sr.pv.unset("$xavp(callee_dom_prefs)")
sr.pv.unset("$xavp(caller_peer_prefs)") sr.pv.unset("$xavp(caller_peer_prefs)")
@ -55,13 +57,21 @@ TestNGCP = {} --class
end end
function TestNGCP:test_prefs_init() function TestNGCP:test_prefs_init()
--print("TestNGCP:test_prefs_init") sr.log("dbg", "TestNGCP:test_prefs_init")
assertTrue(self.ngcp) assertTrue(self.ngcp)
assertTrue(self.ngcp.prefs) assertTrue(self.ngcp.prefs)
assertTrue(self.ngcp.prefs.peer) assertTrue(self.ngcp.prefs.peer)
assertEquals(sr.pv.get("$xavp(caller_peer_prefs=>dummy)"),"caller")
assertEquals(sr.pv.get("$xavp(callee_peer_prefs=>dummy)"),"callee")
assertTrue(self.ngcp.prefs.usr) assertTrue(self.ngcp.prefs.usr)
assertEquals(sr.pv.get("$xavp(caller_usr_prefs=>dummy)"),"caller")
assertEquals(sr.pv.get("$xavp(callee_usr_prefs=>dummy)"),"callee")
assertTrue(self.ngcp.prefs.dom) assertTrue(self.ngcp.prefs.dom)
assertEquals(sr.pv.get("$xavp(caller_dom_prefs=>dummy)"),"caller")
assertEquals(sr.pv.get("$xavp(callee_dom_prefs=>dummy)"),"callee")
assertTrue(self.ngcp.prefs.real) assertTrue(self.ngcp.prefs.real)
assertEquals(sr.pv.get("$xavp(caller_real_prefs=>dummy)"),"caller")
assertEquals(sr.pv.get("$xavp(callee_real_prefs=>dummy)"),"callee")
end end
function TestNGCP:test_caller_usr_load_empty() function TestNGCP:test_caller_usr_load_empty()
@ -86,10 +96,10 @@ TestNGCP = {} --class
xavp("foo","foo") xavp("foo","foo")
assertEquals(sr.pv.get("$xavp(callee_usr_prefs=>testid)"),1) assertEquals(sr.pv.get("$xavp(callee_usr_prefs=>testid)"),1)
assertEquals(sr.pv.get("$xavp(callee_usr_prefs=>foo)"),"foo") assertEquals(sr.pv.get("$xavp(callee_usr_prefs=>foo)"),"foo")
assertFalse(sr.pv.get("$xavp(caller_usr_prefs=>dummy)")) assertEquals(sr.pv.get("$xavp(caller_usr_prefs=>dummy)"), "caller")
self.ngcp:clean() self.ngcp:clean()
assertFalse(sr.pv.get("$xavp(caller_usr_prefs=>dummy)")) assertEquals(sr.pv.get("$xavp(caller_usr_prefs=>dummy)"),"caller")
assertFalse(sr.pv.get("$xavp(callee_usr_prefs=>dummy)")) assertEquals(sr.pv.get("$xavp(callee_usr_prefs=>dummy)"),"callee")
assertFalse(sr.pv.get("$xavp(user)")) assertFalse(sr.pv.get("$xavp(user)"))
end end
@ -98,21 +108,27 @@ TestNGCP = {} --class
local _,v local _,v
for _,v in pairs(groups) do for _,v in pairs(groups) do
assertEquals(sr.pv.get(string.format("$xavp(caller_%s_prefs=>dummy)", v), "caller")) xavp = self.ngcp.prefs[v]:xavp("caller")
xavp(string.format("test_%s", v), v)
assertEquals(sr.pv.get(string.format("$xavp(caller_%s_prefs=>test_%s)", v, v)), v)
assertEquals(sr.pv.get(string.format("$xavp(caller_%s_prefs=>dummy)", v)), "caller")
self.ngcp:clean("caller", v) self.ngcp:clean("caller", v)
assertFalse(sr.pv.get(string.format("$xavp(caller_%s_prefs=>dummy)", v))) assertEquals(sr.pv.get(string.format("$xavp(caller_%s_prefs=>dummy)", v)), "caller")
end end
assertError(self.ngcp.clean, self.ngcp, "caller", "whatever") assertError(self.ngcp.clean, self.ngcp, "caller", "whatever")
end end
function TestNGCP:test_clean_callee_groups() function TestNGCP:test_clean_callee_groups()
local groups = {"peer", "usr", "dom", "real"} local groups = {"peer", "usr", "dom", "real"}
local _,v local _,v, xavp
for _,v in pairs(groups) do for _,v in pairs(groups) do
assertEquals(sr.pv.get(string.format("$xavp(callee_%s_prefs=>dummy)", v), "callee")) xavp = self.ngcp.prefs[v]:xavp("callee")
xavp(string.format("test_%s", v), v)
assertEquals(sr.pv.get(string.format("$xavp(callee_%s_prefs=>test_%s)", v, v)), v)
assertEquals(sr.pv.get(string.format("$xavp(callee_%s_prefs=>dummy)", v)), "callee")
self.ngcp:clean("callee", v) self.ngcp:clean("callee", v)
assertFalse(sr.pv.get(string.format("$xavp(callee_%s_prefs=>dummy)", v))) assertEquals(sr.pv.get(string.format("$xavp(callee_%s_prefs=>dummy)", v)), "callee")
end end
assertError(self.ngcp.clean, self.ngcp, "callee", "whatever") assertError(self.ngcp.clean, self.ngcp, "callee", "whatever")
end end
@ -136,7 +152,7 @@ TestNGCP = {} --class
assertFalse(sr.pv.get("$xavp(callee_dom_prefs=>foo)")) assertFalse(sr.pv.get("$xavp(callee_dom_prefs=>foo)"))
assertEquals(sr.pv.get("$xavp(caller_dom_prefs=>other)"),1) assertEquals(sr.pv.get("$xavp(caller_dom_prefs=>other)"),1)
assertEquals(sr.pv.get("$xavp(caller_dom_prefs=>otherfoo)"),"foo") assertEquals(sr.pv.get("$xavp(caller_dom_prefs=>otherfoo)"),"foo")
assertFalse(sr.pv.get("$xavp(callee_dom_prefs=>dummy)")) assertEquals(sr.pv.get("$xavp(callee_dom_prefs=>dummy)"), "callee")
end end
function TestNGCP:test_caller_clean() function TestNGCP:test_caller_clean()
@ -153,7 +169,7 @@ TestNGCP = {} --class
assertEquals(sr.pv.get("$xavp(caller_peer_prefs=>otherfoo)"),"foo") assertEquals(sr.pv.get("$xavp(caller_peer_prefs=>otherfoo)"),"foo")
assertEquals(sr.pv.get("$xavp(callee_peer_prefs=>dummy)"),"callee") assertEquals(sr.pv.get("$xavp(callee_peer_prefs=>dummy)"),"callee")
self.ngcp:clean('caller') self.ngcp:clean('caller')
assertFalse(sr.pv.get("$xavp(caller_peer_prefs=>dummy)")) assertEquals(sr.pv.get("$xavp(caller_peer_prefs=>dummy)"),"caller")
assertFalse(sr.pv.get("$xavp(caller_peer_prefs=>other)")) assertFalse(sr.pv.get("$xavp(caller_peer_prefs=>other)"))
assertFalse(sr.pv.get("$xavp(caller_peer_prefs=>otherfoo)")) assertFalse(sr.pv.get("$xavp(caller_peer_prefs=>otherfoo)"))
assertEquals(sr.pv.get("$xavp(callee_peer_prefs=>testid)"),1) assertEquals(sr.pv.get("$xavp(callee_peer_prefs=>testid)"),1)

@ -124,10 +124,10 @@ TestNGCPDomainPrefs = {} --class
xavp("foo","foo") xavp("foo","foo")
assertEquals(sr.pv.get("$xavp(callee_dom_prefs=>testid)"),1) assertEquals(sr.pv.get("$xavp(callee_dom_prefs=>testid)"),1)
assertEquals(sr.pv.get("$xavp(callee_dom_prefs=>foo)"),"foo") assertEquals(sr.pv.get("$xavp(callee_dom_prefs=>foo)"),"foo")
assertFalse(sr.pv.get("$xavp(caller_dom_prefs=>dummy)")) assertEquals(sr.pv.get("$xavp(caller_dom_prefs=>dummy)"),"caller")
self.d:clean() self.d:clean()
assertFalse(sr.pv.get("$xavp(caller_dom_prefs=>dummy)")) assertEquals(sr.pv.get("$xavp(caller_dom_prefs=>dummy)"),"caller")
assertFalse(sr.pv.get("$xavp(callee_dom_prefs=>dummy)")) assertEquals(sr.pv.get("$xavp(callee_dom_prefs=>dummy)"),"callee")
assertFalse(sr.pv.get("$xavp(domain)")) assertFalse(sr.pv.get("$xavp(domain)"))
end end
@ -150,7 +150,7 @@ TestNGCPDomainPrefs = {} --class
assertFalse(sr.pv.get("$xavp(callee_dom_prefs=>foo)")) assertFalse(sr.pv.get("$xavp(callee_dom_prefs=>foo)"))
assertEquals(sr.pv.get("$xavp(caller_dom_prefs=>other)"),1) assertEquals(sr.pv.get("$xavp(caller_dom_prefs=>other)"),1)
assertEquals(sr.pv.get("$xavp(caller_dom_prefs=>otherfoo)"),"foo") assertEquals(sr.pv.get("$xavp(caller_dom_prefs=>otherfoo)"),"foo")
assertFalse(sr.pv.get("$xavp(callee_dom_prefs=>dummy)")) assertEquals(sr.pv.get("$xavp(callee_dom_prefs=>dummy)"),"callee")
end end
function TestNGCPDomainPrefs:test_caller_clean() function TestNGCPDomainPrefs:test_caller_clean()
@ -167,7 +167,7 @@ TestNGCPDomainPrefs = {} --class
assertEquals(sr.pv.get("$xavp(caller_dom_prefs=>otherfoo)"),"foo") assertEquals(sr.pv.get("$xavp(caller_dom_prefs=>otherfoo)"),"foo")
assertEquals(sr.pv.get("$xavp(callee_dom_prefs=>dummy)"),"callee") assertEquals(sr.pv.get("$xavp(callee_dom_prefs=>dummy)"),"callee")
self.d:clean('caller') self.d:clean('caller')
assertFalse(sr.pv.get("$xavp(caller_dom_prefs=>dummy)")) assertEquals(sr.pv.get("$xavp(caller_dom_prefs=>dummy)"),"caller")
assertFalse(sr.pv.get("$xavp(caller_dom_prefs=>other)")) assertFalse(sr.pv.get("$xavp(caller_dom_prefs=>other)"))
assertFalse(sr.pv.get("$xavp(caller_dom_prefs=>otherfoo)")) assertFalse(sr.pv.get("$xavp(caller_dom_prefs=>otherfoo)"))
assertEquals(sr.pv.get("$xavp(callee_dom_prefs=>testid)"),1) assertEquals(sr.pv.get("$xavp(callee_dom_prefs=>testid)"),1)

@ -124,11 +124,11 @@ TestNGCPPeerPrefs = {} --class
xavp("foo","foo") xavp("foo","foo")
assertEquals(sr.pv.get("$xavp(callee_peer_prefs=>testid)"),1) assertEquals(sr.pv.get("$xavp(callee_peer_prefs=>testid)"),1)
assertEquals(sr.pv.get("$xavp(callee_peer_prefs=>foo)"),"foo") assertEquals(sr.pv.get("$xavp(callee_peer_prefs=>foo)"),"foo")
assertFalse(sr.pv.get("$xavp(caller_peer_prefs=>dummy)")) assertEquals(sr.pv.get("$xavp(caller_peer_prefs=>dummy)"),"caller")
assertEquals(sr.pv.get("$xavp(callee_peer_prefs=>dummy)"),"callee") assertEquals(sr.pv.get("$xavp(callee_peer_prefs=>dummy)"),"callee")
self.d:clean() self.d:clean()
assertFalse(sr.pv.get("$xavp(caller_peer_prefs=>dummy)")) assertEquals(sr.pv.get("$xavp(caller_peer_prefs=>dummy)"),"caller")
assertFalse(sr.pv.get("$xavp(callee_peer_prefs=>dummy)")) assertEquals(sr.pv.get("$xavp(callee_peer_prefs=>dummy)"),"callee")
assertFalse(sr.pv.get("$xavp(peer)")) assertFalse(sr.pv.get("$xavp(peer)"))
end end
@ -151,7 +151,7 @@ TestNGCPPeerPrefs = {} --class
assertFalse(sr.pv.get("$xavp(callee_peer_prefs=>foo)")) assertFalse(sr.pv.get("$xavp(callee_peer_prefs=>foo)"))
assertEquals(sr.pv.get("$xavp(caller_peer_prefs=>other)"),1) assertEquals(sr.pv.get("$xavp(caller_peer_prefs=>other)"),1)
assertEquals(sr.pv.get("$xavp(caller_peer_prefs=>otherfoo)"),"foo") assertEquals(sr.pv.get("$xavp(caller_peer_prefs=>otherfoo)"),"foo")
assertFalse(sr.pv.get("$xavp(callee_peer_prefs=>dummy)")) assertEquals(sr.pv.get("$xavp(callee_peer_prefs=>dummy)"),"callee")
end end
function TestNGCPPeerPrefs:test_caller_clean() function TestNGCPPeerPrefs:test_caller_clean()
@ -168,7 +168,7 @@ TestNGCPPeerPrefs = {} --class
assertEquals(sr.pv.get("$xavp(caller_peer_prefs=>otherfoo)"),"foo") assertEquals(sr.pv.get("$xavp(caller_peer_prefs=>otherfoo)"),"foo")
assertEquals(sr.pv.get("$xavp(callee_peer_prefs=>dummy)"),"callee") assertEquals(sr.pv.get("$xavp(callee_peer_prefs=>dummy)"),"callee")
self.d:clean('caller') self.d:clean('caller')
assertFalse(sr.pv.get("$xavp(caller_peer_prefs=>dummy)")) assertEquals(sr.pv.get("$xavp(caller_peer_prefs=>dummy)"),"caller")
assertFalse(sr.pv.get("$xavp(caller_peer_prefs=>other)")) assertFalse(sr.pv.get("$xavp(caller_peer_prefs=>other)"))
assertFalse(sr.pv.get("$xavp(caller_peer_prefs=>otherfoo)")) assertFalse(sr.pv.get("$xavp(caller_peer_prefs=>otherfoo)"))
assertEquals(sr.pv.get("$xavp(callee_peer_prefs=>testid)"),1) assertEquals(sr.pv.get("$xavp(callee_peer_prefs=>testid)"),1)

@ -150,8 +150,8 @@ TestNGCPRealPrefs = {} --class
end end
function TestNGCPRealPrefs:test_set() function TestNGCPRealPrefs:test_set()
assertFalse(sr.pv.get("$xavp(callee_real_prefs=>dummy)")) assertEquals(sr.pv.get("$xavp(callee_real_prefs=>dummy)"),"callee")
assertFalse(sr.pv.get("$xavp(callee_real_prefs)")) assertEquals(sr.pv.get("$xavp(caller_real_prefs=>dummy)"), "caller")
assertFalse(sr.pv.get("$xavp(callee_real_prefs=>testid)")) assertFalse(sr.pv.get("$xavp(callee_real_prefs=>testid)"))
assertFalse(sr.pv.get("$xavp(callee_real_prefs=>foo)")) assertFalse(sr.pv.get("$xavp(callee_real_prefs=>foo)"))
@ -172,12 +172,12 @@ TestNGCPRealPrefs = {} --class
assertEquals(sr.pv.get("$xavp(callee_real_prefs=>testid)"),1) assertEquals(sr.pv.get("$xavp(callee_real_prefs=>testid)"),1)
callee_xavp("foo","foo") callee_xavp("foo","foo")
assertEquals(sr.pv.get("$xavp(callee_real_prefs=>foo)"),"foo") assertEquals(sr.pv.get("$xavp(callee_real_prefs=>foo)"),"foo")
assertFalse(sr.pv.get("$xavp(caller_real_prefs=>dummy)")) assertEquals(sr.pv.get("$xavp(caller_real_prefs=>dummy)"),"caller")
self.real:clean() self.real:clean()
assertFalse(sr.pv.get("$xavp(caller_real_prefs=>dummy)")) assertEquals(sr.pv.get("$xavp(caller_real_prefs=>dummy)"),"caller")
assertFalse(sr.pv.get("$xavp(callee_real_prefs=>dummy)")) assertEquals(sr.pv.get("$xavp(callee_real_prefs=>dummy)"),"callee")
end end
function TestNGCPRealPrefs:test_callee_clean() function TestNGCPRealPrefs:test_callee_clean()
@ -204,7 +204,7 @@ TestNGCPRealPrefs = {} --class
assertFalse(sr.pv.get("$xavp(callee_real_prefs=>foo)")) assertFalse(sr.pv.get("$xavp(callee_real_prefs=>foo)"))
assertEquals(sr.pv.get("$xavp(caller_real_prefs=>other)"),1) assertEquals(sr.pv.get("$xavp(caller_real_prefs=>other)"),1)
assertEquals(sr.pv.get("$xavp(caller_real_prefs=>otherfoo)"),"foo") assertEquals(sr.pv.get("$xavp(caller_real_prefs=>otherfoo)"),"foo")
assertFalse(sr.pv.get("$xavp(callee_real_prefs=>dummy)")) assertEquals(sr.pv.get("$xavp(callee_real_prefs=>dummy)"),"callee")
end end
function TestNGCPRealPrefs:test_caller_clean() function TestNGCPRealPrefs:test_caller_clean()
@ -226,7 +226,7 @@ TestNGCPRealPrefs = {} --class
self.real:clean('caller') self.real:clean('caller')
assertFalse(sr.pv.get("$xavp(caller_real_prefs=>dummy)")) assertEquals(sr.pv.get("$xavp(caller_real_prefs=>dummy)"),"caller")
assertFalse(sr.pv.get("$xavp(caller_real_prefs=>other)")) assertFalse(sr.pv.get("$xavp(caller_real_prefs=>other)"))
assertFalse(sr.pv.get("$xavp(caller_real_prefs=>otherfoo)")) assertFalse(sr.pv.get("$xavp(caller_real_prefs=>otherfoo)"))
assertEquals(sr.pv.get("$xavp(callee_real_prefs=>testid)"),1) assertEquals(sr.pv.get("$xavp(callee_real_prefs=>testid)"),1)

@ -132,10 +132,10 @@ TestNGCPUserPrefs = {} --class
xavp("foo","foo") xavp("foo","foo")
assertEquals(sr.pv.get("$xavp(callee_usr_prefs=>testid)"),1) assertEquals(sr.pv.get("$xavp(callee_usr_prefs=>testid)"),1)
assertEquals(sr.pv.get("$xavp(callee_usr_prefs=>foo)"),"foo") assertEquals(sr.pv.get("$xavp(callee_usr_prefs=>foo)"),"foo")
assertFalse(sr.pv.get("$xavp(caller_usr_prefs=>dummy)"),"caller") assertEquals(sr.pv.get("$xavp(caller_usr_prefs=>dummy)"),"caller")
self.d:clean() self.d:clean()
assertFalse(sr.pv.get("$xavp(caller_usr_prefs)")) assertEquals(sr.pv.get("$xavp(caller_usr_prefs=>dummy)"), "caller")
assertFalse(sr.pv.get("$xavp(callee_usr_prefs)")) assertEquals(sr.pv.get("$xavp(callee_usr_prefs=>dummy)"), "callee")
end end
function TestNGCPUserPrefs:test_callee_clean() function TestNGCPUserPrefs:test_callee_clean()
@ -157,7 +157,7 @@ TestNGCPUserPrefs = {} --class
assertFalse(sr.pv.get("$xavp(callee_usr_prefs=>foo)")) assertFalse(sr.pv.get("$xavp(callee_usr_prefs=>foo)"))
assertEquals(sr.pv.get("$xavp(caller_usr_prefs=>other)"),1) assertEquals(sr.pv.get("$xavp(caller_usr_prefs=>other)"),1)
assertEquals(sr.pv.get("$xavp(caller_usr_prefs=>otherfoo)"),"foo") assertEquals(sr.pv.get("$xavp(caller_usr_prefs=>otherfoo)"),"foo")
assertFalse(sr.pv.get("$xavp(callee_usr_prefs=>dummy)")) assertEquals(sr.pv.get("$xavp(callee_usr_prefs=>dummy)"),"callee")
end end
function TestNGCPUserPrefs:test_caller_clean() function TestNGCPUserPrefs:test_caller_clean()
@ -174,7 +174,7 @@ TestNGCPUserPrefs = {} --class
assertEquals(sr.pv.get("$xavp(caller_usr_prefs=>otherfoo)"),"foo") assertEquals(sr.pv.get("$xavp(caller_usr_prefs=>otherfoo)"),"foo")
assertEquals(sr.pv.get("$xavp(callee_usr_prefs=>dummy)"),"callee") assertEquals(sr.pv.get("$xavp(callee_usr_prefs=>dummy)"),"callee")
self.d:clean('caller') self.d:clean('caller')
assertFalse(sr.pv.get("$xavp(caller_usr_prefs=>dummy)")) assertEquals(sr.pv.get("$xavp(caller_usr_prefs=>dummy)"),"caller")
assertFalse(sr.pv.get("$xavp(caller_usr_prefs=>other)")) assertFalse(sr.pv.get("$xavp(caller_usr_prefs=>other)"))
assertFalse(sr.pv.get("$xavp(caller_usr_prefs=>otherfoo)")) assertFalse(sr.pv.get("$xavp(caller_usr_prefs=>otherfoo)"))
assertEquals(sr.pv.get("$xavp(callee_usr_prefs=>testid)"),1) assertEquals(sr.pv.get("$xavp(callee_usr_prefs=>testid)"),1)

@ -81,9 +81,9 @@ TestNGCPXAvp = {} --class
assertEquals(sr.pv.get("$xavp(caller_peer=>testid)"),1) assertEquals(sr.pv.get("$xavp(caller_peer=>testid)"),1)
assertEquals(sr.pv.get("$xavp(caller_peer=>dummy)"),"caller") assertEquals(sr.pv.get("$xavp(caller_peer=>dummy)"),"caller")
xavp:clean() xavp:clean()
assertEquals(sr.pv.get("$xavp(caller_peer=>dummy)"),"caller")
assertFalse(xavp("testid")) assertFalse(xavp("testid"))
assertFalse(sr.pv.get("$xavp(caller_peer=>testid)")) assertFalse(sr.pv.get("$xavp(caller_peer=>testid)"))
assertFalse(sr.pv.get("$xavp(caller_peer)"))
end end
function TestNGCPXAvp:test_clean_all() function TestNGCPXAvp:test_clean_all()
@ -93,12 +93,12 @@ TestNGCPXAvp = {} --class
assertEquals(sr.pv.get("$xavp(callee_peer=>dummy)"),"callee") assertEquals(sr.pv.get("$xavp(callee_peer=>dummy)"),"callee")
xavp_caller:clean() xavp_caller:clean()
assertFalse(sr.pv.get("$xavp(caller_peer=>dummy)")) assertEquals(sr.pv.get("$xavp(caller_peer=>dummy)"),"caller")
assertEquals(sr.pv.get("$xavp(callee_peer=>dummy)"),"callee") assertEquals(sr.pv.get("$xavp(callee_peer=>dummy)"),"callee")
xavp_callee:clean() xavp_callee:clean()
assertFalse(sr.pv.get("$xavp(callee_peer=>dummy)")) assertEquals(sr.pv.get("$xavp(callee_peer=>dummy)"), "callee")
assertFalse(sr.pv.get("$xavp(caller_peer=>dummy)")) assertEquals(sr.pv.get("$xavp(caller_peer=>dummy)"), "caller")
end end

Loading…
Cancel
Save