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
Line 
1# Copyright 2006 by the LeMill Team (see AUTHORS)
2#
3# This file is part of LeMill.
4#
5# LeMill is free software; you can redistribute it and/or modify
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#
10# LeMill is distributed in the hope that it will be useful,
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
16# along with LeMill; if not, write to the Free Software
17# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
19#
20# Test case for Asset content
21#
22
23import os, sys, re
24if __name__ == '__main__':
25    execfile(os.path.join(sys.path[0], 'framework.py'))
26
27from Testing import ZopeTestCase
28from Testing.ZopeTestCase.functional import Functional
29from LeMillTestCase import LeMillTestCase
30from Products.LeMill.Piece import Piece
31from Products.Archetypes.public import PrimaryFieldMarshaller
32from StringIO import StringIO
33from urllib import urlencode
34from Products.PloneTestCase.setup import portal_owner, default_password
35from mimify import mimify
36
37auth=':'.join((portal_owner, default_password))
38
39class TestPiece(LeMillTestCase,Functional):
40
41    def afterSetUp(self):
42        self.loginAsPortalOwner()
43
44    def testExistence(self):
45        ob = self.construct('Piece','TestPiece',self.folder)
46        self.failUnlessEqual(ob._getPortalTypeName(),'Piece')
47        self.failUnlessEqual(ob.portal_type,'Piece')   
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.
52        ob=self.construct('Piece', 'TestPiece7' ,self.folder)
53        file_text = open("../skins/lemill/logo_main.png","r").read()
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")
57
58def test_suite():
59    from unittest import TestSuite, makeSuite
60    suite = TestSuite()
61    suite.addTest(makeSuite(TestPiece))
62    return suite
63
64if __name__ == '__main__':
65    framework()
Note: See TracBrowser for help on using the repository browser.