Switch to plone.app.testing

This commit is contained in:
Daniel Widerin 2013-03-12 20:06:35 +01:00
parent fb8304c0aa
commit 5c720d3776
8 changed files with 74 additions and 23 deletions

View File

@ -33,7 +33,4 @@
provides="Products.GenericSetup.interfaces.EXTENSION"
/>
<!-- Demo -->
<!-- <include file="demo.zcml" /> -->
</configure>

View File

@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
from plone.app.testing import PLONE_FIXTURE
from plone.app.testing import TEST_USER_ID
from plone.app.testing import PloneSandboxLayer
from plone.app.testing import helpers
from plone.app.testing import layers
from plone.app.testing import login
from plone.app.testing import setRoles
from plone.testing import z2
from zope.configuration import xmlconfig
import doctest
class ContentTreeLayer(PloneSandboxLayer):
defaultBases = (PLONE_FIXTURE, )
def setUpZope(self, app, configurationContext):
import plone.formwidget.contenttree
xmlconfig.file('testing.zcml',
plone.formwidget.contenttree,
context=configurationContext)
def setUpPloneSite(self, portal):
helpers.applyProfile(portal, 'plone.formwidget.contenttree:default')
portal.acl_users.userFolderAddUser('admin', 'secret', ['Manager'], [])
login(portal, 'admin')
portal.portal_workflow.setDefaultChain("simple_publication_workflow")
setRoles(portal, TEST_USER_ID, ['Manager'])
portal.invokeFactory("Folder",
id="contenttree-test-folder",
title=u"A Test Folder")
CONTENTTREE_FIXTURE = ContentTreeLayer()
CONTENTTREE_INTEGRATION_TESTING = layers.IntegrationTesting(
bases=(CONTENTTREE_FIXTURE,),
name="plone.formwidget.contenttree:Integration")
CONTENTTREE_FUNCTIONAL_TESTING = layers.FunctionalTesting(
bases=(CONTENTTREE_FIXTURE, z2.ZSERVER_FIXTURE),
name="plone.formwidget.contenttree:Functional")
optionflags = (doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE)

View File

@ -9,4 +9,6 @@
<include package="plone.z3cform" file="testing.zcml" />
<include package="plone.formwidget.contenttree" file="configure.zcml" />
<include file="demo.zcml" />
</configure>

View File

@ -1,19 +0,0 @@
import os
import unittest
from zope.testing import doctest
from zope.app.testing.functional import ZCMLLayer
testing_zcml_path = os.path.join(os.path.dirname(__file__), 'testing.zcml')
testing_zcml_layer = ZCMLLayer(testing_zcml_path,
'plone.formwidget.contenttree',
'testing_zcml_layer')
def test_suite():
readme_txt = doctest.DocFileSuite('README.txt')
readme_txt.layer = testing_zcml_layer
return unittest.TestSuite([
readme_txt,
])

View File

@ -0,0 +1 @@
# -*- coding: utf-8 -*-

View File

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
from plone.formwidget.contenttree.testing import (
CONTENTTREE_INTEGRATION_TESTING,
)
from plone.testing import layered
import doctest
import unittest
def test_suite():
suite = unittest.TestSuite()
suite.addTests([
layered(doctest.DocFileSuite('../README.txt'),
CONTENTTREE_INTEGRATION_TESTING)
])
return suite

View File

@ -34,7 +34,7 @@ setup(name='plone.formwidget.contenttree',
],
extras_require={
'test': [
'zope.app.testing',
'plone.app.testing',
],
},
entry_points="""

View File

@ -14,6 +14,11 @@ parts +=
zopepy
[instance]
zcml-additional =
<include package="plone.formwidget.contenttree" file="demo.zcml" />
[test]
recipe = zc.recipe.testrunner
defaults = ['-s', '${buildout:package-name}', '--auto-color', '--auto-progress']