[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Content/Image/Views/Browser/tests - __init__.py:1.1.2.1 testImageData.py:1.1.2.1 testImageEdit.py:1.1.2.1

Stephan Richter srichter@cbu.edu
Wed, 27 Mar 2002 10:54:40 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Content/Image/Views/Browser/tests
In directory cvs.zope.org:/tmp/cvs-serv12282/Content/Image/Views/Browser/tests

Added Files:
      Tag: Zope-3x-branch
	__init__.py testImageData.py testImageEdit.py 
Log Message:
New Content Objects:

- NaiveFile --> all the data is stored in one string
- File --> Uses a BTree to store the data in chunks (more efficient)
- Image --> Can store and display an image a la Z2 (based on File)
- ZPTPage --> A simple version of ZPT for the content space to allow some 
  dynamics data (please do not use this for scripting)

Also:

- Expansion of supported views
- all edit screens are Formulator supported



=== Added File Zope3/lib/python/Zope/App/OFS/Content/Image/Views/Browser/tests/__init__.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 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.
##############################################################################
"""

$Id: __init__.py,v 1.1.2.1 2002/03/27 15:54:39 srichter Exp $
"""


=== Added File Zope3/lib/python/Zope/App/OFS/Content/Image/Views/Browser/tests/testImageData.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 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.
##############################################################################
"""

$Id: testImageData.py,v 1.1.2.1 2002/03/27 15:54:39 srichter Exp $
"""

import unittest

from Zope.App.OFS.Image.Views.Browser.ImageData import ImageData
from Zope.App.OFS.Image.Image import Image


class Test( unittest.TestCase ):

    def testData(self):
        """ """
        image = Image('Data')

        id = ImageData(image) 

        self.assertEqual(id.index(), 'Data')


    def testTag(self):
        """ """

        # We need that, sinc eabsolute_url is not implemented yet.
        def absolute_url():
            return '/img'
            
        image = Image()        
        fe = ImageData(image)
        fe.absolute_url = absolute_url

        self.assertEqual(fe.tag(),
            '<img src="/img" alt="" height="-1" width="-1" border="0" />')
        self.assertEqual(fe.tag(alt="Test Image"),
            '<img src="/img" alt="Test Image" '
            'height="-1" width="-1" border="0" />')
        self.assertEqual(fe.tag(height=100, width=100),
            '<img src="/img" alt="" height="100" width="100" border="0" />')
        self.assertEqual(fe.tag(border=1),
            '<img src="/img" alt="" height="-1" width="-1" border="1" />')
        self.assertEqual(fe.tag(css_class="Image"),
            '<img src="/img" alt="" '
            'height="-1" width="-1" border="0" class="Image" />')
        self.assertEqual(fe.tag(height=100, width="100",
                         border=1, css_class="Image"),
            '<img src="/img" alt="" '
            'height="100" width="100" class="Image" border="1" />')


def test_suite():
    loader = unittest.TestLoader()
    return loader.loadTestsFromTestCase( Test )

if __name__=='__main__':
    unittest.main()


=== Added File Zope3/lib/python/Zope/App/OFS/Content/Image/Views/Browser/tests/testImageEdit.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 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.
##############################################################################
"""

$Id: testImageEdit.py,v 1.1.2.1 2002/03/27 15:54:39 srichter Exp $
"""

import unittest, cStringIO

from Zope.App.OFS.Image.Views.Browser.ImageEdit import ImageEdit
from Zope.App.OFS.Image.Image import Image


class Test( unittest.TestCase ):

    def testEdit(self):
        """ """
        file = Image()
        fe = ImageEdit(file) 

        file = cStringIO.StringIO()
        file.write('Data')
        file.seek(0)

        # XXX How can I create a REQUEST object?
        #fe.action({'field_data': file, 'field_contentType': '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()