[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/File/tests - __init__.py:1.1.2.1 testNaiveFile.py:1.1.2.1 testNaiveFileEdit.py:1.1.2.1
Stephan Richter
srichter@cbu.edu
Sat, 19 Jan 2002 23:57:32 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/File/tests
In directory cvs.zope.org:/tmp/cvs-serv30501/File/tests
Added Files:
Tag: Zope-3x-branch
__init__.py testNaiveFile.py testNaiveFileEdit.py
Log Message:
- Restructuring the directory structure in Zope.App.OFS
- Added a simple Image support including two views
NOTE: The ImageData.tag() method does not work yet, since absolute_url is
not implemented yet.
=== Added File Zope3/lib/python/Zope/App/OFS/File/tests/__init__.py ===
=== Added File Zope3/lib/python/Zope/App/OFS/File/tests/testNaiveFile.py ===
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 1.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.
import unittest
from Interface import verify
class Test( unittest.TestCase ):
def _makeNaiveFile(self, *args, **kw):
""" """
from Zope.App.OFS.File.NaiveFile import NaiveFile
return NaiveFile(*args, **kw)
def testEmpty( self ):
file = self._makeNaiveFile()
self.assertEqual(file.getContentType(), '')
self.assertEqual(file.getData(), None)
def testConstructor(self):
file = self._makeNaiveFile('Foobar')
self.assertEqual(file.getContentType(), '')
self.assertEqual(file.getData(), 'Foobar')
file = self._makeNaiveFile('Foobar', 'text/plain')
self.assertEqual(file.getContentType(), 'text/plain')
self.assertEqual(file.getData(), 'Foobar')
file = self._makeNaiveFile(data='Foobar', contentType='text/plain')
self.assertEqual(file.getContentType(), 'text/plain')
self.assertEqual(file.getData(), 'Foobar')
def testMutators(self):
file = self._makeNaiveFile()
file.setContentType('text/plain')
self.assertEqual(file.getContentType(), 'text/plain')
file.setData('Foobar')
self.assertEqual(file.getData(), 'Foobar')
file.edit('Blah', 'text/html')
self.assertEqual(file.getContentType(), 'text/html')
self.assertEqual(file.getData(), 'Blah')
def testInterface(self):
from Zope.App.OFS.File.NaiveFile import NaiveFile, INaiveFile
self.failUnless(INaiveFile.isImplementedByInstancesOf(NaiveFile))
self.failUnless(verify(INaiveFile, NaiveFile))
def test_suite():
loader = unittest.TestLoader()
return loader.loadTestsFromTestCase( Test )
if __name__=='__main__':
unittest.TextTestRunner().run( test_suite() )
=== Added File Zope3/lib/python/Zope/App/OFS/File/tests/testNaiveFileEdit.py ===
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 1.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.
import unittest
from Zope.App.OFS.File.NaiveFileEdit import NaiveFileEdit
from Zope.App.OFS.File.NaiveFile import NaiveFile
class Test( unittest.TestCase ):
def testEdit(self):
""" """
file = NaiveFile()
fe = NaiveFileEdit(file)
fe.edit('Data', 'text/plain')
self.assertEqual(fe.getContext().getContentType(), 'text/plain')
self.assertEqual(fe.getContext().getData(), 'Data')
def test_suite():
loader = unittest.TestLoader()
return loader.loadTestsFromTestCase( Test )
if __name__=='__main__':
unittest.main()