Fix clean. Test it.

squeeze-backports
Victor Seva 13 years ago
parent 8557e523e2
commit c735d1692e

@ -48,8 +48,17 @@ NGCPDomainPrefs_MT = { __index = NGCPDomainPrefs }
return keys
end
function NGCPDomainPrefs:clean()
sr.pv.unset("$xavp(domain)")
function NGCPDomainPrefs:clean(vtype)
local xavp
if not vtype then
sr.pv.unset("$xavp(domain)")
elseif vtype == 'callee' then
xavp = NGCPXAvp:new('callee','domain',{})
xavp:clean()
elseif vtype == 'caller' then
xavp = NGCPXAvp:new('caller','domain',{})
xavp:clean()
end
end
-- class
--EOF

@ -94,6 +94,63 @@ TestNGCPDomainPrefs = {} --class
assertEquals(sr.pv.get("$xavp(domain[1]=>sst_refresh_method)"), "UPDATE_FALLBACK_INVITE")
assertItemsEquals(keys, {"sst_enable", "sst_refresh_method"})
end
function TestNGCPDomainPrefs:test_clean()
local xavp = NGCPXAvp:new('callee','domain',{})
xavp("testid",1)
xavp("foo","foo")
assertEquals(sr.pv.get("$xavp(domain[1]=>testid)"),1)
assertEquals(sr.pv.get("$xavp(domain[1]=>foo)"),"foo")
assertEquals(sr.pv.get("$xavp(domain[0]=>dummy)"),"caller")
self.d:clean()
assertFalse(sr.pv.get("$xavp(domain[0]=>dummy)"))
assertFalse(sr.pv.get("$xavp(domain[1]=>dummy)"))
assertFalse(sr.pv.get("$xavp(domain)"))
end
function TestNGCPDomainPrefs:test_callee_clean()
local callee_xavp = NGCPXAvp:new('callee','domain',{})
callee_xavp("testid",1)
callee_xavp("foo","foo")
local caller_xavp = NGCPXAvp:new('caller','domain',{})
caller_xavp("other",1)
caller_xavp("otherfoo","foo")
assertEquals(sr.pv.get("$xavp(domain[1]=>testid)"),1)
assertEquals(sr.pv.get("$xavp(domain[1]=>foo)"),"foo")
assertEquals(sr.pv.get("$xavp(domain[0]=>dummy)"),"caller")
assertEquals(sr.pv.get("$xavp(domain[0]=>other)"),1)
assertEquals(sr.pv.get("$xavp(domain[0]=>otherfoo)"),"foo")
assertEquals(sr.pv.get("$xavp(domain[1]=>dummy)"),"callee")
self.d:clean('callee')
assertEquals(sr.pv.get("$xavp(domain[0]=>dummy)"),'caller')
assertFalse(sr.pv.get("$xavp(domain[1]=>testid)"))
assertFalse(sr.pv.get("$xavp(domain[1]=>foo)"))
assertEquals(sr.pv.get("$xavp(domain[0]=>other)"),1)
assertEquals(sr.pv.get("$xavp(domain[0]=>otherfoo)"),"foo")
assertEquals(sr.pv.get("$xavp(domain[1]=>dummy)"),"callee")
end
function TestNGCPDomainPrefs:test_caller_clean()
local callee_xavp = NGCPXAvp:new('callee','domain',{})
callee_xavp("testid",1)
callee_xavp("foo","foo")
local caller_xavp = NGCPXAvp:new('caller','domain',{})
caller_xavp("other",1)
caller_xavp("otherfoo","foo")
assertEquals(sr.pv.get("$xavp(domain[1]=>testid)"),1)
assertEquals(sr.pv.get("$xavp(domain[1]=>foo)"),"foo")
assertEquals(sr.pv.get("$xavp(domain[0]=>dummy)"),"caller")
assertEquals(sr.pv.get("$xavp(domain[0]=>other)"),1)
assertEquals(sr.pv.get("$xavp(domain[0]=>otherfoo)"),"foo")
assertEquals(sr.pv.get("$xavp(domain[1]=>dummy)"),"callee")
self.d:clean('caller')
assertEquals(sr.pv.get("$xavp(domain[0]=>dummy)"),'caller')
assertFalse(sr.pv.get("$xavp(domain[0]=>other)"))
assertFalse(sr.pv.get("$xavp(domain[0]=>otherfoo)"))
assertEquals(sr.pv.get("$xavp(domain[1]=>testid)"),1)
assertEquals(sr.pv.get("$xavp(domain[1]=>foo)"),"foo")
assertEquals(sr.pv.get("$xavp(domain[1]=>dummy)"),"callee")
end
-- class TestNGCPDomainPrefs
---- Control test output:

Loading…
Cancel
Save