Add "add" ContentView method & test

This commit is contained in:
Chris Czub 2015-11-09 11:06:16 -05:00
parent f62d564cfb
commit 82a90511bc
2 changed files with 21 additions and 0 deletions

View File

@ -515,6 +515,14 @@ def get_by_shortcut(c):
return i return i
def add(obj):
for i in views:
if i.name == obj.name:
raise ContentViewException("Duplicate view: " + obj.name)
views.append(obj)
def get(name): def get(name):
for i in views: for i in views:
if i.name == name: if i.name == name:

View File

@ -210,6 +210,19 @@ Larry
assert "decoded gzip" in r[0] assert "decoded gzip" in r[0]
assert "Raw" in r[0] assert "Raw" in r[0]
def test_add_cv(self):
class TestContentView(cv.View):
name = "test"
tcv = TestContentView()
cv.add(tcv)
tutils.raises(
ContentViewException,
cv.add,
tcv
)
if pyamf: if pyamf:
def test_view_amf_request(): def test_view_amf_request():