From 34c9ba6d093e664a53d8485faeb82fe354e01223 Mon Sep 17 00:00:00 2001 From: Steve McMahon Date: Fri, 13 May 2011 15:55:06 -0700 Subject: [PATCH] Show off doc tests for adding content --- .../dexterity_class/IntegrationTests.txt | 52 +++++++++++++++++++ collective/dexterity_class/tests.py | 10 ++-- 2 files changed, 57 insertions(+), 5 deletions(-) diff --git a/collective/dexterity_class/IntegrationTests.txt b/collective/dexterity_class/IntegrationTests.txt index 8dded8f..f8b2777 100644 --- a/collective/dexterity_class/IntegrationTests.txt +++ b/collective/dexterity_class/IntegrationTests.txt @@ -25,3 +25,55 @@ Integration Tests + +Create a Container for Everything + + Create the object:: + + >>> from zope.component import createObject + >>> container = createObject('collective.dexterity_class.containerforeverything') + + Verify it's type:: + + >>> container.portal_type + 'collective.dexterity_class.containerforeverything' + + Give it a title:: + + >>> container.setTitle('Test Container') + >>> container.Title() + 'Test Container' + + Put it in our base folder:: + + >>> from plone.dexterity.utils import addContentToContainer + >>> cfolder = addContentToContainer(folder, container) + + >>> cfolder + + + >>> folder['test-container'].Title() + 'Test Container' + +Put an Everything object in our container:: + + >>> my_content = createObject('collective.dexterity_class.everythingmodel') + + >>> my_content + + + >>> my_content.setTitle('Test Content') + >>> my_content.Title() + u'Test Content' + + >>> item = addContentToContainer(cfolder, my_content) + >>> item + + +Try to add something that should not fit:: + + >>> new_content = createObject('collective.dexterity_class.typefromschema') + >>> item = addContentToContainer(cfolder, new_content) + Traceback (most recent call last): + ... + ValueError: Disallowed subobject type: collective.dexterity_class.typefromschema \ No newline at end of file diff --git a/collective/dexterity_class/tests.py b/collective/dexterity_class/tests.py index 7f2a437..0f8a2fd 100644 --- a/collective/dexterity_class/tests.py +++ b/collective/dexterity_class/tests.py @@ -3,16 +3,18 @@ from Testing import ZopeTestCase as ztc -from Products.Five import fiveconfigure +from Products.Five import zcml from Products.PloneTestCase import PloneTestCase as ptc from Products.PloneTestCase.layer import PloneSite -ptc.setupPloneSite() +from Products.PloneTestCase.layer import onsetup import collective.dexterity_class OPTION_FLAGS = doctest.NORMALIZE_WHITESPACE | \ doctest.ELLIPSIS +ptc.setupPloneSite(products=['collective.dexterity_class']) + class TestCase(ptc.PloneTestCase): @@ -20,9 +22,7 @@ class layer(PloneSite): @classmethod def setUp(cls): - fiveconfigure.debug_mode = True - ztc.installPackage(collective.dexterity_class) - fiveconfigure.debug_mode = False + zcml.load_config('configure.zcml', collective.dexterity_class) @classmethod def tearDown(cls):