[Zope3-checkins] CVS: Zope3/src/zope/app/container/tests - test_objectmover.py:1.1.2.1
runyaga
runyaga@thisbox.com
Tue, 4 Feb 2003 10:42:20 -0500
Update of /cvs-repository/Zope3/src/zope/app/container/tests
In directory cvs.zope.org:/tmp/cvs-serv25758/container/tests
Added Files:
Tag: paris-copypasterename-branch
test_objectmover.py
Log Message:
putting this into cvs because my hands are cold
=== Added File Zope3/src/zope/app/container/tests/test_objectmover.py ===
##############################################################################
#
# 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.0 (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.
#
##############################################################################
""" exercise IObjectMover
"""
from unittest import TestCase, TestSuite, main, makeSuite
from zope.app.tests.placelesssetup import PlacelessSetup
from zope.component import getAdapter
from zope.component.adapter import provideAdapter
from zope.app.interfaces.copy import IObjectMover, IObjectCopier
from zope.app.interfaces.container import IPasteTarget
from zope.app.container.copy import PasteTarget
from zope.app.copy import ObjectMover, ObjectCopier
from zope.app.content.folder import Folder
from zope.app.content.file import File
class ObjectMoverTest(PlacelessSetup, TestCase):
def setUp(self):
PlacelessSetup.setUp(self)
provideAdapter(None, IObjectMover, ObjectMover)
provideAdapter(None, IPasteTarget, PasteTarget)
def test_moveto(self):
self._container=Folder()
self._container.setObject('file1', File())
file=self._container.get('file1')
mover=getAdapter(file, IObjectMover)
paster=getAdapter(self._container, IPasteTarget)
mover.moveTo(paster, 'file2')
assert 'file1' not in self._container
def test_moveable(self):
self._container=Folder()
self._container.setObject('file1', File())
mover=getAdapter(file, IObjectMover)
assert mover.moveable()
def test_moveableTo(self):
# A file should not be moveable in its same folder.
#
self._container=Folder()
self._container.setObject('file1', File())
mover=getAdapter(self._container.get('file1'), IObjectMover)
assert not mover.moveableTo(self._container)
def test_suite():
return TestSuite((
makeSuite(ObjectMoverTest),
))
if __name__=='__main__':
main(defaultTest='test_suite')