This repository has been archived by the owner on Apr 9, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
274 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<configure | ||
xmlns="http://namespaces.zope.org/zope" | ||
xmlns:grok="http://namespaces.zope.org/grok" | ||
xmlns:browser="http://namespaces.zope.org/browser" | ||
xmlns:genericsetup="http://namespaces.zope.org/genericsetup" | ||
xmlns:plone="http://namespaces.plone.org/plone" | ||
i18n_domain="plone"> | ||
|
||
<!-- Include our dependencies --> | ||
<includeDependencies package="." /> | ||
|
||
<!-- Grok the package to initialise schema interfaces and content classes --> | ||
<grok:grok package="." /> | ||
|
||
<!-- Register an extension profile to make the product installable --> | ||
<genericsetup:registerProfile | ||
name="default" | ||
title="Text tile" | ||
description="A text tile which can be used by Deco and Blocks" | ||
directory="profiles/default" | ||
provides="Products.GenericSetup.interfaces.EXTENSION" | ||
/> | ||
|
||
<plone:tile | ||
name="plone.app.texttiles.text" | ||
title="Text tile" | ||
description="A tile which adds text" | ||
add_permission="zope.Public" | ||
class=".text.TextTile" | ||
for="*" | ||
permission="zope2.View" | ||
/> | ||
|
||
</configure> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import doctest | ||
from plone.testing import layered | ||
import unittest2 as unittest | ||
from base import PASTANDARDTILES_FUNCTIONAL_TESTING, \ | ||
PASTANDARDTILES_TESTTYPE_FUNCTIONAL_TESTING | ||
import pprint | ||
import interlude | ||
|
||
optionflags = (doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE) | ||
normal_testfiles = [ | ||
'../text.txt', | ||
] | ||
|
||
|
||
def test_suite(): | ||
suite = unittest.TestSuite() | ||
suite.addTests([ | ||
layered(doctest.DocFileSuite(test, | ||
optionflags=optionflags, | ||
globs={'interact': interlude.interact, | ||
'pprint': pprint.pprint, | ||
}, | ||
), | ||
layer=PASTANDARDTILES_FUNCTIONAL_TESTING) | ||
for test in normal_testfiles]) | ||
suite.addTests([ | ||
layered(doctest.DocFileSuite(test, | ||
optionflags=optionflags, | ||
globs={'interact': interlude.interact, | ||
'pprint': pprint.pprint, | ||
}, | ||
), | ||
layer=PASTANDARDTILES_TESTTYPE_FUNCTIONAL_TESTING) | ||
for test in testtype_testfiles]) | ||
return suite |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
from plone.app.testing.layers import IntegrationTesting | ||
from plone.app.testing.layers import FunctionalTesting | ||
from plone.app.testing import PloneSandboxLayer | ||
from plone.app.testing import PLONE_FIXTURE | ||
from plone.app.testing import applyProfile | ||
from plone.app.testing import login | ||
from plone.app.testing import logout | ||
|
||
from zope.configuration import xmlconfig | ||
|
||
from zope.interface import implements, Interface | ||
from zope.component import adapts, provideAdapter, getSiteManager | ||
|
||
from zope.publisher.interfaces.browser import IBrowserView, IBrowserRequest | ||
from zope.contentprovider.interfaces import UpdateNotCalled | ||
|
||
from plone.portlets.interfaces import IPortletManager | ||
from plone.portlets.manager import PortletManager, PortletManagerRenderer | ||
|
||
from plone.dexterity.fti import DexterityFTI | ||
|
||
from Products.CMFCore.utils import getToolByName | ||
|
||
|
||
class IMockPortletManager(IPortletManager): | ||
"""Marker interface for the mock portlet manager.""" | ||
|
||
|
||
class MockPortletManager(PortletManager): | ||
"""Mock portlet manager to use in tests.""" | ||
|
||
implements(IMockPortletManager) | ||
|
||
|
||
class MockPortletManagerRenderer(PortletManagerRenderer): | ||
"""Mock portlet manager renderer to use in tests.""" | ||
|
||
adapts(Interface, IBrowserRequest, IBrowserView, IMockPortletManager) | ||
|
||
def __init__(self, context, request, view, manager): | ||
self.__updated = False | ||
|
||
def update(self): | ||
self.__updated = True | ||
|
||
def render(self): | ||
if not self.__updated: | ||
raise UpdateNotCalled | ||
return "Portlet Manager Renderer output." | ||
|
||
|
||
class PAStandardtiles(PloneSandboxLayer): | ||
defaultBases = (PLONE_FIXTURE,) | ||
|
||
def setUpZope(self, app, configurationContext): | ||
# load ZCML | ||
import plone.app.standardtiles | ||
xmlconfig.file('configure.zcml', plone.app.standardtiles, | ||
context=configurationContext) | ||
|
||
def setUpPloneSite(self, portal): | ||
# install into the Plone site | ||
applyProfile(portal, 'plone.app.registry:default') | ||
applyProfile(portal, 'plone.app.dexterity:default') | ||
applyProfile(portal, 'plone.app.intid:default') | ||
applyProfile(portal, 'plone.app.standardtiles:default') | ||
|
||
# register portlet manager and portlet manager renderer | ||
sm = getSiteManager(portal) | ||
sm.registerUtility(component=MockPortletManager(), | ||
provided=IMockPortletManager, | ||
name='mock.portletmanager') | ||
provideAdapter(MockPortletManagerRenderer) | ||
|
||
|
||
class PAStandardtilesTestType(PloneSandboxLayer): | ||
defaultBases = (PLONE_FIXTURE,) | ||
|
||
NORMAL_USER_NAME = 'user' | ||
NORMAL_USER_PASSWORD = 'secret' | ||
EDITOR_USER_NAME = 'editor' | ||
EDITOR_USER_PASSWORD = 'confidential' | ||
MANAGER_USER_NAME = 'manager' | ||
MANAGER_USER_PASSWORD = 'topsecret' | ||
|
||
def setUpZope(self, app, configurationContext): | ||
# load ZCML | ||
import plone.app.standardtiles | ||
xmlconfig.file('testing.zcml', plone.app.standardtiles, | ||
context=configurationContext) | ||
|
||
def setUpPloneSite(self, portal): | ||
# install into the Plone site | ||
applyProfile(portal, 'plone.app.registry:default') | ||
applyProfile(portal, 'plone.app.dexterity:default') | ||
applyProfile(portal, 'plone.app.intid:default') | ||
applyProfile(portal, 'plone.app.standardtiles:default') | ||
|
||
# Creates some users | ||
acl_users = getToolByName(portal, 'acl_users') | ||
acl_users.userFolderAddUser( | ||
self.NORMAL_USER_NAME, | ||
self.NORMAL_USER_PASSWORD, | ||
['Member'], | ||
[], | ||
) | ||
acl_users.userFolderAddUser( | ||
self.EDITOR_USER_NAME, | ||
self.EDITOR_USER_PASSWORD, | ||
['Editor'], | ||
[], | ||
) | ||
acl_users.userFolderAddUser( | ||
self.MANAGER_USER_NAME, | ||
self.MANAGER_USER_PASSWORD, | ||
['Manager'], | ||
[], | ||
) | ||
|
||
# Define the dexterity "junk" type | ||
fti = DexterityFTI('DecoTestType1') | ||
fti.schema = u'plone.app.standardtiles.testing.ITestType1' | ||
fti.behaviors = ('plone.app.dexterity.behaviors.metadata.IDublinCore',) | ||
portal.portal_types._setObject('DecoTestType1', fti) | ||
schema = fti.lookupSchema() | ||
|
||
# inserts the content of the types defined above | ||
login(portal, self.MANAGER_USER_NAME) | ||
content = portal[portal.invokeFactory('DecoTestType1', | ||
'deco-test-type1')] | ||
content.title = u"Test content" | ||
content.description = u"Just a test content" | ||
content.contributors = (u'Jane Doe', u'John Doe') | ||
logout() | ||
|
||
|
||
PASTANDARDTILES_FIXTURE = PAStandardtiles() | ||
PASTANDARDTILES_TESTTYPE_FIXTURE = PAStandardtilesTestType() | ||
|
||
PASTANDARDTILES_INTEGRATION_TESTING = IntegrationTesting( | ||
bases=(PASTANDARDTILES_FIXTURE,), name="PAStandardTiles:Integration") | ||
PASTANDARDTILES_FUNCTIONAL_TESTING = FunctionalTesting( | ||
bases=(PASTANDARDTILES_FIXTURE,), name="PAStandardTiles:Functional") | ||
PASTANDARDTILES_TESTTYPE_FUNCTIONAL_TESTING = FunctionalTesting( | ||
bases=(PASTANDARDTILES_TESTTYPE_FIXTURE,), | ||
name="PAStandardTilesTestType:Functional", | ||
) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
class TextTile(Tile): | ||
""" A text tile """ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
Content tiles | ||
============= | ||
|
||
Here we show up the main tiles used for the content usage. | ||
|
||
First, we set up a browser instance and get Manager privileges:: | ||
|
||
>>> from plone.testing.z2 import Browser | ||
>>> app = layer['app'] | ||
>>> browser = Browser(app) | ||
>>> browser.handleErrors = False | ||
>>> portal = layer['portal'] | ||
>>> portalURL = portal.absolute_url() | ||
|
||
>>> from plone.app.testing import setRoles | ||
>>> from plone.app.testing import TEST_USER_ID, TEST_USER_NAME, TEST_USER_PASSWORD | ||
>>> browser.addHeader('Authorization', 'Basic %s:%s' % (TEST_USER_NAME, TEST_USER_PASSWORD,)) | ||
>>> setRoles(portal, TEST_USER_ID, ['Manager']) | ||
|
||
>>> from plone.app.standardtiles.tests.base import EDITOR_USER_NAME, EDITOR_USER_PASSWORD, MANAGER_USER_NAME, MANAGER_USER_PASSWORD | ||
|
||
>>> import transaction | ||
>>> transaction.commit() # make the browser see this role | ||
|
||
We also keep another testbrowser handy for testing how tiles are rendered if | ||
you're not logged in:: | ||
|
||
>>> unprivileged_browser = Browser(app) | ||
|
||
We create a page in the site to use it in tests later:: | ||
|
||
>>> browser.open(portalURL + '/createObject?type_name=Document') | ||
>>> browser.getControl(name='title').value = 'A simple page' | ||
>>> browser.getControl(name='description').value = 'A description' | ||
>>> browser.getControl('Save').click() | ||
>>> pageURL = browser.url | ||
>>> pageURL | ||
'http://nohost/plone/a-simple-page' | ||
|
||
Text tile | ||
------------- | ||
|
||
The text tile displays a list of the keywords (aka subjects) | ||
assigned to the context. | ||
|
||
Add the tile:: | ||
|
||
>>> browser.open(pageURL + '/@@plone.app.texttile.text') | ||
>>> browser.getControl('Save').click() | ||
|
||
The tile will show them:: | ||
|
||
>>> unprivileged_browser.open(pageURL + '/@@plone.app.standardtiles.text') | ||
>>> unprivileged_browser.contents | ||
'...id="category"...Sprint...Statues...' |
1ef89d5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are registering a profile but without a profiles/default folder. Could you explain it please ? The addon is supposed to be installable but install nothing. You should add at least a metadata.xml.
1ef89d5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably a copy/paste error ... while we were breaking up p.a.standardtiles