Changeset 17313 for main/waeup.kofa/trunk/src/waeup/kofa/hostels/tests.py
- Timestamp:
- 25 Jan 2023, 08:52:51 (22 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/hostels/tests.py
r17176 r17313 31 31 from zope.security.interfaces import Unauthorized 32 32 from zope.catalog.interfaces import ICatalog 33 from zope.component import queryUtility, getUtility 33 from zope.component import queryUtility, getUtility, createObject 34 34 from waeup.kofa.app import University 35 35 from waeup.kofa.hostels.interfaces import ( … … 54 54 BED_SAMPLE_DATA = open( 55 55 os.path.join(os.path.dirname(__file__), 'sample_bed_data.csv'), 56 'rb').read() 57 58 BED_SAMPLE_DATA_2 = open( 59 os.path.join(os.path.dirname(__file__), 'sample_bed_data_2.csv'), 56 60 'rb').read() 57 61 … … 396 400 (u'hall-1_A_101_C', u'regular_female_reserved'), 397 401 (u'hall-1_A_101_D', u'regular_female_reserved')]) 402 # Block beds. 403 self.browser.getControl("Switch blockade", index=0).click() 404 self.assertTrue('No item selected' in self.browser.contents) 405 ctrl = self.browser.getControl(name='val_id') 406 ctrl.getControl(value='hall-1_A_101_A').selected = True 407 ctrl.getControl(value='hall-1_A_101_B').selected = True 408 ctrl.getControl(value='hall-1_A_101_C').selected = True 409 ctrl.getControl(value='hall-1_A_101_D').selected = True 410 self.browser.getControl("Switch blockade", index=0).click() 411 self.assertTrue('Successfully switched beds: hall-1_A_101_A (blocked)' 412 in self.browser.contents) 413 self.assertEqual(self.app['hostels']['hall-1'][ 414 'hall-1_A_101_D'].bed_type, 'regular_female_blocked') 415 # The catalog has been updated. 416 results = cat.searchResults( 417 bed_type=('regular_female_all', 'regular_female_all')) 418 results = [(x.bed_id, x.bed_type) for x in results] 419 self.assertEqual(results, 420 [(u'hall-1_A_101_E', u'regular_female_all'), 421 (u'hall-1_B_101_D', u'regular_female_all'), 422 (u'hall-1_B_101_E', u'regular_female_all')]) 423 results = cat.searchResults( 424 bed_type=('regular_female_blocked', 'regular_female_blocked')) 425 results = [(x.bed_id, x.bed_type) for x in results] 426 self.assertEqual(results, 427 [(u'hall-1_A_101_A', u'regular_female_blocked'), 428 (u'hall-1_A_101_B', u'regular_female_blocked'), 429 (u'hall-1_A_101_C', u'regular_female_blocked'), 430 (u'hall-1_A_101_D', u'regular_female_blocked')]) 398 431 # Change hostel configuration with one bed booked. 399 432 hall['hall-1_A_101_E'].owner = u'anyid' … … 672 705 logcontent = open(self.logfile).read() 673 706 self.assertEqual( 674 'owner,bed_id,hostel_id,reserved, --ERRORS--\r\n'675 '<IGNORE>,block-a-upper-hostel_A_101_C,block-a-upper-hostel,2, '707 'owner,bed_id,hostel_id,reserved,blocked,--ERRORS--\r\n' 708 '<IGNORE>,block-a-upper-hostel_A_101_C,block-a-upper-hostel,2,0,' 676 709 'reserved: invalid value\r\n' 677 'K999,block-a-upper-hostel_A_101_E,block-a-upper-hostel,0, '710 'K999,block-a-upper-hostel_A_101_E,block-a-upper-hostel,0,0,' 678 711 'owner: student does not exist\r\n', 679 712 fail_file_content) 680 713 self.assertTrue( 681 714 'system - Bed Processor (update only) - sample_bed_data - ' 682 'block-a-upper-hostel_A_101_A - updated: nothing'715 'block-a-upper-hostel_A_101_A - updated: blocked' 683 716 in logcontent) 684 717 self.assertTrue( … … 697 730 ['block-a-upper-hostel_A_101_B'].bed_type, 698 731 'regular_female_reserved') 732 # Add another student K1000001 733 student = createObject('waeup.Student') 734 student.firstname = u'Claus' 735 student.lastname = u'Tester' 736 self.app['students'].addStudent(student) 737 # Try to allocate this student to a blocked bed 738 739 open(self.csv_file, 'wb').write(BED_SAMPLE_DATA_2) 740 num, num_warns, fin_file, fail_file = self.processor.doImport( 741 self.csv_file, BED_HEADER_FIELDS, 'update') 742 fail_file_content = open(fail_file).read() 743 self.assertEqual( 744 'owner,bed_id,hostel_id,reserved,blocked,--ERRORS--\r\n' 745 'K1000001,block-a-upper-hostel_A_101_A,block-a-upper-hostel,' 746 '<IGNORE>,<IGNORE>,Bed is blocked.\r\n', 747 fail_file_content) 699 748 shutil.rmtree(os.path.dirname(fin_file)) 700 749 shutil.rmtree(self.workdir)
Note: See TracChangeset for help on using the changeset viewer.