source: trunk/tests/testPiece.py @ 1624

Revision 1624, 2.7 KB checked in by szabolcs, 12 years ago (diff)

fixed #1299 spent 3h

  • 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
58    def testWCAGLogo(self):
59        ob = self.construct('Piece', 'TestPiece4' ,self.folder)
60        #path='/'.join((self.folder.absolute_url_path(),'TestPiece4'))
61        path = ob.absolute_url_path()+'/view'
62        result = self.publish(path).getBody()
63        self.failUnless(result.find("Explanation of Level Double-A Conformance") != -1, "WCAG log not found? It may be possible that user doesn't have access to view object.")
64
65def test_suite():
66    from unittest import TestSuite, makeSuite
67    suite = TestSuite()
68    suite.addTest(makeSuite(TestPiece))
69    return suite
70
71if __name__ == '__main__':
72    framework()
Note: See TracBrowser for help on using the repository browser.