Changeset 4278 for waeup


Ignore:
Timestamp:
13 Jun 2009, 14:15:24 (15 years ago)
Author:
uli
Message:

Test imports of CSV data for departments and courses.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • waeup/branches/ulif-rewrite/src/waeup/browser.txt

    r4276 r4278  
    199199  ['myfaculties.csv']
    200200
     201We create and upload also a CSV file containing departments:
     202
     203  >>> open('departments.csv', 'wb').write(
     204  ... """code,title,title_prefix,faculty_code
     205  ... LIT,Literature,Department,FA
     206  ... SOC,Sociology,Department,FA
     207  ... PHY,Physics,Department,FS
     208  ... INF,Informatics,Department,FS
     209  ... MAT,Math,Department,FS
     210  ... """)
     211
     212  >>> browser.open('http://localhost/myuniversity/datacenter/upload')
     213  >>> browser.getControl(name='uploadfile:file').add_file(
     214  ...   cStringIO.StringIO(open('departments.csv', 'rb').read()),
     215  ...   'text/plain', 'mydepartments.csv')
     216  >>> browser.getControl(name='SUBMIT').click()
     217
     218We create and upload also a CSV file containing courses:
     219
     220  >>> open('courses.csv', 'wb').write(
     221  ... """code,level,title,passmark,credits,semester,faculty,department
     222  ... LI1,,Introduction to Literature I,40,2,1,FA,LIT
     223  ... LI2,,Introduction to Literature II,40,2,2,FA,LIT
     224  ... AN1,000,Analysis I,40,2,1,FS,MAT
     225  ... AN2,000,Analysis II,40,2,2,FS,MAT
     226  ... """)
     227
     228  >>> browser.open('http://localhost/myuniversity/datacenter/upload')
     229  >>> browser.getControl(name='uploadfile:file').add_file(
     230  ...   cStringIO.StringIO(open('courses.csv', 'rb').read()),
     231  ...   'text/plain', 'mycourses.csv')
     232  >>> browser.getControl(name='SUBMIT').click()
     233
     234
    201235
    202236Importing a CSV file
     
    217251  ...myfaculties.csv...
    218252  ...Faculty Importer...
     253  ...mydepartments.csv...
     254  ...Department Importer...
     255  ...mycourses.csv...
     256  ...Course Importer...
    219257  ...
    220258
     
    222260tell us what kind of importer is available for each.
    223261
    224 We do import the faculty file by clicking on ``Import!``:
    225 
    226   >>> facimport = browser.getControl('Import!')
     262We do import the faculty file by clicking on ``Import!`` next to the
     263appropriate file:
     264
     265  >>> facimport = browser.getControl('Import!', index=0)
    227266  >>> facimport.click()
    228267
     
    242281  ...
    243282
     283We can also import the department data:
     284
     285  >>> browser.open('http://localhost/myuniversity/datacenter')
     286  >>> browser.getLink('Import CSV data').click()
     287  >>> browser.getControl('Import!', index=1).click()
     288
     289  >>> print browser.contents
     290  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
     291  ...Successfully imported: mydepartments.csv...
     292  ...
     293
     294We can also import the course data:
     295
     296  >>> browser.open('http://localhost/myuniversity/datacenter')
     297  >>> browser.getLink('Import CSV data').click()
     298  >>> browser.getControl('Import!', index=2).click()
     299
     300  >>> print browser.contents
     301  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
     302  ...Successfully imported: mycourses.csv...
     303  ...
     304
     305
    244306Clean up:
    245307
Note: See TracChangeset for help on using the changeset viewer.