Skip to content

Commit

Permalink
Show off doc tests for adding content
Browse files Browse the repository at this point in the history
  • Loading branch information
smcmahon committed May 13, 2011
1 parent 289035d commit 34c9ba6
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 5 deletions.
52 changes: 52 additions & 0 deletions collective/dexterity_class/IntegrationTests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,55 @@ Integration Tests
<Application at >



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
<ContainerforEverything at /plone/Members/test_user_1_/test-container>

>>> folder['test-container'].Title()
'Test Container'

Put an Everything object in our container::

>>> my_content = createObject('collective.dexterity_class.everythingmodel')

>>> my_content
<EverythingModel at >

>>> my_content.setTitle('Test Content')
>>> my_content.Title()
u'Test Content'

>>> item = addContentToContainer(cfolder, my_content)
>>> item
<EverythingModel at /plone/Members/test_user_1_/test-container/test-content>

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
10 changes: 5 additions & 5 deletions collective/dexterity_class/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@

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):

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):
Expand Down

0 comments on commit 34c9ba6

Please sign in to comment.