- Timestamp:
- 23 Jul 2011, 02:49:20 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_applicants.py
r6297 r6539 23 23 """ 24 24 import unittest 25 from StringIO import StringIO 26 from hurry.file.interfaces import IFileRetrieval 25 27 from zope.app.testing.functional import FunctionalTestCase 26 28 from zope.component import ( 27 29 provideAdapter, adapts, getGlobalSiteManager, provideUtility) 30 from zope.component.hooks import setSite 28 31 from zope.component.interfaces import IFactory 29 32 from zope.interface import verify, implements … … 31 34 from zope.publisher.base import TestRequest 32 35 from zope.publisher.interfaces import NotFound 33 from waeup.sirp.image.image import WAeUPImageFile 36 from waeup.sirp.app import University 37 from waeup.sirp.image import WAeUPImageFile, createWAeUPImageFile 34 38 from waeup.sirp.image.interfaces import IWAeUPImageFile 35 39 from waeup.sirp.applicants import ( … … 39 43 IResultEntry, IApplicant, 40 44 ) 45 from waeup.sirp.imagestorage import ImageStorageFileRetrieval 41 46 from waeup.sirp.testing import FunctionalLayer 42 47 … … 70 75 71 76 def setUp(self): 77 super(ApplicantTest, self).setUp() 72 78 self.applicant = Applicant() 79 return 73 80 74 81 def tearDown(self): 75 pass 82 super(ApplicantTest, self).tearDown() 83 return 76 84 77 85 def test_interfaces(self): 78 86 verify.verifyClass(IApplicant, Applicant) 79 87 verify.verifyObject(IApplicant, self.applicant) 88 return 89 90 def test_passport_no_site(self): 91 # make sure we get a real image stored in passport attr 92 image = self.applicant.passport.file.read() 93 self.assertEqual(len(image), 2059) 94 return 95 96 def test_passport_insite(self): 97 # make sure we get a real image in passport attr when inside a site. 98 # When an applicant is created 'inside a site', its passport 99 # photograph should be put inside the images folder of the 100 # site, even if it is only a placeholder. 101 self.getRootFolder()['app'] = University() 102 app = self.getRootFolder()['app'] 103 setSite(app) 104 applicant = Applicant() 105 image = self.applicant.passport.file.read() 106 self.assertEqual(len(image), 2059) 107 # The image contains a file_id instead of real image-data 108 self.assertEqual(self.applicant.passport.data, 109 u'b48a1d39bbcb32e955d9ff2dea4ed0e6-1') 110 assert u'b48a1d39bbcb32e955d9ff2dea4ed0e6' in app['images'].keys() 111 return 80 112 81 113 class ApplicantFactoryTest(FunctionalTestCase): … … 84 116 85 117 def setUp(self): 118 # Install a IFileRetrieval utility that returns WAeUPImageFiles. 119 storage = ImageStorageFileRetrieval() 120 provideUtility(storage, IFileRetrieval) 86 121 self.factory = ApplicantFactory() 87 122 … … 146 181 self.applicant, self.request 147 182 ) 148 self.applicant.passport = WAeUPImageFile('nofile.jpg', '') 183 self.applicant.passport = createWAeUPImageFile( 184 'nofile.jpg', StringIO('no-content')) 149 185 self.applicant.passport.filename = 'mypic.jpg' 150 186 result = traverser.publishTraverse(self.request, 'passport.jpg')
Note: See TracChangeset for help on using the changeset viewer.