Exemplo n.º 1
0
    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'),
        ]
Exemplo n.º 2
0
    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'),
            ]
Exemplo n.º 3
0
 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
Exemplo n.º 4
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
Exemplo n.º 5
0
 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
Exemplo n.º 6
0
    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
Exemplo n.º 7
0
    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
Exemplo n.º 8
0
    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
Exemplo n.º 9
0
    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
Exemplo n.º 10
0
    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])
Exemplo n.º 11
0
 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'
Exemplo n.º 12
0
 def test_type_info_add_permission_default(self):
     from kotti.resources import TypeInfo
     type_info = TypeInfo()
     assert type_info.add_permission == 'add'
Exemplo n.º 13
0
        class Target:
            implements(IContent)
            type_info = TypeInfo(name='pippo')

            def __init__(self, request):
                self.request = request
Exemplo n.º 14
0
 class Target:
     implements(IContent)
     type_info = TypeInfo(name='pippo')