def test_add_selectable_default_view(self): from kotti.resources import TypeInfo type_info = TypeInfo(selectable_default_views=[]) type_info.add_selectable_default_view('foo', u'Fannick') assert type_info.selectable_default_views == [ ('foo', u'Fannick'), ]
def test_type_info_unaddable(self): from kotti.resources import TypeInfo type_info = TypeInfo(add_view=None, addable_to=['Document']) context = Mock(type_info=Mock()) context.type_info.name = 'Document' with patch('kotti.resources.view_permitted') as vp: res = type_info.addable(context, None) assert vp.call_count == 0
def test_copy(self): from kotti.resources import TypeInfo obj = object() ti = TypeInfo(name='dummy', edit_links=[obj]) ti_copy = ti.copy() assert ti_copy.name == 'dummy' assert ti_copy.edit_links[0] == obj assert ti.edit_links is not ti_copy.edit_links
def test_add_selectable_default_view(self): from kotti.resources import Content from kotti.resources import Document from kotti.resources import TypeInfo type_info = TypeInfo(selectable_default_views=[]) type_info.add_selectable_default_view("foo", "Fannick") assert type_info.selectable_default_views == [("foo", "Fannick")] Document.type_info.add_selectable_default_view("one", "two") assert ("one", "two") in Document.type_info.selectable_default_views assert ("one", "two") not in Content.type_info.selectable_default_views
def test_add_selectable_default_view(self): from kotti.resources import Content from kotti.resources import Document from kotti.resources import TypeInfo type_info = TypeInfo(selectable_default_views=[]) type_info.add_selectable_default_view('foo', u'Fannick') assert type_info.selectable_default_views == [ ('foo', u'Fannick'), ] Document.type_info.add_selectable_default_view('one', 'two') assert ('one', 'two') in Document.type_info.selectable_default_views assert ('one', 'two') not in Content.type_info.selectable_default_views
def test_type_info_action_links_deprecated(self, allwarnings): from kotti.resources import TypeInfo from kotti.util import LinkParent my_item = object() with warnings.catch_warnings(record=True) as wngs: # If there's a last LinkParent item, we'll assume that is # the action menu. TypeInfo(edit_links=[LinkParent("foo", [])], action_links=[my_item]) assert wngs[0].category == DeprecationWarning with raises(ValueError): # If there's no last LinkParent item, we'll raise an # error, since we can't do anything useful with the link. TypeInfo(edit_links=[], action_links=[my_item])
def test_type_info_add_permission_custom(self): from kotti.resources import TypeInfo type_info = TypeInfo(add_permission='customadd') assert type_info.add_permission == 'customadd'
def test_type_info_add_permission_default(self): from kotti.resources import TypeInfo type_info = TypeInfo() assert type_info.add_permission == 'add'
class Target: implements(IContent) type_info = TypeInfo(name='pippo') def __init__(self, request): self.request = request
class Target: implements(IContent) type_info = TypeInfo(name='pippo')