Changeset 7121 for main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests
- Timestamp:
- 16 Nov 2011, 18:07:03 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_applicant.py
r7063 r7121 23 23 """ 24 24 import grok 25 import os 26 import shutil 27 import tempfile 25 28 import unittest 29 from StringIO import StringIO 26 30 from zope.component import adapts, queryUtility 27 31 from zope.component.interfaces import IFactory … … 48 52 layer = FunctionalLayer 49 53 54 def setUp(self): 55 super(HelperTests, self).setUp() 56 self.workdir = tempfile.mkdtemp() 57 return 58 59 def tearDown(self): 60 super(HelperTests, self).tearDown() 61 shutil.rmtree(self.workdir) 62 return 63 50 64 def test_get_regno_or_ac(self): 51 65 # we can get reg_no or access_code of an applicants if it is set … … 85 99 store, '/fake-root', '__img-applicant__dir1/dir2/sample.jpg') 86 100 self.assertEqual( 87 result1, '/fake-root/applicants/sample.jpg') 88 self.assertEqual( 89 result2, '/fake-root/applicants/dir1/sample.jpg') 90 self.assertEqual( 91 result3, '/fake-root/applicants/dir1/dir2/sample.jpg') 101 result1, '/fake-root/applicants/sample') 102 self.assertEqual( 103 result2, '/fake-root/applicants/dir1/sample') 104 self.assertEqual( 105 result3, '/fake-root/applicants/dir1/dir2/sample') 106 return 107 108 def test_image_store_handler_create(self): 109 # we can create files in image store with the applicant image 110 # store handler 111 store = DefaultStorage(self.workdir) 112 handler = queryUtility(IFileStoreHandler, name='img-applicant') 113 file_obj, path, waeup_file = handler.createFile( 114 store, store.root, 'sample.jpg', '__img_applicant__sample', 115 StringIO('I am a JPG file')) 116 self.assertEqual(path[-21:], 'applicants/sample.jpg') 117 return 118 119 def test_image_store_handler_invalid_filename_ext(self): 120 # we only accept '.jpg' and '.png' as filename extensions. 121 store = DefaultStorage() 122 handler = queryUtility(IFileStoreHandler, name='img-applicant') 123 self.assertRaises( 124 ValueError, 125 handler.createFile, 126 store, store.root, 'sample.txt', '__img_applicant__sample', 127 StringIO('I am a txt file')) 92 128 return 93 129
Note: See TracChangeset for help on using the changeset viewer.