[Product-Developers] Problem with roles and plone.app.testing

Noe Nieto nnieto at noenieto.com
Tue May 31 19:45:26 UTC 2011


2011/5/31 Martin Aspeli <optilude at gmail.com>

>
>
> On 31 May 2011, at 18:09, Noe Nieto <nnieto at noenieto.com> wrote:
>
> On one of my tests I'm trying to create some folders.  This is the layer
> class:
>
> # ... adequate python imports
>
> class CatalogosFixture(PloneSandboxLayer):
>     defaultBases = (PLONE_FIXTURE,)
>
>     def setUpZope(self, app, configurationContext):
>         # Load ZCML for product dependencies
>         .....
>
>     def setUpPloneSite(self, portal):
>         #Install products and dependencies
>         self.applyProfile(portal, 'plone.app.dexterity:default')
>         self.applyProfile(portal,'holokinesislibros.contenttypes:default')
>         self.applyProfile(portal,'holokinesislibros.catalogos:default')
>
>         #Create a layout for testing
>         from plone.app.testing import setRoles
>         from plone.app.testing import TEST_USER_NAME
>         setRoles(portal, TEST_USER_NAME, ['Manager'])
>
>
>
> Use TEST_USER_ID. See docs for more.
>
>
>
The docs in
http://pypi.python.org/pypi/plone.app.testing/1.0a1#permissions-and-rolesadviced
me to use TEST_USER_NAME. Now I understand why I should use
TEST_USER_ID.

It works now. Thanks.




>         portal.invokeFactory('Folder', 'catalogo-general', title=u'Catalogo
> General')
>         portal.invokeFactory('Folder', 'libros', title=u'Libros')
>         portal.invokeFactory('Folder', 'videos', title=u'Videos')
>         portal.invokeFactory('Folder', 'audios', title=u'Audios')
>
>     def tearDownZope(self, app):
>         ...
>
> While running one DocTest with this fixture I get this traceback:
>
> Running holokinesislibros.catalogos.tests.CatalogosFixture:Functional
> tests:
>   Set up plone.testing.zca.LayerCleanup in 0.001 seconds.
>   Set up plone.testing.z2.Startup in 1.218 seconds.
>   Set up plone.app.testing.layers.PloneFixture in 27.080 seconds.
>   Set up holokinesislibros.catalogos.tests.CatalogosFixture Traceback (most
> recent call last):
>   File
> "/home/tzicatl/Aplicaciones/Buildout/egss/zope.testing-3.9.4-py2.6.egg/zope/testing/testrunner/runner.py",
> line 367, in run_layer
>     setup_layer(options, layer, setup_layers)
>   File
> "/home/tzicatl/Aplicaciones/Buildout/egss/zope.testing-3.9.4-py2.6.egg/zope/testing/testrunner/runner.py",
> line 627, in setup_layer
>     setup_layer(options, base, setup_layers)
>   File
> "/home/tzicatl/Aplicaciones/Buildout/egss/zope.testing-3.9.4-py2.6.egg/zope/testing/testrunner/runner.py",
> line 632, in setup_layer
>     layer.setUp()
>   File
> "/home/tzicatl/Aplicaciones/Buildout/egss/plone.app.testing-4.0-py2.6.egg/plone/app/testing/helpers.py",
> line 342, in setUp
>     setSite(None)
>   File "/home/tzicatl/Aplicaciones/Python2.6/lib/python2.6/contextlib.py",
> line 34, in __exit__
>     self.gen.throw(type, value, traceback)
>   File
> "/home/tzicatl/Aplicaciones/Buildout/egss/plone.app.testing-4.0-py2.6.egg/plone/app/testing/helpers.py",
> line 232, in ploneSite
>     yield portal
>   File
> "/home/tzicatl/Aplicaciones/Buildout/egss/plone.app.testing-4.0-py2.6.egg/plone/app/testing/helpers.py",
> line 341, in setUp
>     self.setUpPloneSite(portal)
>   File
> "/home/tzicatl/Documentos/Codigo/pu/holokinesis_libros/src/holokinesislibros.catalogos/holokinesislibros/catalogos/tests.py",
> line 38, in setUpPloneSite
>     setRoles(portal, TEST_USER_NAME, ['Manager'])
>   File
> "/home/tzicatl/Aplicaciones/Buildout/egss/plone.app.testing-4.0-py2.6.egg/plone/app/testing/helpers.py",
> line 39, in setRoles
>     z2.setRoles(userFolder, userId, roles)
>   File
> "/home/tzicatl/Aplicaciones/Buildout/egss/plone.testing-4.0.1-py2.6.egg/plone/testing/z2.py",
> line 183, in setRoles
>     userName = userFolder.getUserById(userId).getUserName()
> AttributeError: 'NoneType' object has no attribute 'getUserName'
>
> I'm stuck here, What am I doing wrong?
>
> --
> ---
> Noe Nieto
> NNieto Consulting Services
> M: <nnieto at noenieto.com>nnieto at noenieto.com
> W: <http://noenieto.com>http://noenieto.com
> T:  @tzicatl <https://twitter.com/#%21/tzicatl>
> Li: Perfil en LinkedIn <http://www.linkedin.com/profile/view?id=84300665>
>
>  _______________________________________________
> Product-Developers mailing list
> Product-Developers at lists.plone.org
> https://lists.plone.org/mailman/listinfo/plone-product-developers
>
>


-- 
---
Noe Nieto
NNieto Consulting Services
M: nnieto at noenieto.com
W: http://noenieto.com
T:  @tzicatl <https://twitter.com/#%21/tzicatl>
Li: Perfil en LinkedIn <http://www.linkedin.com/profile/view?id=84300665>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.plone.org/pipermail/plone-product-developers/attachments/20110531/85fe1779/attachment.html>


More information about the Product-Developers mailing list