[Checkins] SVN: zope.app.container/trunk/ Reactivate some
functional tests.
Stephan Richter
srichter at cosmos.phy.tufts.edu
Thu Nov 1 17:08:38 EDT 2007
Log message for revision 81387:
Reactivate some functional tests.
Changed:
U zope.app.container/trunk/CHANGES.txt
U zope.app.container/trunk/setup.py
D zope.app.container/trunk/src/zope/app/container/browser/ftests/
A zope.app.container/trunk/src/zope/app/container/browser/tests/configure.zcml
A zope.app.container/trunk/src/zope/app/container/browser/tests/index.txt
A zope.app.container/trunk/src/zope/app/container/browser/tests/test_contents_functional.py
U zope.app.container/trunk/src/zope/app/container/ftesting.zcml
-=-
Modified: zope.app.container/trunk/CHANGES.txt
===================================================================
--- zope.app.container/trunk/CHANGES.txt 2007-11-01 21:03:01 UTC (rev 81386)
+++ zope.app.container/trunk/CHANGES.txt 2007-11-01 21:08:37 UTC (rev 81387)
@@ -2,6 +2,11 @@
CHANGES
=======
+3.5.2 (2007-11-01)
+------------------
+
+- Reactivated functional tests.
+
3.5.1 (2007-10-31)
------------------
Modified: zope.app.container/trunk/setup.py
===================================================================
--- zope.app.container/trunk/setup.py 2007-11-01 21:03:01 UTC (rev 81386)
+++ zope.app.container/trunk/setup.py 2007-11-01 21:08:37 UTC (rev 81387)
@@ -22,7 +22,7 @@
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
setup(name='zope.app.container',
- version = '3.6.0',
+ version = '3.5.2',
author='Zope Corporation and Contributors',
author_email='zope3-dev at zope.org',
description='Zope Container',
Copied: zope.app.container/trunk/src/zope/app/container/browser/tests/configure.zcml (from rev 81370, zope.app.container/trunk/src/zope/app/container/browser/ftests/configure.zcml)
===================================================================
--- zope.app.container/trunk/src/zope/app/container/browser/tests/configure.zcml (rev 0)
+++ zope.app.container/trunk/src/zope/app/container/browser/tests/configure.zcml 2007-11-01 21:08:37 UTC (rev 81387)
@@ -0,0 +1,16 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:browser="http://namespaces.zope.org/browser">
+
+ <class class=".test_contents_functional.ReadOnlyContainer">
+ <require
+ permission="zope.ManageContent"
+ interface="zope.app.container.interfaces.IReadContainer"
+ />
+ </class>
+
+ <browser:containerViews
+ for="zope.app.container.interfaces.IReadContainer"
+ contents="zope.ManageContent" />
+
+</configure>
Copied: zope.app.container/trunk/src/zope/app/container/browser/tests/index.txt (from rev 81370, zope.app.container/trunk/src/zope/app/container/browser/ftests/index.txt)
===================================================================
--- zope.app.container/trunk/src/zope/app/container/browser/tests/index.txt (rev 0)
+++ zope.app.container/trunk/src/zope/app/container/browser/tests/index.txt 2007-11-01 21:08:37 UTC (rev 81387)
@@ -0,0 +1,18 @@
+The containerViews directive lets us associate some standard forms
+for containers with an interface. There's an "index.html" view that
+provides a listing of the contained objects without provinding any way
+to manage them (though it allows us to visit them by clicking on
+links).
+
+We can get this view from the root folder easily::
+
+ >>> response = http(r"""
+ ... GET / HTTP/1.1
+ ... """)
+
+And we can check that there isn't a form (where the management
+operations would have buttons)::
+
+ >>> body = response.getBody().lower()
+ >>> "<form" in body
+ False
Copied: zope.app.container/trunk/src/zope/app/container/browser/tests/test_contents_functional.py (from rev 81370, zope.app.container/trunk/src/zope/app/container/browser/ftests/test_contents.py)
===================================================================
--- zope.app.container/trunk/src/zope/app/container/browser/tests/test_contents_functional.py (rev 0)
+++ zope.app.container/trunk/src/zope/app/container/browser/tests/test_contents_functional.py 2007-11-01 21:08:37 UTC (rev 81387)
@@ -0,0 +1,351 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Functional tests for the Container's 'Contents' view
+
+$Id$
+"""
+
+import unittest
+
+from persistent import Persistent
+import transaction
+from zope import copypastemove
+from zope.interface import implements, Interface
+from zope.annotation.interfaces import IAttributeAnnotatable
+from zope.dublincore.interfaces import IZopeDublinCore
+
+from zope.app.container.interfaces import IReadContainer, IContained
+from zope.app.testing import ztapi
+from zope.app.testing.functional import BrowserTestCase
+from zope.app.testing.functional import FunctionalDocFileSuite
+from zope.app.container.testing import AppContainerLayer
+
+
+class IImmovable(Interface):
+ """Marker interface for immovable objects."""
+
+class IUncopyable(Interface):
+ """Marker interface for uncopyable objects."""
+
+class File(Persistent):
+ implements(IAttributeAnnotatable)
+
+class ImmovableFile(File):
+ implements(IImmovable)
+
+class UncopyableFile(File):
+ implements(IUncopyable)
+
+class ObjectNonCopier(copypastemove.ObjectCopier):
+
+ def copyable(self):
+ return False
+
+class ObjectNonMover(copypastemove.ObjectMover):
+
+ def moveable(self):
+ return False
+
+class ReadOnlyContainer(Persistent):
+ implements(IReadContainer, IContained)
+ __parent__ = __name__ = None
+
+ def __init__(self): self.data = {}
+ def keys(self): return self.data.keys()
+ def __getitem__(self, key): return self.data[key]
+ def get(self, key, default=None): return self.data.get(key, default)
+ def __iter__(self): return iter(self.data)
+ def values(self): return self.data.values()
+ def __len__(self): return len(self.data)
+ def items(self): return self.data.items()
+ def __contains__(self, key): return key in self.data
+ def has_key(self, key): return self.data.has_key(key)
+
+
+class Test(BrowserTestCase):
+
+ def test_inplace_add(self):
+ root = self.getRootFolder()
+ self.assert_('foo' not in root)
+ response = self.publish('/@@contents.html',
+ basic='mgr:mgrpw',
+ form={'type_name': u'zope.app.content.File'})
+ body = ' '.join(response.getBody().split())
+ self.assert_(body.find('type="hidden" name="type_name"') >= 0)
+ self.assert_(body.find('input name="new_value"') >= 0)
+ self.assert_(body.find('type="submit" name="container_cancel_button"')
+ >= 0)
+ self.assert_(body.find('type="submit" name="container_rename_button"')
+ < 0)
+
+ response = self.publish('/@@contents.html',
+ basic='mgr:mgrpw',
+ form={'type_name': u'zope.app.content.File',
+ 'new_value': 'foo'})
+ self.assertEqual(response.getStatus(), 302)
+ self.assertEqual(response.getHeader('Location'),
+ 'http://localhost/@@contents.html')
+
+ root._p_jar.sync()
+ self.assert_('foo' in root)
+
+ def test_inplace_rename_multiple(self):
+ root = self.getRootFolder()
+ root['foo'] = File()
+ self.assert_('foo' in root)
+ transaction.commit()
+
+ # Check that we don't change mode if there are no items selected
+
+ response = self.publish('/@@contents.html',
+ basic='mgr:mgrpw',
+ form={'container_rename_button': u''})
+ body = ' '.join(response.getBody().split())
+ self.assert_(body.find('input name="new_value:list"') < 0)
+ self.assert_(body.find('type="submit" name="container_cancel_button"')
+ < 0)
+ self.assert_(body.find('type="submit" name="container_rename_button"')
+ >= 0)
+ self.assert_(body.find('div class="page_error"')
+ >= 0)
+
+
+ # Check normal multiple select
+
+
+ response = self.publish('/@@contents.html',
+ basic='mgr:mgrpw',
+ form={'container_rename_button': u'',
+ 'ids': ['foo']})
+ body = ' '.join(response.getBody().split())
+ self.assert_(body.find('input name="new_value:list"') >= 0)
+ self.assert_(body.find('type="submit" name="container_cancel_button"')
+ >= 0)
+ self.assert_(body.find('type="submit" name="container_rename_button"')
+ < 0)
+
+ response = self.publish('/@@contents.html',
+ basic='mgr:mgrpw',
+ form={'rename_ids': ['foo'],
+ 'new_value': ['bar']})
+ self.assertEqual(response.getStatus(), 302)
+ self.assertEqual(response.getHeader('Location'),
+ 'http://localhost/@@contents.html')
+
+ root._p_jar.sync()
+ self.assert_('foo' not in root)
+ self.assert_('bar' in root)
+
+
+ def test_inplace_rename_single(self):
+ root = self.getRootFolder()
+ root['foo'] = File()
+ self.assert_('foo' in root)
+ transaction.commit()
+
+ response = self.publish('/@@contents.html',
+ basic='mgr:mgrpw',
+ form={'rename_ids': ['foo']})
+ body = ' '.join(response.getBody().split())
+ self.assert_(body.find('input name="new_value:list"') >= 0)
+ self.assert_(body.find('type="submit" name="container_cancel_button"')
+ >= 0)
+ self.assert_(body.find('type="submit" name="container_rename_button"')
+ < 0)
+
+ response = self.publish('/@@contents.html',
+ basic='mgr:mgrpw',
+ form={'rename_ids': ['foo'],
+ 'new_value': ['bar']})
+ self.assertEqual(response.getStatus(), 302)
+ self.assertEqual(response.getHeader('Location'),
+ 'http://localhost/@@contents.html')
+
+ root._p_jar.sync()
+ self.assert_('foo' not in root)
+ self.assert_('bar' in root)
+
+ def test_inplace_change_title(self):
+ root = self.getRootFolder()
+ root['foo'] = File()
+ transaction.commit()
+ self.assert_('foo' in root)
+ dc = IZopeDublinCore(root['foo'])
+ self.assert_(dc.title == '')
+
+ response = self.publish('/@@contents.html',
+ basic='mgr:mgrpw',
+ form={'retitle_id': u'foo'})
+ body = ' '.join(response.getBody().split())
+ self.assert_(body.find('type="hidden" name="retitle_id"') >= 0)
+ self.assert_(body.find('input name="new_value"') >= 0)
+ self.assert_(body.find('type="submit" name="container_cancel_button"')
+ >= 0)
+ self.assert_(body.find('type="submit" name="container_rename_button"')
+ < 0)
+
+ response = self.publish('/@@contents.html',
+ basic='mgr:mgrpw',
+ form={'retitle_id': u'foo',
+ 'new_value': u'test title'})
+ self.assertEqual(response.getStatus(), 302)
+ self.assertEqual(response.getHeader('Location'),
+ 'http://localhost/@@contents.html')
+
+ root._p_jar.sync()
+ self.assert_('foo' in root)
+ dc = IZopeDublinCore(root['foo'])
+ self.assert_(dc.title == 'test title')
+
+
+ def test_pasteable_for_deleted_clipboard_item(self):
+ """Tests Paste button visibility when copied item is deleted."""
+
+ root = self.getRootFolder()
+ root['foo'] = File() # item to be copied/deleted
+ root['bar'] = File() # ensures that there's always an item in
+ # the collection view
+ transaction.commit()
+
+ # confirm foo in contents, Copy button visible, Paste not visible
+ response = self.publish('/@@contents.html', basic='mgr:mgrpw')
+ self.assertEqual(response.getStatus(), 200)
+ self.assert_(response.getBody().find(
+ '<a href="foo/@@SelectedManagementView.html">foo</a>') != -1)
+ self.assert_(response.getBody().find(
+ '<input type="submit" name="container_copy_button"') != -1)
+ self.assert_(response.getBody().find(
+ '<input type="submit" name="container_paste_button"') == -1)
+
+ # copy foo - confirm Paste visible
+ response = self.publish('/@@contents.html', basic='mgr:mgrpw', form={
+ 'ids' : ('foo',),
+ 'container_copy_button' : '' })
+ self.assertEqual(response.getStatus(), 302)
+ self.assertEqual(response.getHeader('Location'),
+ 'http://localhost/@@contents.html')
+ response = self.publish('/@@contents.html', basic='mgr:mgrpw')
+ self.assertEqual(response.getStatus(), 200)
+ self.assert_(response.getBody().find(
+ '<input type="submit" name="container_paste_button"') != -1)
+
+ # delete foo -> nothing valid to paste -> Paste should not be visible
+ del root['foo']
+ transaction.commit()
+ response = self.publish('/@@contents.html', basic='mgr:mgrpw')
+ self.assertEqual(response.getStatus(), 200)
+ self.assert_(response.getBody().find(
+ '<input type="submit" name="container_paste_button"') == -1)
+
+
+ def test_paste_for_deleted_clipboard_item(self):
+ """Tests paste operation when one of two copied items is deleted."""
+
+ root = self.getRootFolder()
+ root['foo'] = File()
+ root['bar'] = File()
+ transaction.commit()
+
+ # confirm foo/bar in contents, Copy button visible, Paste not visible
+ response = self.publish('/@@contents.html', basic='mgr:mgrpw')
+ self.assertEqual(response.getStatus(), 200)
+ self.assert_(response.getBody().find(
+ '<a href="foo/@@SelectedManagementView.html">foo</a>') != -1)
+ self.assert_(response.getBody().find(
+ '<a href="bar/@@SelectedManagementView.html">bar</a>') != -1)
+ self.assert_(response.getBody().find(
+ '<input type="submit" name="container_copy_button"') != -1)
+ self.assert_(response.getBody().find(
+ '<input type="submit" name="container_paste_button"') == -1)
+
+ # copy foo and bar - confirm Paste visible
+ response = self.publish('/@@contents.html', basic='mgr:mgrpw', form={
+ 'ids' : ('foo', 'bar'),
+ 'container_copy_button' : '' })
+ self.assertEqual(response.getStatus(), 302)
+ self.assertEqual(response.getHeader('Location'),
+ 'http://localhost/@@contents.html')
+ response = self.publish('/@@contents.html', basic='mgr:mgrpw')
+ self.assertEqual(response.getStatus(), 200)
+ self.assert_(response.getBody().find(
+ '<input type="submit" name="container_paste_button"') != -1)
+
+ # delete only foo -> bar still available -> Paste should be visible
+ del root['foo']
+ transaction.commit()
+ response = self.publish('/@@contents.html', basic='mgr:mgrpw')
+ self.assertEqual(response.getStatus(), 200)
+ self.assert_(response.getBody().find(
+ '<input type="submit" name="container_paste_button"') != -1)
+
+ # paste clipboard contents - only bar should be copied
+ response = self.publish('/@@contents.html', basic='mgr:mgrpw', form={
+ 'container_paste_button' : '' })
+ self.assertEqual(response.getStatus(), 302)
+ self.assertEqual(response.getHeader('Location'),
+ 'http://localhost/@@contents.html')
+ response = self.publish('/@@contents.html', basic='mgr:mgrpw')
+ self.assertEqual(response.getStatus(), 200)
+ root._p_jar.sync()
+ self.assertEqual(tuple(root.keys()), ('bar', 'bar-2'))
+
+ def test_readonly_display(self):
+ root = self.getRootFolder()
+ root['foo'] = ReadOnlyContainer()
+ transaction.commit()
+ response = self.publish('/foo/@@contents.html', basic='mgr:mgrpw')
+ self.assertEqual(response.getStatus(), 200)
+
+ def test_uncopyable_object(self):
+ ztapi.provideAdapter(IUncopyable,
+ copypastemove.interfaces.IObjectCopier,
+ ObjectNonCopier)
+ root = self.getRootFolder()
+ root['uncopyable'] = UncopyableFile()
+ transaction.commit()
+ response = self.publish('/@@contents.html',
+ basic='mgr:mgrpw',
+ form={'ids': [u'uncopyable'],
+ 'container_copy_button': u'Copy'})
+ self.assertEqual(response.getStatus(), 200)
+ body = response.getBody()
+ self.assert_("cannot be copied" in body)
+
+ def test_unmoveable_object(self):
+ ztapi.provideAdapter(IImmovable,
+ copypastemove.interfaces.IObjectMover,
+ ObjectNonMover)
+ root = self.getRootFolder()
+ root['immovable'] = ImmovableFile()
+ transaction.commit()
+ response = self.publish('/@@contents.html',
+ basic='mgr:mgrpw',
+ form={'ids': [u'immovable'],
+ 'container_cut_button': u'Cut'})
+ self.assertEqual(response.getStatus(), 200)
+ body = response.getBody()
+ self.assert_("cannot be moved" in body)
+
+
+def test_suite():
+ suite = unittest.TestSuite()
+ Test.layer = AppContainerLayer
+ suite.addTest(unittest.makeSuite(Test))
+ index = FunctionalDocFileSuite("index.txt")
+ index.layer = AppContainerLayer
+ suite.addTest(index)
+ return suite
+
+if __name__=='__main__':
+ unittest.main(defaultTest='test_suite')
Modified: zope.app.container/trunk/src/zope/app/container/ftesting.zcml
===================================================================
--- zope.app.container/trunk/src/zope/app/container/ftesting.zcml 2007-11-01 21:03:01 UTC (rev 81386)
+++ zope.app.container/trunk/src/zope/app/container/ftesting.zcml 2007-11-01 21:08:37 UTC (rev 81387)
@@ -8,7 +8,7 @@
<!-- used for functional testing setup -->
<include package="zope.app.zcmlfiles" />
- <include package="zope.app.container.browser.ftests" />
+ <include package="zope.app.container.browser.tests" />
<include package="zope.app.file"/>
<include package="zope.app.authentication" />
More information about the Checkins
mailing list