Changeset 9200
- Timestamp:
- 19 Sep 2012, 05:33:38 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/hostels/tests.py
r9197 r9200 37 37 from waeup.kofa.hostels.container import HostelsContainer 38 38 from waeup.kofa.hostels.hostel import Hostel, Bed 39 from waeup.kofa.hostels.export import BedExporter, HostelExporter 39 40 from waeup.kofa.testing import (FunctionalLayer, FunctionalTestCase) 40 41 from waeup.kofa.students.student import Student … … 143 144 # Create a bed 144 145 bed = Bed() 145 bed.bed_id = u' xyz'146 bed.bed_id = u'hall_block_room_bed' 146 147 bed.bed_number = 1 147 bed.bed_type = u'a bc'148 bed.bed_type = u'a_b_c' 148 149 self.app['hostels'][hostel.hostel_id][bed.bed_id] = bed 149 150 … … 175 176 # We can find a certain bed 176 177 cat = queryUtility(ICatalog, name='beds_catalog') 177 results = cat.searchResults(bed_type=(u'a bc', u'abc'))178 results = cat.searchResults(bed_type=(u'a_b_c', u'a_b_c')) 178 179 results = [x for x in results] # Turn results generator into list 179 180 assert len(results) == 1 180 assert results[0] is self.app['hostels']['hall-x'][' xyz']181 assert results[0] is self.app['hostels']['hall-x']['hall_block_room_bed'] 181 182 182 183 def test_search_by_owner(self): 183 184 # We can find a certain bed 184 myobj = self.app['hostels']['hall-x'][' xyz']185 myobj = self.app['hostels']['hall-x']['hall_block_room_bed'] 185 186 myobj.owner = u'abc' 186 187 notify(grok.ObjectModifiedEvent(myobj)) … … 189 190 results = [x for x in results] # Turn results generator into list 190 191 assert len(results) == 1 191 assert results[0] is self.app['hostels']['hall-x'][' xyz']192 assert results[0] is self.app['hostels']['hall-x']['hall_block_room_bed'] 192 193 193 194 class HostelsUITests(HostelsFullSetup): … … 387 388 self.assertTrue('zope.mgr - hostels.browser.HostelsContainerManagePage' 388 389 ' - hostels - all hostels cleared' in logcontent) 390 391 class ExportTests(HostelsFullSetup): 392 393 layer = FunctionalLayer 394 395 def setUp(self): 396 super(ExportTests, self).setUp() 397 self.workdir = tempfile.mkdtemp() 398 self.outfile = os.path.join(self.workdir, 'myoutput.csv') 399 return 400 401 def test_export_hostels(self): 402 exporter = HostelExporter() 403 exporter.export_all(self.app, self.outfile) 404 result = open(self.outfile, 'rb').read() 405 self.assertEqual( 406 result, 407 'beds_for_all,beds_for_final,beds_for_fresh,beds_for_pre,' 408 'beds_for_returning,beds_reserved,blocks_for_female,' 409 'blocks_for_male,floors_per_block,hostel_id,hostel_name,' 410 'rooms_per_floor,sort_id,special_handling\r\n,,,,,[],,,1,' 411 'hall-x,Hall 1,2,10,regular\r\n' 412 ) 413 return 414 415 def test_export_beds(self): 416 exporter = BedExporter() 417 exporter.export_all(self.app, self.outfile) 418 result = open(self.outfile, 'rb').read() 419 self.assertEqual( 420 result, 421 'bed_id,bed_number,bed_type,owner,hall,block,room,bed,' 422 'special_handling,sex,bt\r\nhall_block_room_bed,1,a_b_c,,' 423 'hall,block,room,bed,a,b,c\r\n' 424 ) 425 return
Note: See TracChangeset for help on using the changeset viewer.