source: trunk/tests/testPiece.py @ 1930

Revision 1930, 2.3 KB checked in by jukka, 12 years ago (diff)

Fixed tests and other stuff, fixed #1376, closed #1420.

  • Property svn:eol-style set to native
RevLine 
[236]1# Copyright 2006 by the LeMill Team (see AUTHORS)
[4]2#
[236]3# This file is part of LeMill.
[99]4#
[236]5# LeMill is free software; you can redistribute it and/or modify
[99]6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
[236]10# LeMill is distributed in the hope that it will be useful,
[99]11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
[236]16# along with LeMill; if not, write to the Free Software
[99]17# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
19#
[4]20# Test case for Asset content
21#
22
[20]23import os, sys, re
[4]24if __name__ == '__main__':
25    execfile(os.path.join(sys.path[0], 'framework.py'))
26
27from Testing import ZopeTestCase
[20]28from Testing.ZopeTestCase.functional import Functional
[236]29from LeMillTestCase import LeMillTestCase
[415]30from Products.LeMill.Piece import Piece
[20]31from Products.Archetypes.public import PrimaryFieldMarshaller
[68]32from StringIO import StringIO
33from urllib import urlencode
34from Products.PloneTestCase.setup import portal_owner, default_password
35from mimify import mimify
[4]36
[68]37auth=':'.join((portal_owner, default_password))
[4]38
[236]39class TestPiece(LeMillTestCase,Functional):
[4]40
41    def afterSetUp(self):
[241]42        self.loginAsPortalOwner()
[4]43
44    def testExistence(self):
[68]45        ob = self.construct('Piece','TestPiece',self.folder)
46        self.failUnlessEqual(ob._getPortalTypeName(),'Piece')
47        self.failUnlessEqual(ob.portal_type,'Piece')   
[20]48
49    def testCompatibilityFileAccess(self):
50        # Use an actual file, because if Python Imaging Library is installed, it
51        # will complain when non-files are used as image data.
[68]52        ob=self.construct('Piece', 'TestPiece7' ,self.folder)
[290]53        file_text = open("../skins/lemill/logo_main.png","r").read()
[68]54        ob.edit(file=file_text, source=file_text)
55        self.failUnlessEqual(ob.file.data, file_text, "File upload error")
56        self.failUnlessEqual(ob.source.data, file_text, "Source upload error")
[20]57
[4]58def test_suite():
59    from unittest import TestSuite, makeSuite
60    suite = TestSuite()
[68]61    suite.addTest(makeSuite(TestPiece))
[4]62    return suite
63
64if __name__ == '__main__':
65    framework()
Note: See TracBrowser for help on using the repository browser.