[silva.core.contentlayout][Sylvain Viollon] Fix icons, and tests.
[email protected] Fri, 30 Aug 2013 13:46:22 +0200
| Newsgroups | gmane.comp.web.zope.silva.cvs |
|---|---|
| Message-ID | <[email protected]> |
author: Sylvain Viollon
date: Fri Aug 30 13:46:18 2013 +0200
revision: 353:2a720aff3037 in silva.core.contentlayout
branch: 2.4
details: https://hg.infrae.com/silva.core.contentlayout?cmd=changeset;node=2a720aff3037
modified: src/silva/core/contentlayout/interfaces.py src/silva/core/contentlayout/martiansupport.py src/silva/core/contentlayout/tests/data/test_export_design.silvaxml src/silva/core/contentlayout/tests/data/test_export_page_model.silvaxml src/silva/core/contentlayout/tests/data/test_export_ref_block.silvaxml src/silva/core/contentlayout/tests/data/test_export_source_block.silvaxml src/silva/core/contentlayout/tests/data/test_export_source_block_with_reference.silvaxml src/silva/core/contentlayout/tests/data/test_export_text_block.silvaxml src/silva/core/contentlayout/tests/test_design.py src/silva/core/contentlayout/tests/test_xml_export.py
added:
removed:
log: Fix icons, and tests.
diffstat:
src/silva/core/contentlayout/interfaces.py | 14 +-
src/silva/core/contentlayout/martiansupport.py | 4 +-
src/silva/core/contentlayout/tests/data/test_export_design.silvaxml | 8 +-
src/silva/core/contentlayout/tests/data/test_export_page_model.silvaxml | 12 +-
src/silva/core/contentlayout/tests/data/test_export_ref_block.silvaxml | 12 +-
src/silva/core/contentlayout/tests/data/test_export_source_block.silvaxml | 8 +-
src/silva/core/contentlayout/tests/data/test_export_source_block_with_reference.silvaxml | 8 +-
src/silva/core/contentlayout/tests/data/test_export_text_block.silvaxml | 8 +-
src/silva/core/contentlayout/tests/test_design.py | 51 +++
src/silva/core/contentlayout/tests/test_xml_export.py | 153 +++++----
10 files changed, 166 insertions(+), 112 deletions(-)
diffs (546 lines):
diff -r 16027da52ae9 -r 2a720aff3037 src/silva/core/contentlayout/interfaces.py
--- a/src/silva/core/contentlayout/interfaces.py Tue Aug 27 18:23:50 2013 +0200
+++ b/src/silva/core/contentlayout/interfaces.py Fri Aug 30 13:46:18 2013 +0200
@@ -15,7 +15,7 @@
from silva.core import conf as silvaconf
from silva.core.conf.interfaces import ITitledContent
from silva.core.conf.schema import Vocabulary, Term
-from silva.core.interfaces import IAddableContents
+from silva.core.interfaces import IAddableContents, IIconResolver
from silva.core.interfaces import IVersion, IVersionedObject
from silva.core.interfaces import IViewableObject, ISilvaLocalService
from silva.core.views.interfaces import IVirtualSite
@@ -166,7 +166,6 @@
"""Source vocabulary for design.
"""
registry = getUtility(IDesignLookup)
- base_url = IVirtualSite(form.request).get_root_url() + '/'
candidates = []
blacklist_identifier = None
current_identifier = None
@@ -184,7 +183,7 @@
# You cannot set a design used by this design here.
blacklist_identifier = content.get_design_identifier()
- get_icon = iconRegistry.get_icon_by_identifier
+ get_icon = IIconResolver(form.request).get_identifier_url
def make_terms():
for candidate in candidates:
@@ -198,13 +197,10 @@
candidate_identifier != current_identifier):
continue
if used_candidates:
- icon_identifier = used_candidates[-1]
+ identifier = (namespace, used_candidates[-1])
else:
- icon_identifier = 'default'
- try:
- icon = base_url + get_icon((namespace, icon_identifier))
- except ValueError:
- icon = base_url + get_icon((namespace, 'default'))
+ identifier = ('default', namespace)
+ icon = get_icon(identifier, default=namespace)
yield Term(value=candidate,
token=candidate_identifier,
title=candidate.get_design_title(),
diff -r 16027da52ae9 -r 2a720aff3037 src/silva/core/contentlayout/martiansupport.py
--- a/src/silva/core/contentlayout/martiansupport.py Tue Aug 27 18:23:50 2013 +0200
+++ b/src/silva/core/contentlayout/martiansupport.py Fri Aug 30 13:46:18 2013 +0200
@@ -143,8 +143,8 @@
# Register default icons
for category, icon in (
- (('silva.core.contentlayout.designs', 'default'), 'design.png'),
- (('silva.core.contentlayout.models', 'default'), 'model.png')):
+ (('default', 'silva.core.contentlayout.designs'), 'design.png'),
+ (('default', 'silva.core.contentlayout.models'), 'model.png')):
icon_registry.register(
category,
'++static++/silva.core.contentlayout/' + icon)
diff -r 16027da52ae9 -r 2a720aff3037 src/silva/core/contentlayout/tests/data/test_export_design.silvaxml
--- a/src/silva/core/contentlayout/tests/data/test_export_design.silvaxml Tue Aug 27 18:23:50 2013 +0200
+++ b/src/silva/core/contentlayout/tests/data/test_export_design.silvaxml Fri Aug 30 13:46:18 2013 +0200
@@ -12,10 +12,10 @@
<silva-extra:contactname/>
<silva-extra:content_description/>
<silva-extra:creationtime>YYYY-MM-DDTHH:MM:SS</silva-extra:creationtime>
- <silva-extra:creator>manager</silva-extra:creator>
+ <silva-extra:creator>author</silva-extra:creator>
<silva-extra:keywords/>
<silva-extra:language/>
- <silva-extra:lastauthor>unknown</silva-extra:lastauthor>
+ <silva-extra:lastauthor>author</silva-extra:lastauthor>
<silva-extra:modificationtime>YYYY-MM-DDTHH:MM:SS</silva-extra:modificationtime>
<silva-extra:subject/>
</set>
@@ -46,10 +46,10 @@
<silva-extra:contactname/>
<silva-extra:content_description/>
<silva-extra:creationtime>YYYY-MM-DDTHH:MM:SS</silva-extra:creationtime>
- <silva-extra:creator>manager</silva-extra:creator>
+ <silva-extra:creator>author</silva-extra:creator>
<silva-extra:keywords/>
<silva-extra:language/>
- <silva-extra:lastauthor>unknown</silva-extra:lastauthor>
+ <silva-extra:lastauthor>author</silva-extra:lastauthor>
<silva-extra:modificationtime>YYYY-MM-DDTHH:MM:SS</silva-extra:modificationtime>
<silva-extra:subject/>
</set>
diff -r 16027da52ae9 -r 2a720aff3037 src/silva/core/contentlayout/tests/data/test_export_page_model.silvaxml
--- a/src/silva/core/contentlayout/tests/data/test_export_page_model.silvaxml Tue Aug 27 18:23:50 2013 +0200
+++ b/src/silva/core/contentlayout/tests/data/test_export_page_model.silvaxml Fri Aug 30 13:46:18 2013 +0200
@@ -12,10 +12,10 @@
<silva-extra:contactname />
<silva-extra:content_description />
<silva-extra:creationtime>YYYY-MM-DDTHH:MM:SS</silva-extra:creationtime>
- <silva-extra:creator>manager</silva-extra:creator>
+ <silva-extra:creator>author</silva-extra:creator>
<silva-extra:keywords />
<silva-extra:language />
- <silva-extra:lastauthor>unknown</silva-extra:lastauthor>
+ <silva-extra:lastauthor>author</silva-extra:lastauthor>
<silva-extra:modificationtime>YYYY-MM-DDTHH:MM:SS</silva-extra:modificationtime>
<silva-extra:subject />
</set>
@@ -46,10 +46,10 @@
<silva-extra:contactname />
<silva-extra:content_description />
<silva-extra:creationtime>YYYY-MM-DDTHH:MM:SS</silva-extra:creationtime>
- <silva-extra:creator>manager</silva-extra:creator>
+ <silva-extra:creator>author</silva-extra:creator>
<silva-extra:keywords />
<silva-extra:language />
- <silva-extra:lastauthor>unknown</silva-extra:lastauthor>
+ <silva-extra:lastauthor>author</silva-extra:lastauthor>
<silva-extra:modificationtime>YYYY-MM-DDTHH:MM:SS</silva-extra:modificationtime>
<silva-extra:subject />
</set>
@@ -92,14 +92,14 @@
YYYY-MM-DDTHH:MM:SS
</silva-extra:creationtime>
<silva-extra:creator>
- manager
+ author
</silva-extra:creator>
<silva-extra:keywords>
</silva-extra:keywords>
<silva-extra:language>
</silva-extra:language>
<silva-extra:lastauthor>
- unknown
+ author
</silva-extra:lastauthor>
<silva-extra:modificationtime>
YYYY-MM-DDTHH:MM:SS
diff -r 16027da52ae9 -r 2a720aff3037 src/silva/core/contentlayout/tests/data/test_export_ref_block.silvaxml
--- a/src/silva/core/contentlayout/tests/data/test_export_ref_block.silvaxml Tue Aug 27 18:23:50 2013 +0200
+++ b/src/silva/core/contentlayout/tests/data/test_export_ref_block.silvaxml Fri Aug 30 13:46:18 2013 +0200
@@ -12,10 +12,10 @@
<silva-extra:contactname/>
<silva-extra:content_description/>
<silva-extra:creationtime>YYYY-MM-DDTHH:MM:SS</silva-extra:creationtime>
- <silva-extra:creator>manager</silva-extra:creator>
+ <silva-extra:creator>author</silva-extra:creator>
<silva-extra:keywords/>
<silva-extra:language/>
- <silva-extra:lastauthor>unknown</silva-extra:lastauthor>
+ <silva-extra:lastauthor>author</silva-extra:lastauthor>
<silva-extra:modificationtime>YYYY-MM-DDTHH:MM:SS</silva-extra:modificationtime>
<silva-extra:subject/>
</set>
@@ -46,10 +46,10 @@
<silva-extra:contactname/>
<silva-extra:content_description/>
<silva-extra:creationtime>YYYY-MM-DDTHH:MM:SS</silva-extra:creationtime>
- <silva-extra:creator>manager</silva-extra:creator>
+ <silva-extra:creator>author</silva-extra:creator>
<silva-extra:keywords/>
<silva-extra:language/>
- <silva-extra:lastauthor>unknown</silva-extra:lastauthor>
+ <silva-extra:lastauthor>author</silva-extra:lastauthor>
<silva-extra:modificationtime>YYYY-MM-DDTHH:MM:SS</silva-extra:modificationtime>
<silva-extra:subject/>
</set>
@@ -78,10 +78,10 @@
<silva-extra:contactname/>
<silva-extra:content_description/>
<silva-extra:creationtime>YYYY-MM-DDTHH:MM:SS</silva-extra:creationtime>
- <silva-extra:creator>manager</silva-extra:creator>
+ <silva-extra:creator>author</silva-extra:creator>
<silva-extra:keywords/>
<silva-extra:language/>
- <silva-extra:lastauthor>unknown</silva-extra:lastauthor>
+ <silva-extra:lastauthor>author</silva-extra:lastauthor>
<silva-extra:modificationtime>YYYY-MM-DDTHH:MM:SS</silva-extra:modificationtime>
<silva-extra:subject/>
</set>
diff -r 16027da52ae9 -r 2a720aff3037 src/silva/core/contentlayout/tests/data/test_export_source_block.silvaxml
--- a/src/silva/core/contentlayout/tests/data/test_export_source_block.silvaxml Tue Aug 27 18:23:50 2013 +0200
+++ b/src/silva/core/contentlayout/tests/data/test_export_source_block.silvaxml Fri Aug 30 13:46:18 2013 +0200
@@ -15,10 +15,10 @@
<silva-extra:content_description />
<silva-extra:creationtime>YYYY-MM-DDTHH:MM:SS
</silva-extra:creationtime>
- <silva-extra:creator>manager</silva-extra:creator>
+ <silva-extra:creator>author</silva-extra:creator>
<silva-extra:keywords />
<silva-extra:language />
- <silva-extra:lastauthor>unknown</silva-extra:lastauthor>
+ <silva-extra:lastauthor>author</silva-extra:lastauthor>
<silva-extra:modificationtime>YYYY-MM-DDTHH:MM:SS
</silva-extra:modificationtime>
<silva-extra:subject />
@@ -51,10 +51,10 @@
<silva-extra:content_description />
<silva-extra:creationtime>YYYY-MM-DDTHH:MM:SS
</silva-extra:creationtime>
- <silva-extra:creator>manager</silva-extra:creator>
+ <silva-extra:creator>author</silva-extra:creator>
<silva-extra:keywords />
<silva-extra:language />
- <silva-extra:lastauthor>unknown</silva-extra:lastauthor>
+ <silva-extra:lastauthor>author</silva-extra:lastauthor>
<silva-extra:modificationtime>YYYY-MM-DDTHH:MM:SS
</silva-extra:modificationtime>
<silva-extra:subject />
diff -r 16027da52ae9 -r 2a720aff3037 src/silva/core/contentlayout/tests/data/test_export_source_block_with_reference.silvaxml
--- a/src/silva/core/contentlayout/tests/data/test_export_source_block_with_reference.silvaxml Tue Aug 27 18:23:50 2013 +0200
+++ b/src/silva/core/contentlayout/tests/data/test_export_source_block_with_reference.silvaxml Fri Aug 30 13:46:18 2013 +0200
@@ -13,10 +13,10 @@
<silva-extra:content_description />
<silva-extra:creationtime>YYYY-MM-DDTHH:MM:SS
</silva-extra:creationtime>
- <silva-extra:creator>manager</silva-extra:creator>
+ <silva-extra:creator>author</silva-extra:creator>
<silva-extra:keywords />
<silva-extra:language />
- <silva-extra:lastauthor>unknown</silva-extra:lastauthor>
+ <silva-extra:lastauthor>author</silva-extra:lastauthor>
<silva-extra:modificationtime>YYYY-MM-DDTHH:MM:SS
</silva-extra:modificationtime>
<silva-extra:subject />
@@ -49,10 +49,10 @@
<silva-extra:content_description />
<silva-extra:creationtime>YYYY-MM-DDTHH:MM:SS
</silva-extra:creationtime>
- <silva-extra:creator>manager</silva-extra:creator>
+ <silva-extra:creator>author</silva-extra:creator>
<silva-extra:keywords />
<silva-extra:language />
- <silva-extra:lastauthor>unknown</silva-extra:lastauthor>
+ <silva-extra:lastauthor>author</silva-extra:lastauthor>
<silva-extra:modificationtime>YYYY-MM-DDTHH:MM:SS
</silva-extra:modificationtime>
<silva-extra:subject />
diff -r 16027da52ae9 -r 2a720aff3037 src/silva/core/contentlayout/tests/data/test_export_text_block.silvaxml
--- a/src/silva/core/contentlayout/tests/data/test_export_text_block.silvaxml Tue Aug 27 18:23:50 2013 +0200
+++ b/src/silva/core/contentlayout/tests/data/test_export_text_block.silvaxml Fri Aug 30 13:46:18 2013 +0200
@@ -12,10 +12,10 @@
<silva-extra:contactname/>
<silva-extra:content_description/>
<silva-extra:creationtime>YYYY-MM-DDTHH:MM:SS</silva-extra:creationtime>
- <silva-extra:creator>manager</silva-extra:creator>
+ <silva-extra:creator>author</silva-extra:creator>
<silva-extra:keywords/>
<silva-extra:language/>
- <silva-extra:lastauthor>unknown</silva-extra:lastauthor>
+ <silva-extra:lastauthor>author</silva-extra:lastauthor>
<silva-extra:modificationtime>YYYY-MM-DDTHH:MM:SS</silva-extra:modificationtime>
<silva-extra:subject/>
</set>
@@ -46,10 +46,10 @@
<silva-extra:contactname/>
<silva-extra:content_description/>
<silva-extra:creationtime>YYYY-MM-DDTHH:MM:SS</silva-extra:creationtime>
- <silva-extra:creator>manager</silva-extra:creator>
+ <silva-extra:creator>author</silva-extra:creator>
<silva-extra:keywords/>
<silva-extra:language/>
- <silva-extra:lastauthor>unknown</silva-extra:lastauthor>
+ <silva-extra:lastauthor>author</silva-extra:lastauthor>
<silva-extra:modificationtime>YYYY-MM-DDTHH:MM:SS</silva-extra:modificationtime>
<silva-extra:subject/>
</set>
diff -r 16027da52ae9 -r 2a720aff3037 src/silva/core/contentlayout/tests/test_design.py
--- a/src/silva/core/contentlayout/tests/test_design.py Tue Aug 27 18:23:50 2013 +0200
+++ b/src/silva/core/contentlayout/tests/test_design.py Fri Aug 30 13:46:18 2013 +0200
@@ -4,11 +4,15 @@
import unittest
+from Products.Silva.testing import TestRequest
from Products.Silva.ExtensionRegistry import extensionRegistry
from zope.interface.verify import verifyObject, verifyClass
+from zope.schema.interfaces import ISource
+from zeam.form.base import FormData
from ..designs.registry import registry as design_registry
from ..interfaces import IDesign, IDesignLookup
+from ..interfaces import design_identifier_source, design_source
from ..testing import FunctionalLayer
@@ -20,6 +24,53 @@
factory = self.root.manage_addProduct['silva.core.contentlayout']
factory.manage_addMockupPage('page', 'Page')
+ def test_design_identifier_source(self):
+ """Test the vocabulary used to list design identifiers (used
+ in the service).
+ """
+ vocabulary = design_identifier_source(self.root)
+ self.assertTrue(verifyObject(ISource, vocabulary))
+ self.assertEqual(len(vocabulary), 4)
+ self.assertItemsEqual(
+ map(lambda v: v.token, vocabulary),
+ ['adesign',
+ 'demo.advanced_template',
+ 'demo.one_column',
+ 'demo.two_column'])
+ self.assertItemsEqual(
+ map(lambda v: v.title, vocabulary),
+ ['A Design for testing',
+ u'Advanced design (StandardIssue)',
+ u'One Column (standard)',
+ u'Two Columns (standard)'])
+
+ def test_design_source(self):
+ """Test the vocabulary used to list design and page models in
+ the form.
+ """
+ form = FormData(self.root.page.get_editable(), TestRequest())
+ vocabulary = design_source(form)
+ self.assertTrue(verifyObject(ISource, vocabulary))
+ self.assertEqual(len(vocabulary), 4)
+ self.assertItemsEqual(
+ map(lambda v: v.token, vocabulary),
+ ['adesign',
+ 'demo.advanced_template',
+ 'demo.one_column',
+ 'demo.two_column'])
+ self.assertItemsEqual(
+ map(lambda v: v.title, vocabulary),
+ ['A Design for testing',
+ u'Advanced design (StandardIssue)',
+ u'One Column (standard)',
+ u'Two Columns (standard)'])
+ self.assertItemsEqual(
+ map(lambda v: v.icon, vocabulary),
+ ['http://localhost/root/++static++/silva.core.contentlayout/design.png',
+ 'http://localhost/root/++static++/silva.core.contentlayout/design.png',
+ 'http://localhost/root/++resource++icon-designs-demo.one_column.png',
+ 'http://localhost/root/++resource++icon-designs-demo.two_column.png'])
+
def test_registry(self):
"""Test the different lookup methods on the registry.
"""
diff -r 16027da52ae9 -r 2a720aff3037 src/silva/core/contentlayout/tests/test_xml_export.py
--- a/src/silva/core/contentlayout/tests/test_xml_export.py Tue Aug 27 18:23:50 2013 +0200
+++ b/src/silva/core/contentlayout/tests/test_xml_export.py Fri Aug 30 13:46:18 2013 +0200
@@ -4,7 +4,7 @@
import unittest
-from Products.Silva.testing import TestRequest
+from Products.Silva.testing import TestRequest, Transaction
from Products.Silva.tests.test_xml_export import SilvaXMLTestCase
from Products.SilvaExternalSources.interfaces import IExternalSourceManager
@@ -30,16 +30,18 @@
def setUp(self):
self.root = self.layer.get_application()
- factory = self.root.manage_addProduct['silva.core.contentlayout']
- factory.manage_addContentLayoutService()
- factory = self.root.manage_addProduct['Silva']
- factory.manage_addFolder('export', 'Export base')
- self.base_folder = self.root.export
- factory = self.base_folder.manage_addProduct['silva.core.contentlayout']
- factory.manage_addMockupPage('page', 'Page')
- self.page = self.base_folder.page.get_editable()
- self.design = registry.lookup_design_by_name('adesign')
- self.page.set_design(self.design)
+ with Transaction():
+ self.layer.login('author')
+ factory = self.root.manage_addProduct['silva.core.contentlayout']
+ factory.manage_addContentLayoutService()
+ factory = self.root.manage_addProduct['Silva']
+ factory.manage_addFolder('export', 'Export base')
+ self.base_folder = self.root.export
+ factory = self.base_folder.manage_addProduct['silva.core.contentlayout']
+ factory.manage_addMockupPage('page', 'Page')
+ self.page = self.base_folder.page.get_editable()
+ self.design = registry.lookup_design_by_name('adesign')
+ self.page.set_design(self.design)
def test_export_design(self):
exporter = self.assertExportEqual(
@@ -50,17 +52,18 @@
self.assertEqual(exporter.getProblems(), [])
def test_export_design_and_reference_block(self):
- factory = self.root.export.manage_addProduct['Silva']
- with self.layer.open_fixture('image.png') as image_file:
- factory.manage_addImage('image', 'Image', image_file)
+ with Transaction():
+ factory = self.root.export.manage_addProduct['Silva']
+ with self.layer.open_fixture('image.png') as image_file:
+ factory.manage_addImage('image', 'Image', image_file)
- block = ReferenceBlock()
- controller = getWrapper(
- (block, self.page, TestRequest()),
- interfaces.IBlockController)
- controller.content = self.root.export.image
- manager = interfaces.IBlockManager(self.page)
- manager.add('one', block)
+ block = ReferenceBlock()
+ controller = getWrapper(
+ (block, self.page, TestRequest()),
+ interfaces.IBlockController)
+ controller.content = self.root.export.image
+ manager = interfaces.IBlockManager(self.page)
+ manager.add('one', block)
exporter = self.assertExportEqual(
self.root.export,
@@ -76,13 +79,14 @@
[])
def test_export_text_block(self):
- block = TextBlock(identifier='text block 1')
- controller = getWrapper(
- (block, self.page, TestRequest()),
- interfaces.IBlockController)
- controller.text = "<div>text</div>"
- manager = interfaces.IBlockManager(self.page)
- manager.add('two', block)
+ with Transaction():
+ block = TextBlock(identifier='text block 1')
+ controller = getWrapper(
+ (block, self.page, TestRequest()),
+ interfaces.IBlockController)
+ controller.text = "<div>text</div>"
+ manager = interfaces.IBlockManager(self.page)
+ manager.add('two', block)
exporter = self.assertExportEqual(
self.root.export,
@@ -92,15 +96,16 @@
self.assertEqual(exporter.getProblems(), [])
def test_export_source_block(self):
- source_manager = getWrapper(self.page, IExternalSourceManager)
- parameters = dict(field_citation="A joke is a very serious thing.",
- field_author="Winston Churchill")
- request = TestRequest(form=parameters)
- controller = source_manager(request, name='cs_citation')
- marker = controller.create()
- self.assertIs(marker, silvaforms.SUCCESS)
- manager = interfaces.IBlockManager(self.page)
- manager.add('one', SourceBlock(controller.getId()))
+ with Transaction():
+ source_manager = getWrapper(self.page, IExternalSourceManager)
+ parameters = dict(field_citation="A joke is a very serious thing.",
+ field_author="Winston Churchill")
+ request = TestRequest(form=parameters)
+ controller = source_manager(request, name='cs_citation')
+ marker = controller.create()
+ self.assertIs(marker, silvaforms.SUCCESS)
+ manager = interfaces.IBlockManager(self.page)
+ manager.add('one', SourceBlock(controller.getId()))
exporter = self.assertExportEqual(
self.root.export,
@@ -110,21 +115,22 @@
self.assertEqual(exporter.getProblems(), [])
def test_export_source_block_with_reference(self):
- source_manager = getWrapper(self.page, IExternalSourceManager)
- intids = getUtility(IIntIds)
- folder_id = intids.register(self.base_folder)
- parameters = dict(field_paths=str(folder_id),
- field_toc_types="Silva Folder",
- field_depth="0",
- field_sort_on="silva",
- field_order="normal")
- request = TestRequest(form=parameters)
- controller = source_manager(request, name='cs_toc')
- marker = controller.create()
- self.assertIs(marker, silvaforms.SUCCESS)
+ with Transaction():
+ source_manager = getWrapper(self.page, IExternalSourceManager)
+ intids = getUtility(IIntIds)
+ folder_id = intids.register(self.base_folder)
+ parameters = dict(field_paths=str(folder_id),
+ field_toc_types="Silva Folder",
+ field_depth="0",
+ field_sort_on="silva",
+ field_order="normal")
+ request = TestRequest(form=parameters)
+ controller = source_manager(request, name='cs_toc')
+ marker = controller.create()
+ self.assertIs(marker, silvaforms.SUCCESS)
- manager = interfaces.IBlockManager(self.page)
- manager.add('two', SourceBlock(controller.getId()))
+ manager = interfaces.IBlockManager(self.page)
+ manager.add('two', SourceBlock(controller.getId()))
exporter = self.assertExportEqual(
self.root.export,
@@ -134,30 +140,31 @@
self.assertEqual(exporter.getProblems(), [])
def test_export_page_model(self):
- factory = self.root.export.manage_addProduct['silva.core.contentlayout']
- factory.manage_addPageModel('model', 'A Page Model')
- version = self.root.export.model.get_editable()
- version.set_design(self.design)
+ with Transaction():
+ factory = self.root.export.manage_addProduct['silva.core.contentlayout']
+ factory.manage_addPageModel('model', 'A Page Model')
+ version = self.root.export.model.get_editable()
+ version.set_design(self.design)
- text_block = TextBlock(identifier='text block 1')
- controller = getWrapper(
- (text_block, self.page, TestRequest()),
- interfaces.IBlockController)
- controller.text = "<div>text</div>"
+ text_block = TextBlock(identifier='text block 1')
+ controller = getWrapper(
+ (text_block, self.page, TestRequest()),
+ interfaces.IBlockController)
+ controller.text = "<div>text</div>"
- manager = interfaces.IBlockManager(version)
- manager.add('two', text_block)
- manager.add('two', BlockSlot(
- identifier='slot-two',
- css_class="large"))
- manager.add('one', BlockSlot(
- identifier='slot-one',
- restrictions=[
- restrictions.CodeSourceName(
- allowed=set(['allow1', 'allow2']),
- disallowed=set(['dis1', 'dis2'])),
- restrictions.Content(schema=IImage),
- restrictions.BlockAll()]))
+ manager = interfaces.IBlockManager(version)
+ manager.add('two', text_block)
+ manager.add('two', BlockSlot(
+ identifier='slot-two',
+ css_class="large"))
+ manager.add('one', BlockSlot(
+ identifier='slot-one',
+ restrictions=[
+ restrictions.CodeSourceName(
+ allowed=set(['allow1', 'allow2']),
+ disallowed=set(['dis1', 'dis2'])),
+ restrictions.Content(schema=IImage),
+ restrictions.BlockAll()]))
exporter = self.assertExportEqual(
self.root.export,