Skip to content

Commit

Permalink
Backport rudimentary content type tests from templer.dexterity.
Browse files Browse the repository at this point in the history
  • Loading branch information
smcmahon committed Apr 9, 2013
1 parent 19dba7e commit 13bb277
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 14 deletions.
3 changes: 3 additions & 0 deletions docs/HISTORY.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ development is taking place in templer.dexterity (also in the collective).
1.5.0 (unreleased)
------------------

* Backport rudimentary content type tests from templer.dexterity.
[smcmahon]

* Dexterity 2 is deemphasizing the Item type in favor of containers which
may or may not allow contents. Adjusted question and actions to match.
[smcmahon]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
${contenttype_classname} Tests
-----------------

This is a DocTest file, using the Python doctest format.


Create a ${contenttype_classname} object and put it in a folder

Create the object::

>>> from zope.component import createObject
>>> container = createObject('${contenttype_dottedname}')

Verify it's type::

>>> container.portal_type
'${contenttype_dottedname}'

Give it a title::

>>> container.setTitle('Test Title')
>>> container.Title()
'Test Title'

Put it in our base folder::

>>> from plone.dexterity.utils import addContentToContainer
>>> cobj = addContentToContainer(folder, container)

>>> cobj
<${contenttype_classname} at /plone/Members/test_user_1_/test-title>

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

Now, let's demonstrate a failing test::

>>> 2 == 3 # Deliberately failing test; fix me!
True
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

\# Integration tests for ${contenttype_classname}
ztc.ZopeDocFileSuite(
'${contenttype_classname}.txt',
package='${namespace_package}.${package}',
optionflags = OPTION_FLAGS,
test_class=TestCase),

Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,30 @@ In an integration test, here's some of the globals you have to work with::

>>> portal
<PloneSite at /plone>

>>> portal_name
'plone'

>>> folder
<ATFolder at /plone/Members/test_user_1_>

>>> user_name
'test_user_1_'

>>> user_password
'secret'

>>> user_role
'test_role_1_'

>>> app.REQUEST
<HTTPRequest, URL=http://nohost>

>>> app
<Application at >

Now, let's demonstrate a failing test::

>>> 1 == 2
>>> 1 == 2 # deliberately failing test; fix me!
True

Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,12 @@ def test_suite():

\# Integration tests that use PloneTestCase
ztc.ZopeDocFileSuite(
'INTEGRATION.txt',
'INTEGRATION.txt',
package='${namespace_package}.${package}',
optionflags = OPTION_FLAGS,
test_class=TestCase),

\#ztc.FunctionalDocFileSuite(
\# 'BROWSER.TXT',
\# package='${namespace_package}.${package}',
\# optionflags = OPTION_FLAGS,
\# test_class=TestCase),
# -*- extra stuff goes here -*-

])

Expand Down

0 comments on commit 13bb277

Please sign in to comment.