- Timestamp:
- 3 Oct 2011, 11:28:07 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py
r6845 r6852 25 25 import shutil 26 26 import tempfile 27 import cStringIO 27 28 from datetime import datetime 28 29 from zope.component import createObject … … 39 40 40 41 PH_LEN = 2059 # Length of placeholder file 42 43 def lookup_submit_value(name, value, browser): 44 """Find a button with a certain value.""" 45 for num in range(0, 100): 46 try: 47 button = browser.getControl(name=name, index=num) 48 if button.value.endswith(value): 49 return button 50 except IndexError: 51 break 52 return None 41 53 42 54 class StudentsFullSetup(FunctionalTestCase): … … 388 400 self.browser.getControl("Save").click() 389 401 return 402 403 def test_manage_import(self): 404 # Managers can import student data files 405 datacenter_path = 'http://localhost/app/datacenter' 406 # Prepare a csv file for students 407 open('students.csv', 'wb').write( 408 """firstname,lastname,fullname,reg_number,date_of_birth,matric_number 409 Aaren,Pieri,Aaren Pieri,1,1990-01-02,100000 410 Claus,Finau,Claus Finau,2,1990-01-03,100001 411 Brit,Berson,Brit Berson,3,1990-01-04,100001 412 """) 413 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 414 self.browser.open(datacenter_path) 415 self.browser.getLink('Upload CSV file').click() 416 filecontents = cStringIO.StringIO(open('students.csv', 'rb').read()) 417 filewidget = self.browser.getControl(name='uploadfile:file') 418 filewidget.add_file(filecontents, 'text/plain', 'students.csv') 419 self.browser.getControl(name='SUBMIT').click() 420 self.browser.getLink('Batch processing').click() 421 button = lookup_submit_value( 422 'select', 'students_zope.mgr.csv', self.browser) 423 button.click() 424 importerselect = self.browser.getControl(name='importer') 425 modeselect = self.browser.getControl(name='mode') 426 importerselect.getControl('Student Importer').selected = True 427 modeselect.getControl(value='create').selected = True 428 self.browser.getControl('Proceed to step 3...').click() 429 self.assertTrue('Header fields OK' in self.browser.contents) 430 self.browser.getControl('Perform import...').click() 431 self.assertTrue('Processing of 1 rows failed' in self.browser.contents) 432 self.assertTrue('Successfully processed 2 rows' in self.browser.contents) 433 self.assertTrue('Batch processing finished' in self.browser.contents) 434 open('studycourses.csv', 'wb').write( 435 """reg_number,matric_number,certificate,current_session,current_level 436 1,,CERT1,2008,100 437 ,100001,CERT1,2008,100 438 ,100002,CERT1,2008,100 439 """) 440 self.browser.open(datacenter_path) 441 self.browser.getLink('Upload CSV file').click() 442 filecontents = cStringIO.StringIO(open('studycourses.csv', 'rb').read()) 443 filewidget = self.browser.getControl(name='uploadfile:file') 444 filewidget.add_file(filecontents, 'text/plain', 'studycourses.csv') 445 self.browser.getControl(name='SUBMIT').click() 446 self.browser.getLink('Batch processing').click() 447 button = lookup_submit_value( 448 'select', 'studycourses_zope.mgr.csv', self.browser) 449 button.click() 450 importerselect = self.browser.getControl(name='importer') 451 modeselect = self.browser.getControl(name='mode') 452 importerselect.getControl( 453 'StudentStudyCourse Importer (update only)').selected = True 454 modeselect.getControl(value='create').selected = True 455 self.browser.getControl('Proceed to step 3...').click() 456 self.assertTrue('Update mode only' in self.browser.contents) 457 self.browser.getControl('Proceed to step 3...').click() 458 self.assertTrue('Header fields OK' in self.browser.contents) 459 self.browser.getControl('Perform import...').click() 460 self.assertTrue('Processing of 1 rows failed' in self.browser.contents) 461 self.assertTrue('Successfully processed 2 rows' in self.browser.contents) 390 462 391 463 def test_student_change_password(self):
Note: See TracChangeset for help on using the changeset viewer.