Index: main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_applicants.py
===================================================================
--- main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_applicants.py	(revision 6538)
+++ main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_applicants.py	(revision 6539)
@@ -23,7 +23,10 @@
 """
 import unittest
+from StringIO import StringIO
+from hurry.file.interfaces import IFileRetrieval
 from zope.app.testing.functional import FunctionalTestCase
 from zope.component import (
     provideAdapter, adapts, getGlobalSiteManager, provideUtility)
+from zope.component.hooks import setSite
 from zope.component.interfaces import IFactory
 from zope.interface import verify, implements
@@ -31,5 +34,6 @@
 from zope.publisher.base import TestRequest
 from zope.publisher.interfaces import NotFound
-from waeup.sirp.image.image import WAeUPImageFile
+from waeup.sirp.app import University
+from waeup.sirp.image import WAeUPImageFile, createWAeUPImageFile
 from waeup.sirp.image.interfaces import IWAeUPImageFile
 from waeup.sirp.applicants import (
@@ -39,4 +43,5 @@
     IResultEntry, IApplicant,
     )
+from waeup.sirp.imagestorage import ImageStorageFileRetrieval
 from waeup.sirp.testing import FunctionalLayer
 
@@ -70,12 +75,39 @@
 
     def setUp(self):
+        super(ApplicantTest, self).setUp()
         self.applicant = Applicant()
+        return
 
     def tearDown(self):
-        pass
+        super(ApplicantTest, self).tearDown()
+        return
 
     def test_interfaces(self):
         verify.verifyClass(IApplicant, Applicant)
         verify.verifyObject(IApplicant, self.applicant)
+        return
+
+    def test_passport_no_site(self):
+        # make sure we get a real image stored in passport attr
+        image = self.applicant.passport.file.read()
+        self.assertEqual(len(image), 2059)
+        return
+
+    def test_passport_insite(self):
+        # make sure we get a real image in passport attr when inside a site.
+        # When an applicant is created 'inside a site', its passport
+        # photograph should be put inside the images folder of the
+        # site, even if it is only a placeholder.
+        self.getRootFolder()['app'] = University()
+        app = self.getRootFolder()['app']
+        setSite(app)
+        applicant = Applicant()
+        image = self.applicant.passport.file.read()
+        self.assertEqual(len(image), 2059)
+        # The image contains a file_id instead of real image-data
+        self.assertEqual(self.applicant.passport.data,
+                         u'b48a1d39bbcb32e955d9ff2dea4ed0e6-1')
+        assert u'b48a1d39bbcb32e955d9ff2dea4ed0e6' in app['images'].keys()
+        return
 
 class ApplicantFactoryTest(FunctionalTestCase):
@@ -84,4 +116,7 @@
 
     def setUp(self):
+        # Install a IFileRetrieval utility that returns WAeUPImageFiles.
+        storage = ImageStorageFileRetrieval()
+        provideUtility(storage, IFileRetrieval)
         self.factory = ApplicantFactory()
 
@@ -146,5 +181,6 @@
             self.applicant, self.request
             )
-        self.applicant.passport = WAeUPImageFile('nofile.jpg', '')
+        self.applicant.passport = createWAeUPImageFile(
+            'nofile.jpg', StringIO('no-content'))
         self.applicant.passport.filename = 'mypic.jpg'
         result = traverser.publishTraverse(self.request, 'passport.jpg')
