[Zope3-checkins] CVS: Zope3/src/zope/app/content/tests - test_file.py:1.4 test_image.py:1.6
Steve Alexander
steve@cat-box.net
Mon, 14 Apr 2003 13:15:51 -0400
Update of /cvs-repository/Zope3/src/zope/app/content/tests
In directory cvs.zope.org:/tmp/cvs-serv19670/src/zope/app/content/tests
Modified Files:
test_file.py test_image.py
Log Message:
Made file and image implementations confirm to their schema.
The data field should never be None, as it must conform to a required
Bytes field.
See http://collector.zope.org/Zope3-dev/140
=== Zope3/src/zope/app/content/tests/test_file.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/content/tests/test_file.py:1.3 Mon Feb 3 10:08:34 2003
+++ Zope3/src/zope/app/content/tests/test_file.py Mon Apr 14 13:15:20 2003
@@ -22,7 +22,6 @@
from zope.app.content.file import FileChunk, FileReadFile, FileWriteFile
class TestFileAdapters:
-
def test_ReadFile(self):
file = self._makeFile()
@@ -42,37 +41,28 @@
def _makeFile(self, *args, **kw):
""" """
from zope.app.content.file import File
-
return File(*args, **kw)
-
def testEmpty(self):
-
file = self._makeFile()
self.assertEqual(file.getContentType(), '')
self.assertEqual(file.getData(), '')
-
def testConstructor(self):
-
file = self._makeFile('Foobar')
self.assertEqual(file.getContentType(), '')
self.assertEqual(file.getData(), 'Foobar')
-
file = self._makeFile('Foobar', 'text/plain')
self.assertEqual(file.getContentType(), 'text/plain')
self.assertEqual(file.getData(), 'Foobar')
-
file = self._makeFile(data='Foobar', contentType='text/plain')
self.assertEqual(file.getContentType(), 'text/plain')
self.assertEqual(file.getData(), 'Foobar')
-
def testMutators(self):
-
file = self._makeFile()
file.setContentType('text/plain')
@@ -85,9 +75,7 @@
self.assertEqual(file.getContentType(), 'text/html')
self.assertEqual(file.getData(), 'Blah')
-
def testLargeDataInput(self):
-
file = self._makeFile()
# Insert as string
@@ -110,14 +98,15 @@
self.assertEqual(file.getSize(), 6*100000)
self.assertEqual(file.getData(), 'Foobar'*100000)
+ def testNoneDataInput(self):
+ file = self._makeFile()
+ self.assertRaises(TypeError, file.setData, None)
def testInterface(self):
-
from zope.app.content.file import File, IFile
self.failUnless(IFile.isImplementedByInstancesOf(File))
self.failUnless(verifyClass(IFile, File))
-
def testEdit(self):
file = self._makeFile()
=== Zope3/src/zope/app/content/tests/test_image.py 1.5 => 1.6 ===
--- Zope3/src/zope/app/content/tests/test_image.py:1.5 Mon Feb 3 10:08:34 2003
+++ Zope3/src/zope/app/content/tests/test_image.py Mon Apr 14 13:15:20 2003
@@ -47,11 +47,10 @@
def _makeImage(self, *args, **kw):
return Image(*args, **kw)
-
def testEmpty(self):
file = self._makeImage()
self.assertEqual(file.getContentType(), '')
- self.assertEqual(file.getData(), None)
+ self.assertEqual(file.getData(), '')
def testConstructor(self):
file = self._makeImage('Data')
@@ -85,7 +84,7 @@
def _makeFile(self, *args, **kw):
return Image(*args, **kw)
-
+
class DummyImage: