Exemplo n.º 1
0
    async def test_creator_used_from_content_creation(self, dummy_request):
        self.request = dummy_request
        utils.login(self.request)

        container = await create_content(
            'Container',
            id='guillotina',
            title='Guillotina')
        container.__name__ = 'guillotina'
        utils._p_register(container)

        import guillotina.tests
        configure.register_configuration(Folder, dict(
            type_name="TestType2",
            behaviors=[],
            module=guillotina.tests  # for registration initialization
        ), 'contenttype')
        root = get_utility(IApplication, name='root')

        configure.load_configuration(
            root.app.config, 'guillotina.tests', 'contenttype')
        root.app.config.execute_actions()
        load_cached_schema()

        obj = await create_content_in_container(
            container, 'TestType2', 'foobar',
            creators=('root',), contributors=('root',))

        assert obj.creators == ('root',)
        assert obj.contributors == ('root',)

        behavior = IDublinCore(obj)
        assert behavior.creators == ('root',)
        assert behavior.contributors == ('root',)
Exemplo n.º 2
0
    async def test_allowed_types(self, dummy_request):
        self.request = dummy_request
        utils.login(self.request)

        container = await create_content(
            'Container',
            id='guillotina',
            title='Guillotina')
        container.__name__ = 'guillotina'
        utils._p_register(container)

        import guillotina.tests
        configure.register_configuration(Folder, dict(
            type_name="TestType",
            allowed_types=['Item'],
            module=guillotina.tests  # for registration initialization
        ), 'contenttype')
        root = get_utility(IApplication, name='root')

        configure.load_configuration(
            root.app.config, 'guillotina.tests', 'contenttype')
        root.app.config.execute_actions()
        load_cached_schema()

        obj = await create_content_in_container(container, 'TestType', 'foobar')

        constrains = IConstrainTypes(obj, None)
        assert constrains.get_allowed_types() == ['Item']
        assert constrains.is_type_allowed('Item')

        with pytest.raises(NotAllowedContentType):
            await create_content_in_container(obj, 'TestType', 'foobar')
        await create_content_in_container(obj, 'Item', 'foobar')
Exemplo n.º 3
0
    async def test_allowed_to_create_content(self, dummy_request):
        self.request = dummy_request
        utils.login(self.request)

        container = await create_content('Container',
                                         id='guillotina',
                                         title='Guillotina')
        container.__name__ = 'guillotina'
        utils._p_register(container)

        await create_content_in_container(container, 'Item', id_='foobar')